forked from luisobo/Nocilla
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support requests using HTTPBodyStream
NSURLRequest's HTTPBody and HTTPBodyStream are mutually exclusive, so first check if HTTPBodyStream is non-nil and read its entire contents as the request body.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
NocillaTests/Hooks/NSURLRequest/NSURLRequest+LSHTTPRequestSpec.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#import "Kiwi.h" | ||
#import "NSURLRequest+LSHTTPRequest.h" | ||
|
||
SPEC_BEGIN(NSURLRequest_LSHTTPRequestSpec) | ||
|
||
describe(@"-body", ^{ | ||
__block NSURLRequest *request; | ||
|
||
context(@"when the request provides a body stream", ^{ | ||
__block NSString *stringUrl = @"http://api.example.com/dogs.xml"; | ||
__block NSData *requestBody = [@"arg1=foo&arg2=bar" dataUsingEncoding:NSUTF8StringEncoding]; | ||
|
||
beforeEach(^{ | ||
NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:stringUrl]]; | ||
mutableRequest.HTTPBodyStream = [NSInputStream inputStreamWithData:requestBody]; | ||
request = mutableRequest; | ||
}); | ||
|
||
it(@"uses the entire stream as the body", ^{ | ||
[[[request body] should] equal:requestBody]; | ||
}); | ||
}); | ||
}); | ||
|
||
SPEC_END |