Skip to content
Browse files

Added responseStatusMessage

  • Loading branch information...
1 parent be69495 commit e98fd1e4119e23ddb70fb4d5cb1ea2aa83219b78 @pokeb committed Sep 13, 2009
Showing with 16 additions and 2 deletions.
  1. +3 −0 Classes/ASIHTTPRequest.h
  2. +5 −2 Classes/ASIHTTPRequest.m
  3. +8 −0 Classes/Tests/ASIHTTPRequestTests.m
View
3 Classes/ASIHTTPRequest.h
@@ -195,6 +195,8 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
// HTTP status code, eg: 200 = OK, 404 = Not found etc
int responseStatusCode;
+ NSString *responseStatusMessage;
+
// Size of the response
unsigned long long contentLength;
@@ -540,6 +542,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (retain) NSDictionary *requestCredentials;
@property (retain) NSDictionary *proxyCredentials;
@property (assign,readonly) int responseStatusCode;
+@property (retain,readonly) NSString *responseStatusMessage;
@property (retain,readonly) NSMutableData *rawResponseData;
@property (assign) NSTimeInterval timeOutSeconds;
@property (retain) NSString *requestMethod;
View
7 Classes/ASIHTTPRequest.m
@@ -124,7 +124,7 @@ + (void)recordBandwidthUsage;
@property (retain) NSConditionLock *authenticationLock;
@property (retain) NSString *authenticationRealm;
@property (retain) NSString *proxyAuthenticationRealm;
-
+@property (retain) NSString *responseStatusMessage;
@end
@@ -1158,7 +1158,8 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure
CFRelease(headerFields);
[self setResponseStatusCode:CFHTTPMessageGetResponseStatusCode(headers)];
-
+ [self setResponseStatusMessage:[(NSString *)CFHTTPMessageCopyResponseStatusLine(headers) autorelease]];
+
// Is the server response a challenge for credentials?
isAuthenticationChallenge = ([self responseStatusCode] == 401);
if ([self responseStatusCode] == 407) {
@@ -1247,6 +1248,7 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure
CFRelease(headers);
return isAuthenticationChallenge;
}
+
#pragma mark http authentication
@@ -2814,6 +2816,7 @@ + (unsigned long)maxUploadReadLength
@synthesize shouldPresentAuthenticationDialog;
@synthesize shouldPresentProxyAuthenticationDialog;
@synthesize authenticationChallengeInProgress;
+@synthesize responseStatusMessage;
@end
View
8 Classes/Tests/ASIHTTPRequestTests.m
@@ -890,6 +890,14 @@ - (void)testFetchToInvalidPath
GHAssertNotNil([request error],@"Failed to generate an authentication when attempting to write to an invalid location");
}
+- (void)testResponseStatusMessage
+{
+ ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/the-meaning-of-life"]];
+ [request start];
+ BOOL success = [[request responseStatusMessage] isEqualToString:@"HTTP/1.0 404 Not Found"];
+ GHAssertTrue(success,@"Got wrong response status message");
+}
+
@end

0 comments on commit e98fd1e

Please sign in to comment.
Something went wrong with that request. Please try again.