Wuyx
2017-01-04 0ba5a82e9ec833aa36729dfbad7deffbf3ea05c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
//    wax_http_connection.h
//    RentList
//
//    Created by Corey Johnson on 8/9/09.
//    Copyright 2009 ProbablyInteractive. All rights reserved.
//
 
#import <UIKit/UIKit.h>
//#import "lua.h"
#import <lua/lua.h>
 
enum {
    WAX_HTTP_UNKNOWN,
    WAX_HTTP_TEXT,
    WAX_HTTP_BINARY, // Like an image or something
    WAX_HTTP_JSON,
    WAX_HTTP_XML
};
 
#define WAX_HTTP_CALLBACK_FUNCTION_NAME "callback"
#define WAX_HTTP_PROGRESS_CALLBACK_FUNCTION_NAME "progressCallback"
#define WAX_HTTP_AUTH_CALLBACK_FUNCTION_NAME "authCallback"
#define WAX_HTTP_REDIRECT_CALLBACK_FUNCTION_NAME "redirectCallback"
 
@interface wax_http_connection : NSURLConnection {
    lua_State *L;
    NSMutableData *_data;
    NSHTTPURLResponse *_response;
    NSURLRequest *_request;
    NSTimer *_timeoutTimer;
    NSError *_error;
    
    NSTimeInterval _timeout;
    int _format;
    bool _finished;
    bool _canceled;
}
 
@property (nonatomic, assign) NSHTTPURLResponse *response;
 
@property (nonatomic, assign) int format;
@property (nonatomic, readonly, getter=isFinished) bool finished;
 
- (id)initWithRequest:(NSURLRequest *)urlRequest timeout:(NSTimeInterval)timeout luaState:(lua_State *)luaState;
- (void)callRedirectCallback:(NSURLResponse *)redirectResponse;
- (BOOL)callLuaAuthCallback:(NSURLAuthenticationChallenge *)challenge;
- (void)callLuaProgressCallback;
- (void)callLuaCallback;
 
// HSHTTPURLResponse Delegate Methods
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
 
@end