[英]How to inspect the HTTP request headers sent through a HttpsURLConnection?
The simple Java code below works. 下面的简单Java代码有效。 Is there an easy way to find out / inspect the HTTP request (not the response) headers actually sent?
有没有一种简单的方法来查找/检查实际发送的HTTP 请求 (不是响应)标头?
import java.net.URL;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
public class Test {
public static void main(String[] args) throws Exception {
String httpsURL = "https://api.gdax.com/products/BTC-USD/book?level=1";
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection) myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
}
}
I think you can not do it programaticaly, you could use some kind of proxy like TCP/IP monitor in Eclipse. 我认为您不能以编程方式做到这一点,可以在Eclipse中使用某种代理,例如TCP / IP监视器。 Or enable the debbug option for java adding these options:
或为java启用debbug选项,并添加以下选项:
-Djava.util.logging.config.file=logging.properties
And put in logging.properties (by default in JRE_HOME\\lib) the following property 并将以下属性放入logging.properties(默认情况下在JRE_HOME \\ lib中)
sun.net.www.protocol.http.HttpsURLConnection.level = ALL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.