I am switching from ASIHTTPRequest
to AFNetworking
in an iOS application.
RF2616 (HTTP/1.1) defines a "status-line" by the combination of "Status Code" and "Reason Phrase". Sometimes the server adds some specific information in this "Reason Phrase" and I found it rather handy that ASIHTTPRequest allowed me to access it easily via
ASIHTTPRequest *request = ...;
NSString *reason = request.responseStatusMessage;
My problem is that I can't find any way to do it with AFHTTPRequestOperation
NSMutableURLRequest *request = ...;
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
In both completion/failure block of the operation i can get the status code by doing:
int statusCode = [operation.response statusCode];
But I can't find where to get the "Reason Phrase".
Some answers on StackOverflow suggest that it would be located in one of the entries of [operation.response allHeaderFields]
but it's not.
An answer to this question << Can I access "Reason Phrase" from the HTTP Status-Line in NSHTTPURLResponse >> suggests changing how the server behaves but that's not always an available option.
Any idea?