@@ -23,10 +23,31 @@ - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)ur
2323 NSURL * url = urlSchemeTask.request .URL ;
2424 NSString * stringToLoad = url.path ;
2525 NSString * scheme = url.scheme ;
26+ NSString * method = urlSchemeTask.request .HTTPMethod ;
27+ NSData * data;
28+ NSInteger statusCode;
2629
2730 if ([scheme isEqualToString: self .scheme]) {
2831 if ([stringToLoad hasPrefix: @" /_app_file_" ]) {
2932 startPath = [stringToLoad stringByReplacingOccurrencesOfString: @" /_app_file_" withString: @" " ];
33+ } else if ([stringToLoad hasPrefix: @" /_http_proxy_" ]||[stringToLoad hasPrefix: @" /_https_proxy_" ]) {
34+ startPath = [stringToLoad stringByReplacingOccurrencesOfString: @" /_http_proxy_" withString: @" http://" ];
35+ startPath = [stringToLoad stringByReplacingOccurrencesOfString: @" /_https_proxy_" withString: @" https://" ];
36+ NSLog (@" Proxy %@ " , startPath);
37+ NSMutableURLRequest *request = [[NSMutableURLRequest alloc ] init ];
38+ [request setHTTPMethod: method];
39+ [request setURL: [NSURL URLWithString: startPath]];
40+ [request setAllHTTPHeaderFields: [NSHTTPCookie requestHeaderFieldsWithCookies: [NSHTTPCookieStorage sharedHTTPCookieStorage ].cookies]];
41+ [request HTTPShouldHandleCookies ];
42+
43+ NSError *error = nil ;
44+ NSHTTPURLResponse *responseCode = nil ;
45+
46+ data = [NSURLConnection sendSynchronousRequest: request returningResponse: &responseCode error: &error];
47+ statusCode = [responseCode statusCode ];
48+ if (!error) {
49+ NSLog (@" %@ " , error);
50+ }
3051 } else {
3152 startPath = self.basePath ;
3253 if ([stringToLoad isEqualToString: @" " ] || [url.pathExtension isEqualToString: @" " ]) {
@@ -37,8 +58,10 @@ - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)ur
3758 }
3859 }
3960
40- NSData * data = [[NSData alloc ] initWithContentsOfFile: startPath];
41- NSInteger statusCode = 200 ;
61+ if (!data) {
62+ data = [[NSData alloc ] initWithContentsOfFile: startPath];
63+ }
64+ statusCode = 200 ;
4265 if (!data) {
4366 statusCode = 404 ;
4467 }
0 commit comments