Skip to content

Commit 59039d6

Browse files
committed
Re-ordering AFHTTPClient multipart proxy methods
1 parent e8d55c8 commit 59039d6

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

AFNetworking/AFHTTPClient.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,21 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
574574
mimeType:(NSString *)mimeType
575575
error:(NSError * __autoreleasing *)error;
576576

577+
/**
578+
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
579+
580+
@param inputStream The input stream to be appended to the form data
581+
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
582+
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
583+
@param length The length of the specified input stream in bytes.
584+
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
585+
*/
586+
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
587+
name:(NSString *)name
588+
fileName:(NSString *)fileName
589+
length:(unsigned long long)length
590+
mimeType:(NSString *)mimeType;
591+
577592
/**
578593
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
579594
@@ -607,21 +622,6 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
607622
- (void)appendPartWithHeaders:(NSDictionary *)headers
608623
body:(NSData *)body;
609624

610-
/**
611-
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
612-
613-
@param inputStream The input stream to be appended to the form data
614-
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
615-
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
616-
@param length The length of the specified input stream in bytes.
617-
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
618-
*/
619-
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
620-
name:(NSString *)name
621-
fileName:(NSString *)fileName
622-
length:(unsigned long long)length
623-
mimeType:(NSString *)mimeType;
624-
625625
/**
626626
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
627627

AFNetworking/AFHTTPClient.m

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,32 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
873873
return YES;
874874
}
875875

876+
877+
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
878+
name:(NSString *)name
879+
fileName:(NSString *)fileName
880+
length:(unsigned long long)length
881+
mimeType:(NSString *)mimeType
882+
{
883+
NSParameterAssert(name);
884+
NSParameterAssert(fileName);
885+
NSParameterAssert(mimeType);
886+
887+
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
888+
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
889+
[mutableHeaders setValue:mimeType forKey:@"Content-Type"];
890+
891+
892+
AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
893+
bodyPart.stringEncoding = self.stringEncoding;
894+
bodyPart.headers = mutableHeaders;
895+
bodyPart.body = inputStream;
896+
897+
bodyPart.bodyContentLength = length;
898+
899+
[self.bodyStream appendHTTPBodyPart:bodyPart];
900+
}
901+
876902
- (void)appendPartWithFileData:(NSData *)data
877903
name:(NSString *)name
878904
fileName:(NSString *)fileName
@@ -914,31 +940,6 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers
914940
[self.bodyStream appendHTTPBodyPart:bodyPart];
915941
}
916942

917-
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
918-
name:(NSString *)name
919-
fileName:(NSString *)fileName
920-
length:(unsigned long long)length
921-
mimeType:(NSString *)mimeType
922-
{
923-
NSParameterAssert(name);
924-
NSParameterAssert(fileName);
925-
NSParameterAssert(mimeType);
926-
927-
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
928-
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
929-
[mutableHeaders setValue:mimeType forKey:@"Content-Type"];
930-
931-
932-
AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
933-
bodyPart.stringEncoding = self.stringEncoding;
934-
bodyPart.headers = mutableHeaders;
935-
bodyPart.body = inputStream;
936-
937-
bodyPart.bodyContentLength = length;
938-
939-
[self.bodyStream appendHTTPBodyPart:bodyPart];
940-
}
941-
942943
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
943944
delay:(NSTimeInterval)delay
944945
{

0 commit comments

Comments
 (0)