Skip to content

Commit

Permalink
Merge pull request ReactiveCocoa#1140 from ReactiveCocoa/better-async…
Browse files Browse the repository at this point in the history
…-response-check

Consider a nil NSURLResponse to be an error
  • Loading branch information
joshaber committed Feb 26, 2014
2 parents 68907ed + 2929612 commit 09e17b9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ + (RACSignal *)rac_sendAsynchronousRequest:(NSURLRequest *)request {
queue.name = @"com.github.ReactiveCocoa.NSURLConnectionRACSupport";

[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (data == nil) {
// The docs say that `nil` data means an error occurred, but
// `nil` responses can also occur in practice (circumstances
// unknown). Consider either to be an error.
//
// Note that _empty_ data is not necessarily erroneous, as there
// may be headers but no HTTP body.
if (response == nil || data == nil) {
[subscriber sendError:error];
} else {
[subscriber sendNext:RACTuplePack(response, data)];
Expand Down

0 comments on commit 09e17b9

Please sign in to comment.