Ben Copsey

Fix issue with new encoding parsing code

All tests now pass on Mac and iPhone
@@ -25,7 +25,11 @@ @@ -25,7 +25,11 @@
25 ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; 25 ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
26 26
27 NSDate *d = [NSDate new]; 27 NSDate *d = [NSDate new];
  28 +#if TARGET_OS_IPHONE
28 NSValue *v = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)]; 29 NSValue *v = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
  30 +#else
  31 + NSValue *v = [NSValue valueWithRect:NSMakeRect(0, 0, 200, 200)];
  32 +#endif
29 [request setPostValue:@"foo" forKey:@"post_var"]; 33 [request setPostValue:@"foo" forKey:@"post_var"];
30 [request setPostValue:d forKey:@"post_var2"]; 34 [request setPostValue:d forKey:@"post_var2"];
31 [request setPostValue:v forKey:@"post_var3"]; 35 [request setPostValue:v forKey:@"post_var3"];
@@ -593,11 +593,13 @@ static NSError *ASIUnableToCreateRequestError; @@ -593,11 +593,13 @@ static NSError *ASIUnableToCreateRequestError;
593 593
594 - (void)updateDownloadProgress 594 - (void)updateDownloadProgress
595 { 595 {
596 - unsigned long long bytesReadSoFar = totalBytesRead; 596 +
597 597
598 // We won't update download progress until we've examined the headers, since we might need to authenticate 598 // We won't update download progress until we've examined the headers, since we might need to authenticate
599 if (responseHeaders) { 599 if (responseHeaders) {
600 600
  601 + unsigned long long bytesReadSoFar = totalBytesRead;
  602 +
601 if (bytesReadSoFar > lastBytesRead) { 603 if (bytesReadSoFar > lastBytesRead) {
602 [self setLastActivityTime:[NSDate date]]; 604 [self setLastActivityTime:[NSDate date]];
603 } 605 }
@@ -774,8 +776,9 @@ static NSError *ASIUnableToCreateRequestError; @@ -774,8 +776,9 @@ static NSError *ASIUnableToCreateRequestError;
774 NSScanner *charsetScanner = [NSScanner scannerWithString: contentType]; 776 NSScanner *charsetScanner = [NSScanner scannerWithString: contentType];
775 NSString *IANAEncoding = nil; 777 NSString *IANAEncoding = nil;
776 778
777 - if ([charsetScanner scanUpToString: charsetSeparator intoString: NULL]) 779 + if ([charsetScanner scanUpToString: charsetSeparator intoString: NULL] && [charsetScanner scanLocation] < [contentType length])
778 { 780 {
  781 + NSLog(@"%hi %hi",[charsetScanner scanLocation],[charsetSeparator length]);
779 [charsetScanner setScanLocation: [charsetScanner scanLocation] + [charsetSeparator length]]; 782 [charsetScanner setScanLocation: [charsetScanner scanLocation] + [charsetSeparator length]];
780 [charsetScanner scanUpToString: @";" intoString: &IANAEncoding]; 783 [charsetScanner scanUpToString: @";" intoString: &IANAEncoding];
781 } 784 }
@@ -166,7 +166,6 @@ @@ -166,7 +166,6 @@
166 BOOL success = [[NSString stringWithContentsOfURL:[NSURL fileURLWithPath:path]] isEqualToString:@"This is the expected content for the first string"]; 166 BOOL success = [[NSString stringWithContentsOfURL:[NSURL fileURLWithPath:path]] isEqualToString:@"This is the expected content for the first string"];
167 GHAssertTrue(success,@"Failed to download data to a file"); 167 GHAssertTrue(success,@"Failed to download data to a file");
168 168
169 -  
170 } 169 }
171 170
172 171
@@ -183,6 +182,12 @@ @@ -183,6 +182,12 @@
183 } 182 }
184 183
185 184
  185 +- (void)setProgress:(float)newProgress;
  186 +{
  187 + progress = newProgress;
  188 +}
  189 +
  190 +
186 - (void)testUploadProgress 191 - (void)testUploadProgress
187 { 192 {
188 progress = 0; 193 progress = 0;
@@ -196,11 +201,6 @@ @@ -196,11 +201,6 @@
196 } 201 }
197 202
198 203
199 -- (void)setProgress:(float)newProgress;  
200 -{  
201 - progress = newProgress;  
202 -}  
203 -  
204 204
205 205
206 - (void)testCookies 206 - (void)testCookies
This diff was suppressed by a .gitattributes entry.