"Adrian Hjelmslund" <Ne**@hjelmslund.dk> wrote in message
news:tM******************@news.get2net.dk...
Why not write a simple socket server that will print everything it gets,
byte for byte, to System.out or a file? It takes maybe 30 lines of code.
I've probably got one lying around somewhere.
Oh, a misunderstanding here :o)
I'm generating the client request (I have no control over the header I
send though) and I need to see the header of my own request that I send to the
server. I have no access to the server unfortunately :-(
Best regards
Adrian
No, that's what I mean. Write a simple server, and tell your client to
connect to that server, and basically the server will just echo everything
it gets from the client so you can examine it. Something like:
import java.net.*;
import java.io.*;
public class EchoServer {
private int port = 8081;
public EchoServer() {
try {
ServerSocket serverSocket = new ServerSocket(port);
Socket client = serverSocket.accept();
InputStream in = client.getInputStream();
int data;
while ((data = in.read()) != -1) {
System.out.print((char) data);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("---------------- Done");
}
public static void main(String[] args) {
EchoServer es = new EchoServer();
}
}
Understand that I just jotted that down on the spot, no references or
anything, so I can guarantee it will work. It's the general idea though.
Then just run this, and take your client and point it at
http://localhost:8081 (If that port is taken, just change it in the
program.)