Stop sending a charset header for file uploads in ASIFormDataRequest
Showing
3 changed files
with
12 additions
and
3 deletions
| @@ -200,7 +200,7 @@ | @@ -200,7 +200,7 @@ | ||
| 200 | NSString *fileName = [fileInfo objectForKey:@"fileName"]; | 200 | NSString *fileName = [fileInfo objectForKey:@"fileName"]; |
| 201 | 201 | ||
| 202 | [self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, fileName]]; | 202 | [self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, fileName]]; |
| 203 | - [self appendPostString:[NSString stringWithFormat:@"Content-Type: %@; charset=%@\r\n\r\n", contentType, charset]]; | 203 | + [self appendPostString:[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", contentType]]; |
| 204 | 204 | ||
| 205 | if ([file isKindOfClass:[NSString class]]) { | 205 | if ([file isKindOfClass:[NSString class]]) { |
| 206 | [self appendPostDataFromFile:file]; | 206 | [self appendPostDataFromFile:file]; |
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | // Automatically set on build | 25 | // Automatically set on build |
| 26 | -NSString *ASIHTTPRequestVersion = @"v1.6.2-7 2010-05-01"; | 26 | +NSString *ASIHTTPRequestVersion = @"v1.6.2-8 2010-05-01"; |
| 27 | 27 | ||
| 28 | NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; | 28 | NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; |
| 29 | 29 |
| @@ -176,7 +176,16 @@ | @@ -176,7 +176,16 @@ | ||
| 176 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; | 176 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; |
| 177 | [request startSynchronous]; | 177 | [request startSynchronous]; |
| 178 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); | 178 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); |
| 179 | - GHAssertTrue(success,@"Failed to correctly encode the data"); | 179 | + GHAssertTrue(success,@"Failed to correctly encode the data"); |
| 180 | + | ||
| 181 | + // Ensure charset isn't added to file post (GH issue 36) | ||
| 182 | + request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/Tests/return-raw-request"]]; | ||
| 183 | + [request setData:[@"test 123" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"file"]; | ||
| 184 | + [request setRequestMethod:@"PUT"]; | ||
| 185 | + [request startSynchronous]; | ||
| 186 | + success = ([[request responseString] rangeOfString:@"charset=utf-8"].location == NSNotFound); | ||
| 187 | + GHAssertTrue(success,@"Sent a charset header for an uploaded file"); | ||
| 188 | + | ||
| 180 | 189 | ||
| 181 | } | 190 | } |
| 182 | 191 |
-
Please register or login to post a comment