BYRequest based on MKNetowrkKit, but it works like ASIHttpRequest, so you can easily migrate your project from ASIHttpRequest to BYRequest and also enjoy ARC.
Objective-C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
BYRequest
BYRequestDemo.xcworkspace
BYRequestDemo
README.md

README.md

*ASIHTTPRequest replacement, MKNetowrkKit based, ARC support, file upload integrated. *

Create your customized request.

Subcalss BYRequest to construct a network request, request customize methods:

- (NSString )apiRequestMethod;

- (NSString )apiURLPrefix;

- (NSString )apiURLSuffix; / request param dictionary /

- (NSMutableDictionary )parameters;

- (BOOL)validateParameters:(NSMutableString *)errorMessage;

- (Class)responseClass;

Subclass BYResponse to specifically handle your response in function:

- (id)initWithResponseDictionary:(NSDictionary *)responseDictionary;

How to Use

Start the request:

[_testRequest cancel];

_testRequest = [[MyTestRequest alloc] initParam:@"1"]; _testRequest.resultDelegate = self;

_testRequest.requestCache=NO;

//upload file //if it is from library

if(_asset) {

[_testRequest addAsset:_asset forKey:@"uploadfile"];

} else {

[_testRequest addFile:_cacheFilePath forKey:@"uploadfile"];

}

[_testRequest sendAsynchronous];

Handle Response in one single delegate function:

- (void)request:(BYRequest )request didEndWithResponse:(BYResponse )response

{

if (response.isError) {

DLog(@"ERROR:%@",response.errorMessage);

}

else {

if ([response isKindOfClass:[MyTestResponse class]]) {

[self.demoWebView loadHTMLString:request.responseString baseURL:[NSURL URLWithString:@"http://www.noahsecure.com"] ];

}

}

}

Features

1.It automatically uses caches when network is unavailable.

2.The BYRequest supports addFile and addAsset for POST, so you can upload file directly by passing a file path, upload pictures/videos directly by passing the ALAsset from Library

-(void) addAsset:(ALAsset) inAssert forKey:(NSString) key;

-(void) addFile:(NSString) filePath forKey:(NSString) key;

3.HTTP Stream uploading is supported in the above two methods. Avoid large memory usage in ASIHTTPRequest, which read the whole file into memory, causing app killed for shortage of memory.