Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charset not useful when Content-Type is multipart/form-data #374

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions ASIHTTPRequest.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Pod::Spec.new do |s|
s.name = 'ASIHTTPRequest'
s.version = '1.8.2'
s.summary = 'Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone.'
s.homepage = 'http://allseeing-i.com/ASIHTTPRequest'
s.author = { 'Ben Copsey' => '[email protected]' }
s.license = 'New BSD License'
s.source = { :git => 'https://github.com/hhuai/asi-http-request.git', :tag => s.version }

s.description = %{
ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that
makes some of the more tedious aspects of communicating with web servers
easier. It is written in Objective-C and works in both Mac OS X and iPhone
applications.

It is suitable performing basic HTTP requests and interacting with
REST-based services (GET / POST / PUT / DELETE). The included
ASIFormDataRequest subclass makes it easy to submit POST data and files
using multipart/form-data.
}

s.source_files = 'Classes'

s.ios.dependency 'Reachability' #, '~> 2.0', '>= 2.0.4'
s.ios.frameworks = 'MobileCoreServices', 'CFNetwork', 'CoreGraphics'

s.osx.exclude_files = '**/*ASIAuthenticationDialog*'
s.osx.frameworks = 'SystemConfiguration', 'CoreServices'

s.library = 'z.1'

s.subspec 'ASIWebPageRequest' do |ws|
ws.source_files = 'Classes/ASIWebPageRequest/'
ws.library = 'xml2.2'
ws.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
end

s.subspec 'CloudFiles' do |cfs|
cfs.source_files = 'Classes/CloudFiles/'
end

s.subspec 'S3' do |s3s|
s3s.source_files = 'Classes/S3/'
end
end
6 changes: 2 additions & 4 deletions Classes/ASIFormDataRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,14 @@ - (void)buildMultipartFormDataPostBody
#if DEBUG_FORM_DATA_REQUEST
[self addToDebugBody:@"\r\n==== Building a multipart/form-data body ====\r\n"];
#endif

NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));


// We don't bother to check if post data contains the boundary, since it's pretty unlikely that it does.
CFUUIDRef uuid = CFUUIDCreate(nil);
NSString *uuidString = [(NSString*)CFUUIDCreateString(nil, uuid) autorelease];
CFRelease(uuid);
NSString *stringBoundary = [NSString stringWithFormat:@"0xKhTmLbOuNdArY-%@",uuidString];

[self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, stringBoundary]];
[self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary]];

[self appendPostString:[NSString stringWithFormat:@"--%@\r\n",stringBoundary]];

Expand Down