gowalla/AFNetworking — Issue #86: Badly formed HTTP Request for Uploading a file
Author: wmketterer
Created: 2011-10-20 22:17:34+00:00
State: open

Couple of issues with the uploading, but the primary issues I found were involving uploading a file with additional parameters.

This function is called before the form data:

- (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body {
[self appendString:AFMultipartFormEncapsulationBoundary()];

for (NSString *field in [headers allKeys]) {
[self appendString:[NSString stringWithFormat:@"%@: %@%@", field, [headers valueForKey:field], kAFMultipartFormLineDelimiter]];
}

[self appendString:kAFMultipartFormLineDelimiter];
[self appendData:body];
}

The AFMultipartFormEncapsulationBoundry includes a kAFMultipartFormLineDelimiter (CRLF) at the beginning. This additional CRLF causes a EOFError (bad content body) on the rails server I was pointing at.

As an aside AFMultipartFormFinalBoundary should probably include a CRLF after the '--' at the end.

Let me know if there is any additional detail I can provide.