【发布时间】:2014-01-23 05:42:25
【问题描述】:
我有一个 Android 客户端向服务器发出 HTTPS 请求。防火墙日志包含不需要的 CONNECT 请求方法条目。
何时会发出 CONNECT 请求,如何防止它被发送?我希望只有一个 GET 请求。我的理解是,对 openConnection() 的调用实际上并没有发出请求,GET 请求会继续调用 getResponseMessage()。
如何禁止 http 客户端尝试建立代理隧道?
以下是我发送连接和拨打电话的方式:
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();
编辑:
这是我试图阻止的防火墙日志条目:
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
由于“代理连接”标头,我认为这是与代理相关的
【问题讨论】:
标签: java android httpurlconnection