I am trying to debug small HTTP client checking for its headers . It Is hard for me to check the header of HTTP ,is there any eclipse plugin available for monitoring HTTP client (HTTP headers)
Check if this helps
public class GetHttpHeaders {
public static void main(String[] args) throws IOException {
try {
URL url = new URL("http://localhost:8080");
URLConnection conn = url.openConnection();
for (int i = 0;; i++) {
String name = conn.getHeaderFieldKey(i);
String value = conn.getHeaderField(i);
if (name == null && value == null) {
break;
}
if (name == null) {
System.out
.println("Server HTTP version, Response code:");
System.out.println(value);
System.out.print("\n");
} else {
System.out.println(name + "=" + value);
}
}
} catch (Exception e) {
}
}
}
Try the blow link. There is a tool in eclipse name TCP/IP monitor
.It provides a console. All you have to add is you server port lets assume localhost:8080
and a monitoring port 8081
(according to reference )
then when you will call on http://localhost:8081/your_servlet_or_page/...
the call will be redirect to http://localhost:8080/your_servlet_or_page/...
and you will be able to see headers in console TCP/IP monitor console
reference # http://www.avajava.com/tutorials/lessons/how-do-i-monitor-http-communication-in-eclipse.html http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.wsi.ui.doc.user%2Ftasks%2Ftmonitor.html
The above reference is tested by me..it is working fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.