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

Update ASIHTTPRequest.m #376

Open
wants to merge 5 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.
Jump to
Jump to file
Failed to load files.
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.1'
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' => 'ben@allseeing-i.com' }
s.license = 'New BSD License'
s.source = { :git => 'https://github.com/hs1512/ASIHTTPRequest', :tag => 'v1.8.1' }

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
33 changes: 18 additions & 15 deletions Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Portions are based on the ImageClient example from Apple:
// See: http://developer.apple.com/samplecode/ImageClient/listing37.html

#import "ASIHTTPRequest.h"
#import "ASIHTTPRequest.h"if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) {

#if TARGET_OS_IPHONE
#import "Reachability.h"
Expand Down Expand Up @@ -3458,22 +3458,25 @@ - (void)handleStreamComplete

} else {

//Remove any file at the destination path
NSError *moveError = nil;
if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) {
fileError = moveError;

}

//Move the temporary file to the destination path
if (!fileError) {
[[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError];
if (moveError) {
fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]];
//James Jeong edited.
if (![[self temporaryFileDownloadPath] isEqualToString:[self downloadDestinationPath]]) {
//Remove any file at the destination path
NSError *moveError = nil;
if (![[self class] removeFileAtPath:[self downloadDestinationPath] error:&moveError]) {
fileError = moveError;

}

//Move the temporary file to the destination path
if (!fileError) {
[[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError];
if (moveError) {
fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]];
}
//[self setTemporaryFileDownloadPath:nil];
}
[self setTemporaryFileDownloadPath:nil];
}

[self setTemporaryFileDownloadPath:nil];
}
}

Expand Down