SOAP Web Service Tutorials - Herong's Tutorial Examples - Version 5.02, by Dr. Herong Yang
Capturing the HTTP Request from a Browser
This section provides a tutorial example on how to capture the HTTP request generated from a Web browser like Firefox with the socket server test program.
To verify my my socket server side testing program, I need to prepare some response files.
My first response file, http_1_0_server.res, represents a simple HTTP 1.0 Web page response:
HTTP/1.0 200 OK Server: SocketHttpServer.java Content-Length: 50 Connection: close Content-Type: text/html;charset=utf-8 <html><body> <p>Hello world!</p> </body></html>
Now I can run my test server as:
\herong>java SocketRequestResponseServer http_1_0_server.res server.req Listening at 8888
With the server running and waiting for connection, I tested it with Firefox 3.0.16 with this URL: http://localhost:8888/anything. The browser gets the expected message: Hello world!
In the command window where the server is running, I got:
Connection received from /127.0.0.1 Request length: 401 Response length: 170
In the server recording file, server.req, I got:
GET /anything HTTP/1.1 Host: localhost:8888 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; ... Accept: text/html,application/xhtml+xml,application/xml;q=0.... Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive
Very nice. I can capture what my browser is sending now!
Last update: 2009.
Table of Contents