[patch] support for the system http proxy

  1 post   Feedicon  
Replies: 0 - Last Post: October 16, 2009 03:10
by: ceager
showing 1 - 1 of 1
 
Posted: October 16, 2009 03:10 by ceager
HTTP Client hangs if you need to access the internet through a proxy. This patches the app to use the system proxy.


Index: src/HTTPServiceCFNetworkImpl.m
===================================================================
--- src/HTTPServiceCFNetworkImpl.m (revision 70)
+++ src/HTTPServiceCFNetworkImpl.m (working copy)
@@ -6,6 +6,7 @@
//

#import "HTTPServiceCFNetworkImpl.h"
+#import <SystemConfiguration/SystemConfiguration.h>

#define BUFSIZE 1024

@@ -91,7 +92,7 @@
if (!rawResponse.length) {
NSString *s = @"(( Zero-length response returned from server. ))";
[command setObject:s forKey:@"rawResponse"];
- NSLog(s);
+ NSLog(@"%@", s);
[self failure:s];
} else {
[command setObject:rawResponse forKey:@"rawResponse"];
@@ -108,7 +109,7 @@
CFHTTPMessageRef response = NULL;
CFHTTPAuthenticationRef auth = NULL;
NSInteger count = 0;
-
+
while (1) {
// send request
response = [self copyResponseBySendingHTTPRequest:request followRedirects:followRedirects];
@@ -254,6 +255,17 @@
}
}

+ /*
+ * When it's OK to drop support for 10.5, SystemConfiguration.framework may be removed,
+ * and the call to SCDynamicStoreCopyProxies() call may be replaced with the following line:
+ * NSDictionary *proxyDict = [(NSDictionary *) CFNetworkCopySystemProxySettings() autorelease];
+ */
+ NSDictionary *proxyDict = [(NSDictionary *) SCDynamicStoreCopyProxies(NULL) autorelease];
+
+ if (proxyDict) {
+ CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPProxy, proxyDict);
+ }
+
CFReadStreamOpen(stream);

BOOL done = NO;
Index: HTTPClient.xcodeproj/project.pbxproj
===================================================================
--- HTTPClient.xcodeproj/project.pbxproj (revision 70)
+++ HTTPClient.xcodeproj/project.pbxproj (working copy)
@@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
+ 0FCF598810880AEC00F754BE /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0FCF598710880AEC00F754BE /* SystemConfiguration.framework */; };
1DDD582C0DA1D0D100B32029 /* HCDocumentWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58280DA1D0D100B32029 /* HCDocumentWindow.xib */; };
1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; };
8D15AC2C0486D014006FF6A4 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 2A37F4B9FDCFA73011CA2CEA /* Credits.rtf */; };
@@ -58,6 +59,7 @@

/* Begin PBXFileReference section */
089C1660FE840EACC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 0FCF598710880AEC00F754BE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
13E42FBA07B3F13500E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
1DDD58290DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/HCDocumentWindow.xib; sourceTree = "<group>"; };
@@ -116,6 +118,7 @@
D357D5630EE63376009D62AE /* Security.framework in Frameworks */,
D385FFA80F0615EB00DB2946 /* TDParseKit.framework in Frameworks */,
D30DDFAA0F3E92BD00274E93 /* Sparkle.framework in Frameworks */,
+ 0FCF598810880AEC00F754BE /* SystemConfiguration.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -139,6 +142,7 @@
2A37F4C4FDCFA73011CA2CEA /* AppKit.framework */,
13E42FBA07B3F13500E4EEF1 /* CoreData.framework */,
2A37F4C5FDCFA73011CA2CEA /* Foundation.framework */,
+ 0FCF598710880AEC00F754BE /* SystemConfiguration.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
Replies: 0 - Last Post: October 16, 2009 03:10
by: ceager
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120127.ac94057)
 
 
Close
loading
Please Confirm
Close