1

Hi I am working on a frame work. I am using NSURLProtocol to interceptor the request. In the request I am adding proxy with Username and password.

its perfectly working in the curl - curl proxy with username and paswword..

when I am changing the header in the request, In the response I am getting this error.

Request failed: unacceptable content-type: text/html"

code which I am using

-(void)startLoading {
        NSMutableURLRequest *newRequest = [self.request mutableCopy];
     NSURLSessionConfiguration* config = NSURLSessionConfiguration.defaultSessionConfiguration;
           // config.HTTPAdditionalHeaders = @{ @"Accept":@"application/json"};
            NSDictionary *proxyDict = [self getProxyDictionary];
            if (proxyDict.allKeys.count >= 1){
                config.connectionProxyDictionary = proxyDict;

     NSString *authorizationToken = ["username" stringByAppendingString:@":"] stringByAppendingString: "password"];
config.HTTPAdditionalHeaders = @{@"Accept": @"application/json",@"Proxy-Authorization":authorizationToken};
            }
    }

If I run in the webview, I am getting this error

TypeError: must start with number, buffer, array or string
 
 at fromObject (buffer.js:138:11)
   at new Buffer (buffer.js:65:10)
   at module.exports (/apps/infinity/freeg-proxy/trans-proxy/app/http/authenticator.js:12:19)
   at call (/apps/infinity/freeg-proxy/trans-proxy/node_modules/connect/index.js:239:7)
   at next (/apps/infinity/freeg-proxy/trans-proxy/node_modules/connect/index.js:183:5)
   at Function.handle (/apps/infinity/freeg-proxy/trans-proxy/node_modules/connect/index.js:186:3)
   at Server.app (/apps/infinity/freeg-proxy/trans-proxy/node_modules/connect/index.js:51:37)
   at emitTwo (events.js:87:13)`enter code here`
   at Server.emit (events.js:172:7)
   at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:528:12)
   at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)

Can any one help for me.

Sapana Ranipa
  • 889
  • 7
  • 20
sunil
  • 70
  • 8

0 Answers0