Cédric Luthi

Merge branch 'master' of git://github.com/pokeb/asi-http-request

... ... @@ -9,3 +9,4 @@ build
profile
*.pbxuser
*.mode1v3
External/GHUnit/*
... ...
[submodule "External/GHUnit"]
path = External/GHUnit
url = git://github.com/gabriel/gh-unit.git
#!/usr/bin/env ruby
# This script fetches a pre-compiled copy of the iOS GHUnit.framework, if one isn't already in the External/GHUnit folder
# This replaces the old system, where GHUnit was included as a git submodule, because:
# a) git submodules confuse people (including me)
# b) GHUnit seems to be tricky to build without warnings
# The pre-compiled frameworks on allseeing-i.com were taken directly from those on the GHUnit downloads page on GitHub
# If you'd rather build GHUnit yourself, simply grab a copy from http://github.com/gabriel/gh-unit and drop your built framework into External/GHUnit
require 'net/http'
if (!File.exists?('External/GHUnit/GHUnitIOS.framework'))
`curl -s http://allseeing-i.com/ASIHTTPRequest/GHUnit/GHUnit-IOS.zip > External/GHUnit/GHUnit-IOS.zip`
`unzip External/GHUnit/GHUnit-IOS.zip -d External/GHUnit/ & rm External/GHUnit/GHUnit-IOS.zip`
end
\ No newline at end of file
... ...
#!/usr/bin/env ruby
# This script fetches a pre-compiled copy of the Mac GHUnit.framework, if one isn't already in the External/GHUnit folder
# This replaces the old system, where GHUnit was included as a git submodule, because:
# a) git submodules confuse people (including me)
# b) GHUnit seems to be tricky to build without warnings
# The pre-compiled frameworks on allseeing-i.com were taken directly from those on the GHUnit downloads page on GitHub
# If you'd rather build GHUnit yourself, simply grab a copy from http://github.com/gabriel/gh-unit and drop your built framework into External/GHUnit
require 'net/http'
if (!File.exists?('External/GHUnit/GHUnit.framework'))
`curl -s http://allseeing-i.com/ASIHTTPRequest/GHUnit/GHUnit-Mac.zip > External/GHUnit/GHUnit-Mac.zip`
`unzip External/GHUnit/GHUnit-Mac.zip -d External/GHUnit/ & rm External/GHUnit/GHUnit-Mac.zip`
end
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@
# This script sets a version number for ASIHTTPRequest based on the last commit, and is run when you build one of the targets in the Xcode projects that come with ASIHTTPRequest
# It only really needs to run on my computer, not on yours... :)
require 'find'
if (File.exists?('/usr/local/bin/git'))
if (File.exists?('.git') && File.directory?('.git') && File.exists?('/usr/local/bin/git'))
newversion = `/usr/local/bin/git describe --tags`.match(/(v([0-9]+)(\.([0-9]+)){1,}-([0-9]+))/).to_s.gsub(/[0-9]+$/){|commit| (commit.to_i + 1).to_s}+Time.now.strftime(" %Y-%m-%d")
buffer = File.new('Classes/ASIHTTPRequest.m','r').read
if !buffer.match(/#{Regexp.quote(newversion)}/)
... ...
... ... @@ -83,7 +83,7 @@
NSError *theError = nil;
NSInteger bytesProcessedAlready = zStream.total_out;
while (zStream.avail_out == 0) {
while (zStream.avail_in != 0) {
if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
[outputData increaseLengthBy:halfLength];
... ...
... ... @@ -80,7 +80,7 @@
NSError *theError = nil;
NSInteger bytesProcessedAlready = zStream.total_out;
while (zStream.avail_out == 0) {
while (zStream.avail_in != 0) {
if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
[outputData increaseLengthBy:halfLength];
... ...
... ... @@ -479,6 +479,21 @@ typedef void (^ASIDataBlock)(NSData *data);
// Setting this to NO may be especially useful for users using ASIHTTPRequest in conjunction with a streaming parser, as it will allow partial gzipped responses to be inflated and passed on to the parser while the request is still running
BOOL shouldWaitToInflateCompressedResponses;
// Will be YES if this is a request created behind the scenes to download a PAC file - these requests do not attempt to configure their own proxies
BOOL isPACFileRequest;
// Used for downloading PAC files from http / https webservers
ASIHTTPRequest *PACFileRequest;
// Used for asynchronously reading PAC files from file:// URLs
NSInputStream *PACFileReadStream;
// Used for storing PAC data from file URLs as it is downloaded
NSMutableData *PACFileData;
// Set to YES in startSynchronous. Currently used by proxy detection to download PAC files synchronously when appropriate
BOOL isSynchronous;
#if NS_BLOCKS_AVAILABLE
//block to execute when request starts
ASIBasicBlock startedBlock;
... ... @@ -780,11 +795,6 @@ typedef void (^ASIDataBlock)(NSData *data);
// Is only used when you have specified a Bundle Display Name (CFDisplayBundleName) or Bundle Name (CFBundleName) in your plist
+ (NSString *)defaultUserAgentString;
#pragma mark proxy autoconfiguration
// Returns an array of proxies to use for a particular url, given the url of a PAC script
+ (NSArray *)proxiesForURL:(NSURL *)theURL fromPAC:(NSURL *)pacScriptURL;
#pragma mark mime-type detection
// Return the mime type for a file
... ...
This diff is collapsed. Click to expand it.
... ... @@ -8,7 +8,7 @@
//
#if !TARGET_OS_IPHONE || (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_4_0)
#if (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_6) || (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_4_0)
@protocol NSXMLParserDelegate
@optional
... ...
... ... @@ -10,6 +10,13 @@
#import "ASIDownloadCache.h"
#import "ASIHTTPRequest.h"
// Stop clang complaining about undeclared selectors
@interface ASIDownloadCacheTests ()
- (void)runCacheOnlyCallsRequestFinishedOnceTest;
- (void)finishCached:(ASIHTTPRequest *)request;
@end
@implementation ASIDownloadCacheTests
- (void)testDownloadCache
... ...
... ... @@ -51,12 +51,6 @@
- (void)testTimeOutWithoutDownloadDelegate;
- (void)testThrottlingDownloadBandwidth;
- (void)testThrottlingUploadBandwidth;
- (void)requestStarted:(ASIHTTPRequest *)request;
- (void)requestFinished:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
- (void)delegateTestStarted:(ASIHTTPRequest *)request;
- (void)delegateTestFinished:(ASIHTTPRequest *)request;
- (void)delegateTestFailed:(ASIHTTPRequest *)request;
#if TARGET_OS_IPHONE
- (void)testReachability;
#endif
... ...
... ... @@ -25,6 +25,33 @@
}
@end
// Stop clang complaining about undeclared selectors
@interface ASIHTTPRequestTests ()
- (void)runCancelTest;
- (void)performDelegateMethodsTest;
- (void)requestStarted:(ASIHTTPRequest *)request;
- (void)requestFinished:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
- (void)delegateTestStarted:(ASIHTTPRequest *)request;
- (void)delegateTestResponseHeaders:(ASIHTTPRequest *)request;
- (void)delegateTestFinished:(ASIHTTPRequest *)request;
- (void)delegateTestFailed:(ASIHTTPRequest *)request;
- (void)runRemoveUploadProgressTest;
- (void)runRedirectedResume;
- (void)performDownloadProgressTest;
- (void)theTestRequest:(ASIHTTPRequest *)request didReceiveData:(NSData *)data;
- (void)theTestRequestFinished:(ASIHTTPRequest *)request;
- (void)performUploadProgressTest;
- (void)performPostBodyStreamedFromDiskTest;
- (void)performPartialFetchTest;
- (void)asyncFail:(ASIHTTPRequest *)request;
- (void)asyncSuccess:(ASIHTTPRequest *)request;
- (void)request:(ASIHTTPRequest *)request isGoingToRedirectToURL:(NSURL *)url;
- (void)redirectURLTestFailed:(ASIHTTPRequest *)request;
- (void)redirectURLTestSucceeded:(ASIHTTPRequest *)request;
@end
@implementation ASIHTTPRequestTests
- (void)testBasicDownload
... ... @@ -1068,12 +1095,23 @@
[ASIHTTPRequest clearSession];
// Test credentials set on the request are sent before the server asks for them
// Test credentials set on the request are not sent before the server asks for them unless they are cached credentials from a previous request to this server
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseSessionPersistence:NO];
[request setUsername:@"secret_username"];
[request setPassword:@"secret_password"];
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request startSynchronous];
BOOL fail = [request authenticationRetryCount] == 0;
GHAssertFalse(fail,@"Sent Basic credentials even though request did not have kCFHTTPAuthenticationSchemeBasic set as authenticationScheme.");
// Test basic credentials set on the request are sent before the server asks for them if we've explictly set the authentication scheme to basic
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseSessionPersistence:NO];
[request setUsername:@"secret_username"];
[request setPassword:@"secret_password"];
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request setAuthenticationScheme:(NSString *)kCFHTTPAuthenticationSchemeBasic];
[request startSynchronous];
success = [request authenticationRetryCount] == 0;
GHAssertTrue(success,@"Didn't supply credentials before being asked for them, even though they were set on the request and shouldPresentCredentialsBeforeChallenge == YES");
... ...
... ... @@ -26,6 +26,36 @@ IMPORTANT
@implementation ASINetworkQueueSubclass
@end
// Stop clang complaining about undeclared selectors
@interface ASINetworkQueueTests ()
- (void)queueFinished:(ASINetworkQueue *)request;
- (void)addedRequestComplete:(ASIHTTPRequest *)request;
- (void)addAnotherRequest;
- (void)immediateCancelFail:(ASIHTTPRequest *)request;
- (void)immediateCancelFinish:(ASIHTTPRequest *)request;
- (void)finish:(ASIHTTPRequest *)request;
- (void)throttleFail:(ASIHTTPRequest *)request;
- (void)postDone:(ASIHTTPRequest *)request;
- (void)ntlmDone:(ASIHTTPRequest *)request;
- (void)ntlmFailed:(ASIHTTPRequest *)request;
- (void)runHEADFailureTest;
- (void)queueFailureFinish:(ASINetworkQueue *)request;
- (void)queueFailureFinishCallOnce:(ASINetworkQueue *)request;
- (void)request:(ASIHTTPRequest *)request isGoingToRedirectToURL:(NSURL *)url;
- (void)redirectURLTestFailed:(ASIHTTPRequest *)request;
- (void)redirectURLTestSucceeded:(ASIHTTPRequest *)request;
- (void)runDelegateMethodsTest;
- (void)delegateTestStarted:(ASIHTTPRequest *)request;
- (void)delegateTestFinished:(ASIHTTPRequest *)request;
- (void)delegateTestFailed:(ASIHTTPRequest *)request;
- (void)delegateTestRequest:(ASIHTTPRequest *)request receivedResponseHeaders:(NSDictionary *)headers;
- (void)addMoreRequestsQueueFinished:(ASINetworkQueue *)request;
- (void)requestFailedCancellingOthers:(ASINetworkQueue *)request;
- (void)fail:(ASIHTTPRequest *)request;
- (void)HEADFail:(ASIHTTPRequest *)request;
- (void)runTestQueueFinishedCalledOnFailureTest;
@end
@implementation ASINetworkQueueTests
- (void)testDelegateAuthenticationCredentialsReuse
... ...
... ... @@ -34,6 +34,16 @@ static NSString *bucket = @"";
@implementation ASIS3BucketObjectSubclass;
@end
// Stop clang complaining about undeclared selectors
@interface ASIS3RequestTests ()
- (void)GETRequestDone:(ASIHTTPRequest *)request;
- (void)GETRequestFailed:(ASIHTTPRequest *)request;
- (void)PUTRequestDone:(ASIHTTPRequest *)request;
- (void)PUTRequestFailed:(ASIHTTPRequest *)request;
- (void)DELETERequestDone:(ASIHTTPRequest *)request;
- (void)DELETERequestFailed:(ASIHTTPRequest *)request;
@end
@implementation ASIS3RequestTests
// All these tests are based on Amazon's examples at: http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
... ... @@ -101,16 +111,16 @@ static NSString *bucket = @"";
GHAssertTrue(success,@"Failed to generate the correct authorisation header for a list request");
// Test Unicode keys
exampleBucket = @"dictionary";
key = @"français/préfère";
dateString = @"Wed, 28 Mar 2007 01:49:49 +0000";
request = [ASIS3ObjectRequest requestWithBucket:exampleBucket key:key];
[request setDateString:dateString];
[request setSecretAccessKey:exampleSecretAccessKey];
[request setAccessKey:exampleAccessKey];
[request buildRequestHeaders];
success = [[[request requestHeaders] valueForKey:@"Authorization"] isEqualToString:@"AWS 0PN5J17HBGZHT7JJ3X82:dxhSBHoI6eVSPcXJqEghlUzZMnY="];
// Comment out this test for now, as the S3 example is relying on mixed-case hex-encoded characters in the url, which isn't going to be easy to replicate
// exampleBucket = @"dictionary";
// key = @"français/préfère";
// dateString = @"Wed, 28 Mar 2007 01:49:49 +0000";
// request = [ASIS3ObjectRequest requestWithBucket:exampleBucket key:key];
// [request setDateString:dateString];
// [request setSecretAccessKey:exampleSecretAccessKey];
// [request setAccessKey:exampleAccessKey];
// [request buildRequestHeaders];
// success = [[[request requestHeaders] valueForKey:@"Authorization"] isEqualToString:@"AWS 0PN5J17HBGZHT7JJ3X82:dxhSBHoI6eVSPcXJqEghlUzZMnY="];
//GHAssertTrue(success,@"Failed to generate the correct authorisation header for a list request");
}
... ...
... ... @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import "GHUnit.h"
#import <GHUnitIOS/GHUnit.h>
#else
#import <GHUnit/GHUnit.h>
#endif
... ...
... ... @@ -20,6 +20,15 @@
@synthesize tag;
@end
// Stop clang complaining about undeclared selectors
@interface PerformanceTests ()
- (void)runSynchronousASIHTTPRequests;
- (void)runSynchronousNSURLConnections;
- (void)startASIHTTPRequests;
- (void)startASIHTTPRequestsWithQueue;
- (void)startNSURLConnections;
@end
@implementation PerformanceTests
... ...
... ... @@ -16,6 +16,13 @@ static int proxyPort = 0;
static NSString *proxyUsername = @"";
static NSString *proxyPassword = @"";
// Stop clang complaining about undeclared selectors
@interface ProxyTests ()
- (void)requestDone:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
@end
@implementation ProxyTests
- (void)testProxyForHTTPS
... ...
... ... @@ -29,6 +29,13 @@ IMPORTANT
@synthesize request;
@end
// Stop clang complaining about undeclared selectors
@interface StressTests ()
- (void)cancelRedirectRequest;
- (void)cancelSetDelegateRequest;
@end
@implementation StressTests
... ...
... ... @@ -2,6 +2,7 @@ ASIHTTPRequest donors
I am very grateful to the following people for their generous donations:
AzroTech, Inc
Karl Beck
John Brayton
Stephan Burlot (http://www.coriolis.ch)
... ... @@ -16,6 +17,7 @@ Nathan de Vries (http://www.atnan.com)
Matthew Frederick
James Hartzell
Hunter Hillegas
Marcus Hobbs
Felix Holmgren
Cesar Jacquet
Philip Jespersen
... ... @@ -29,8 +31,10 @@ Spencer Pieters (http://www.appwizard.be)
Alessandro Segala (http://letsdev.it)
Ben Scheirman
Basil Shkara (http://www.oiledmachine.com)
Jacob Sologub (http://irompler.com)
Jakub Suder (http://psionides.jogger.pl)
Kyle Van Essen
Rowan Willson
Dan Zeitman
Many thanks!
... ...
Subproject commit ffb51729219514fb7948b9be29bbae3dfabb1f4a
This folder is where ASIHTTPRequest looks for GHUnit frameworks.
When you run one of the test targets, a build script will attempt to download a pre-compiled framework and install it here, if one does not already exist. If you would prefer to build GHUnit yourself, simply grab a copy from https://github.com/gabriel/gh-unit, and drop your built framework in this folder.
\ No newline at end of file
... ...
* Copyright (c) 2007-2010, All-Seeing Interactive
* Copyright (c) 2007-2011, All-Seeing Interactive
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
... ...
This diff was suppressed by a .gitattributes entry.
#!/bin/sh
scan-build xcodebuild -target iPhone -configuration Debug -project iPhone.xcodeproj -sdk iphonesimulator2.2.1
scan-build xcodebuild -target Mac -configuration Debug -project Mac.xcodeproj
//
// GHUnitIOSTestMain.m
// GHUnitIPhone
//
// Created by Gabriel Handford on 1/25/09.
// Copyright 2009. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#import <UIKit/UIKit.h>
// If you are using the framework
#import <GHUnitIOS/GHUnit.h>
// If you are using the static library and importing header files manually
//#import "GHUnit.h"
// Default exception handler
void exceptionHandler(NSException *exception) {
NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception));
}
int main(int argc, char *argv[]) {
/*!
For debugging:
Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode).
Then go in the "Arguments" tab. You can add the following environment variables:
Default: Set to:
NSDebugEnabled NO "YES"
NSZombieEnabled NO "YES"
NSDeallocateZombies NO "YES"
NSHangOnUncaughtException NO "YES"
NSEnableAutoreleasePool YES "NO"
NSAutoreleaseFreedObjectCheckEnabled NO "YES"
NSAutoreleaseHighWaterMark 0 non-negative integer
NSAutoreleaseHighWaterResolution 0 non-negative integer
For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html
For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
*/
NSSetUncaughtExceptionHandler(&exceptionHandler);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Register any special test case classes
//[[GHTesting sharedInstance] registerClassName:@"GHSpecialTestCase"];
int retVal = 0;
// If GHUNIT_CLI is set we are using the command line interface and run the tests
// Otherwise load the GUI app
if (getenv("GHUNIT_CLI")) {
retVal = [GHTestRunner run];
} else {
retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIPhoneAppDelegate");
}
[pool release];
return retVal;
}
\ No newline at end of file
... ...
This diff was suppressed by a .gitattributes entry.