Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Created October 16, 2017 13:26
Show Gist options
  • Save salrashid123/a851388e1af99349c7269fada18f0ca5 to your computer and use it in GitHub Desktop.
Save salrashid123/a851388e1af99349c7269fada18f0ca5 to your computer and use it in GitHub Desktop.
proxy-ApacheTransport
JacksonFactory jsonFactory = new JacksonFactory();
HttpHost proxy = new HttpHost("127.0.0.1",3128);
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
httpClient.addRequestInterceptor(new HttpRequestInterceptor(){
@Override
public void process(org.apache.http.HttpRequest request, HttpContext context) throws HttpException, IOException {
if (request.getRequestLine().getMethod().equals("CONNECT"))
request.addHeader(new BasicHeader("Proxy-Authorization","Basic dXNlcjE6dXNlcjE="));
}
});
mHttpTransport = new ApacheHttpTransport(httpClient);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment