Ben Copsey

Tweak naming for HTTPVersionOne property

Add test for same
@@ -212,7 +212,8 @@ typedef enum _ASINetworkErrorType { @@ -212,7 +212,8 @@ typedef enum _ASINetworkErrorType {
212 // Custom user information assosiated with the request 212 // Custom user information assosiated with the request
213 NSDictionary *userInfo; 213 NSDictionary *userInfo;
214 214
215 - BOOL HTTPVersionOne; 215 + // Use HTTP 1.0 rather than 1.1 (defaults to false)
  216 + BOOL useHTTPVersionOne;
216 217
217 } 218 }
218 219
@@ -396,6 +397,6 @@ typedef enum _ASINetworkErrorType { @@ -396,6 +397,6 @@ typedef enum _ASINetworkErrorType {
396 @property (retain) NSInputStream *postBodyReadStream; 397 @property (retain) NSInputStream *postBodyReadStream;
397 @property (assign) BOOL shouldStreamPostDataFromDisk; 398 @property (assign) BOOL shouldStreamPostDataFromDisk;
398 @property (assign) BOOL didCreateTemporaryPostDataFile; 399 @property (assign) BOOL didCreateTemporaryPostDataFile;
399 -@property (assign) BOOL HTTPVersionOne; 400 +@property (assign) BOOL useHTTPVersionOne;
400 401
401 @end 402 @end
@@ -301,7 +301,7 @@ static NSError *ASIUnableToCreateRequestError; @@ -301,7 +301,7 @@ static NSError *ASIUnableToCreateRequestError;
301 } 301 }
302 302
303 // Create a new HTTP request. 303 // Create a new HTTP request.
304 - request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)requestMethod, (CFURLRef)url, self.HTTPVersionOne ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1); 304 + request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)requestMethod, (CFURLRef)url, self.useHTTPVersionOne ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1);
305 if (!request) { 305 if (!request) {
306 [self failWithError:ASIUnableToCreateRequestError]; 306 [self failWithError:ASIUnableToCreateRequestError];
307 return; 307 return;
@@ -1625,5 +1625,5 @@ static NSError *ASIUnableToCreateRequestError; @@ -1625,5 +1625,5 @@ static NSError *ASIUnableToCreateRequestError;
1625 @synthesize postBodyReadStream; 1625 @synthesize postBodyReadStream;
1626 @synthesize shouldStreamPostDataFromDisk; 1626 @synthesize shouldStreamPostDataFromDisk;
1627 @synthesize didCreateTemporaryPostDataFile; 1627 @synthesize didCreateTemporaryPostDataFile;
1628 -@synthesize HTTPVersionOne; 1628 +@synthesize useHTTPVersionOne;
1629 @end 1629 @end
@@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
19 - (void)testBasicDownload; 19 - (void)testBasicDownload;
20 - (void)testTimeOut; 20 - (void)testTimeOut;
21 - (void)testRequestMethod; 21 - (void)testRequestMethod;
  22 +- (void)testHTTPVersion;
22 - (void)testUploadContentLength; 23 - (void)testUploadContentLength;
23 - (void)testDownloadContentLength; 24 - (void)testDownloadContentLength;
24 - (void)testFileDownload; 25 - (void)testFileDownload;
@@ -109,6 +109,23 @@ @@ -109,6 +109,23 @@
109 } 109 }
110 } 110 }
111 111
  112 +- (void)testHTTPVersion
  113 +{
  114 + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/http-version"] autorelease];
  115 + ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
  116 + [request start];
  117 +
  118 + BOOL success = [[request responseString] isEqualToString:@"HTTP/1.1"];
  119 + GHAssertTrue(success,@"Wrong HTTP version used");
  120 +
  121 + request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
  122 + [request setUseHTTPVersionOne:YES];
  123 + [request start];
  124 +
  125 + success = [[request responseString] isEqualToString:@"HTTP/1.0"];
  126 + GHAssertTrue(success,@"Wrong HTTP version used");
  127 +}
  128 +
112 - (void)testUploadContentLength 129 - (void)testUploadContentLength
113 { 130 {
114 //This url will return the contents of the Content-Length request header 131 //This url will return the contents of the Content-Length request header