2

I have an Android client making HTTPS request to a server. The firewall logs have entries for CONNECT request methods which are not desired.

When would the CONNECT request get sent out and how can I prevent it from being sent? I expect only a GET request. My understanding is that the call to openConnection() does not actually make a request and that the GET request would go on the call to getResponseMessage().

How can I disable the http client from attempting to establish a proxy tunnel?

Here is how I sent up my connection and make the call:

URL url = new URL("https://some.server.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(REAT_TIMEOUT);
connection.setRequestProperty(ACCEPT_CHARSET, UTF8_CHARSET);
connection.setRequestProperty(CONTENT_TYPE_HEADER, contentType);
setCustomRequestProperties(connection);
connection.setRequestMethod("GET");

//create response
connection.getResponseMessage();
connection.getResponseCode();
connection.getContentType();
connection.getContent();

EDIT:

Here is the Firewall Log entry that I am trying to prevent:

CONNECT someURL.domain.com:443 HTTP/1.1
Host: someURL.domain.com
User-Agent: CustomUserAgent;1.0.0(Android 4.3;Nexus 4;T-Mobile)
Proxy-Connection: Keep-Alive
X-SSL-Secure: true
X-CS-Source-IP: 10.3.3.3
X-Forwarded-For: 10.3.3.3

I thought this was proxy related because of the "Proxy-Connection" header

Daddyboy
  • 1,412
  • 13
  • 19

2 Answers2

2

The default for URLConnection is to pool the TCP (socket) connections. It seems that the "Proxy-Connection" header was misleading as that header can be misappropriated when "Connection" is really intended.

When I set the system property

System.setProperty("http.keepAlive", "false");

to disable the connection pool, the CONNECT method request entries went away.

There is a slight performance hit since Sockets need to be created for each request but the app does not make a significant number of requests so this is acceptable.

Daddyboy
  • 1,412
  • 13
  • 19
1

This only happens when you have an HTTP proxy configured. Possibly you have set the system properties http.proxyHost and http.proxyPort, or maybe Android has another way of configuring this.

user207421
  • 305,947
  • 44
  • 307
  • 483