Ben Copsey

Stop sending a charset header for file uploads in ASIFormDataRequest

... ... @@ -200,7 +200,7 @@
NSString *fileName = [fileInfo objectForKey:@"fileName"];
[self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, fileName]];
[self appendPostString:[NSString stringWithFormat:@"Content-Type: %@; charset=%@\r\n\r\n", contentType, charset]];
[self appendPostString:[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", contentType]];
if ([file isKindOfClass:[NSString class]]) {
[self appendPostDataFromFile:file];
... ...
... ... @@ -23,7 +23,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.6.2-7 2010-05-01";
NSString *ASIHTTPRequestVersion = @"v1.6.2-8 2010-05-01";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ...
... ... @@ -176,7 +176,16 @@
[request setStringEncoding:NSWindowsCP1252StringEncoding];
[request startSynchronous];
success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]);
GHAssertTrue(success,@"Failed to correctly encode the data");
GHAssertTrue(success,@"Failed to correctly encode the data");
// Ensure charset isn't added to file post (GH issue 36)
request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/Tests/return-raw-request"]];
[request setData:[@"test 123" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"file"];
[request setRequestMethod:@"PUT"];
[request startSynchronous];
success = ([[request responseString] rangeOfString:@"charset=utf-8"].location == NSNotFound);
GHAssertTrue(success,@"Sent a charset header for an uploaded file");
}
... ...