Merge pull request #134 from raycmorgan/master

Fix issue with multipart boundaries.
This commit is contained in:
Mattt Thompson 2011-11-30 16:36:58 -08:00
commit 922c617945

View file

@ -381,6 +381,10 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
#pragma mark - #pragma mark -
static inline NSString * AFMultipartFormInitialBoundary() {
return [NSString stringWithFormat:@"--%@%@", kAFMultipartFormBoundary, kAFMultipartFormLineDelimiter];
}
static inline NSString * AFMultipartFormEncapsulationBoundary() { static inline NSString * AFMultipartFormEncapsulationBoundary() {
return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormLineDelimiter, kAFMultipartFormBoundary, kAFMultipartFormLineDelimiter]; return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormLineDelimiter, kAFMultipartFormBoundary, kAFMultipartFormLineDelimiter];
} }
@ -424,7 +428,11 @@ static inline NSString * AFMultipartFormFinalBoundary() {
#pragma mark - AFMultipartFormData #pragma mark - AFMultipartFormData
- (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body { - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body {
if ([self.mutableData length] == 0) {
[self appendString:AFMultipartFormInitialBoundary()];
} else {
[self appendString:AFMultipartFormEncapsulationBoundary()]; [self appendString:AFMultipartFormEncapsulationBoundary()];
}
for (NSString *field in [headers allKeys]) { for (NSString *field in [headers allKeys]) {
[self appendString:[NSString stringWithFormat:@"%@: %@%@", field, [headers valueForKey:field], kAFMultipartFormLineDelimiter]]; [self appendString:[NSString stringWithFormat:@"%@: %@%@", field, [headers valueForKey:field], kAFMultipartFormLineDelimiter]];