Skip to content

Commit

Permalink
Added auto-detect for proxies - please let me know if you find problems!
Browse files Browse the repository at this point in the history
Tweaks to text in iPhone sample app
  • Loading branch information
pokeb committed Jun 25, 2009
1 parent 4d26738 commit bb72651
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 deletions.
11 changes: 11 additions & 0 deletions Classes/ASIHTTPRequest.m
Expand Up @@ -12,6 +12,9 @@

#import "ASIHTTPRequest.h"
#import <zlib.h>
#ifndef TARGET_OS_IPHONE
#import <SystemConfiguration/SystemConfiguration.h>
#endif

// We use our own custom run loop mode as CoreAnimation seems to want to hijack our threads otherwise
static CFStringRef ASIHTTPRequestRunMode = CFSTR("ASIHTTPRequest");
Expand Down Expand Up @@ -442,6 +445,14 @@ - (void)startRequest
CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, [NSMutableDictionary dictionaryWithObject:(NSString *)kCFBooleanFalse forKey:(NSString *)kCFStreamSSLValidatesCertificateChain]);
}

// Detect proxy settings and apply them
#if TARGET_OS_IPHONE
NSDictionary *proxySettings = [(NSDictionary *)CFNetworkCopySystemProxySettings() autorelease];
#else
NSDictionary *proxySettings = [(NSDictionary *)SCDynamicStoreCopyProxies(NULL) autorelease];
#endif
CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxySettings);

// Set the client
CFStreamClientContext ctxt = {0, self, NULL, NULL, NULL};
if (!CFReadStreamSetClient(readStream, kNetworkEvents, ReadStreamClientCallBack, &ctxt)) {
Expand Down
1 change: 0 additions & 1 deletion Classes/Tests/ASIHTTPRequestTests.m
Expand Up @@ -334,7 +334,6 @@ - (void)testCookies
if (!foundCookie) {
return;
}

// Test a cookie is presented when manually added to the request
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
Expand Down
1 change: 1 addition & 0 deletions Classes/Tests/ASINetworkQueueTests.m
Expand Up @@ -361,6 +361,7 @@ - (void)testWithNoListener
[networkQueue go];
[networkQueue waitUntilAllOperationsAreFinished];

// This test may fail if you are using a proxy and it returns a page when you try to connect to a bad port.
GHAssertTrue(!request_succeeded && request_didfail,@"Request to resource without listener succeeded but should have failed");

[networkQueue release];
Expand Down
6 changes: 6 additions & 0 deletions Mac.xcodeproj/project.pbxproj
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
B53FADE80FF38B2A002E2DE6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B53FADE70FF38B2A002E2DE6 /* SystemConfiguration.framework */; };
B53FADF90FF38BA9002E2DE6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B53FADE70FF38B2A002E2DE6 /* SystemConfiguration.framework */; };
B55B5D200F76568E0064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B5D120F76568E0064029C /* ASIFormDataRequest.m */; };
B55B5D210F76568E0064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B5D140F76568E0064029C /* ASIHTTPRequest.m */; };
B55B5D220F76568E0064029C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B5D160F76568E0064029C /* ASINetworkQueue.m */; };
Expand Down Expand Up @@ -48,6 +50,7 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
8D1107320486CEB800E47090 /* Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Mac.app; sourceTree = BUILT_PRODUCTS_DIR; };
B53FADE70FF38B2A002E2DE6 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
B55B5D110F76568E0064029C /* ASIFormDataRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequest.h; sourceTree = "<group>"; };
B55B5D120F76568E0064029C /* ASIFormDataRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIFormDataRequest.m; sourceTree = "<group>"; };
B55B5D130F76568E0064029C /* ASIHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequest.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -83,6 +86,7 @@
files = (
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
B55B5EB80F7658200064029C /* libz.1.2.3.dylib in Frameworks */,
B53FADF90FF38BA9002E2DE6 /* SystemConfiguration.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -92,6 +96,7 @@
files = (
B55B60140F7659A30064029C /* libz.1.2.3.dylib in Frameworks */,
B5B513680FBEE435002C74D0 /* GHUnit.framework in Frameworks */,
B53FADE80FF38B2A002E2DE6 /* SystemConfiguration.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -135,6 +140,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
B55B5EB70F7658200064029C /* libz.1.2.3.dylib */,
B53FADE70FF38B2A002E2DE6 /* SystemConfiguration.framework */,
);
name = Mac;
sourceTree = "<group>";
Expand Down
62 changes: 51 additions & 11 deletions iPhone Sample/XIBs/Queue.xib
Expand Up @@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">528</int>
<string key="IBDocument.SystemVersion">9G55</string>
<string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.43</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -59,6 +59,26 @@
<float key="IBUIMinimumFontSize">1.000000e+01</float>
<int key="IBUINumberOfLines">0</int>
</object>
<object class="IBUILabel" id="520895357">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{163, 272}, {143, 87}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="IBUIText">See the Mac sample app for a slightly more sophisticated example, with an addtional progress indicator for each request</string>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">1.200000e+01</double>
<int key="NSfFlags">16</int>
</object>
<reference key="IBUITextColor" ref="87390567"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">1.000000e+01</float>
<int key="IBUINumberOfLines">0</int>
</object>
<object class="IBUIButton" id="963091686">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
Expand Down Expand Up @@ -86,11 +106,15 @@
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
<object class="IBUIImageView" id="512691955">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 184}, {135, 87}}</string>
<string key="NSFrame">{{20, 177}, {135, 87}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
Expand All @@ -100,7 +124,7 @@
<object class="IBUIImageView" id="496427125">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 279}, {135, 87}}</string>
<string key="NSFrame">{{20, 272}, {135, 87}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
Expand All @@ -110,7 +134,7 @@
<object class="IBUIImageView" id="393184766">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{163, 184}, {137, 87}}</string>
<string key="NSFrame">{{163, 177}, {137, 87}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
Expand All @@ -120,7 +144,7 @@
<object class="IBUIProgressView" id="138477738">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 379}, {280, 9}}</string>
<string key="NSFrame">{{20, 367}, {280, 9}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
Expand Down Expand Up @@ -241,14 +265,15 @@
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="393184766"/>
<reference ref="512691955"/>
<reference ref="138477738"/>
<reference ref="496427125"/>
<reference ref="602749642"/>
<reference ref="365204290"/>
<reference ref="104706742"/>
<reference ref="963091686"/>
<reference ref="393184766"/>
<reference ref="520895357"/>
<reference ref="138477738"/>
</object>
<reference key="parent" ref="360949347"/>
</object>
Expand Down Expand Up @@ -303,6 +328,11 @@
<reference key="object" ref="365204290"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">24</int>
<reference key="object" ref="520895357"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -319,6 +349,7 @@
<string>14.IBPluginDependency</string>
<string>21.IBPluginDependency</string>
<string>22.IBPluginDependency</string>
<string>24.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
Expand All @@ -336,6 +367,7 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
Expand All @@ -358,11 +390,18 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">23</int>
<int key="maxID">24</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Frameworks/libGHUnitIPhone/GHUNSObject+Swizzle.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">QueueViewController</string>
<string key="superclassName">UIViewController</string>
Expand Down Expand Up @@ -391,13 +430,14 @@
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">QueueViewController.h</string>
<string key="minorKey">iPhone Sample/QueueViewController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">../asi-http-request.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../iPhone.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">3.0</string>
</data>
</archive>
9 changes: 5 additions & 4 deletions iPhone Sample/XIBs/UploadProgress.xib
Expand Up @@ -39,14 +39,15 @@
<object class="IBUILabel" id="652745716">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 20}, {280, 127}}</string>
<string key="NSFrame">{{20, 20}, {280, 144}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string type="base64-UTF8" key="IBUIText">RGVtb25zdHJhdGVzIFBPU1RpbmcgY29udGVudCB0byBhIFVSTCwgc2hvd2luZyB1cGxvYWQgcHJvZ3Jl
c3MuCgpZb3UnbGwgb25seSBzZWUgYWNjdXJhdGUgcHJvZ3Jlc3MgZm9yIHVwbG9hZHMgd2hlbiB0aGUg
cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCIChpbiAyLjIuMSBTREspA</string>
cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCIChpbiAyLjIuMSBTREspLCBvciB3aGVuIHRo
ZSByZXF1ZXN0IGJvZHkgaXMgbGFyZ2VyIHRoYW4gMzJLQiAoaW4gMy4wIFNESyk</string>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">1.400000e+01</double>
Expand All @@ -65,7 +66,7 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCIChpbiAyLjIuMSBTREspA</string>
<object class="IBUIButton" id="117120328">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 161}, {72, 37}}</string>
<string key="NSFrame">{{20, 186}, {72, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
Expand Down Expand Up @@ -97,7 +98,7 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCIChpbiAyLjIuMSBTREspA</string>
<object class="IBUIProgressView" id="975702463">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 215}, {280, 9}}</string>
<string key="NSFrame">{{20, 240}, {280, 9}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
Expand Down

1 comment on commit bb72651

@rbsgn
Copy link
Contributor

@rbsgn rbsgn commented on bb72651 Jun 29, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wheee! This is a nice stuff ;-)

Please sign in to comment.