SOAP Web Service Tutorials - Herong's Tutorial Examples - Version 5.10, 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 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:
C:\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 Chrome 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 /0:0:0:0:0:0:0:1 Request length: 393 Response length: 179
In the server recording file, server.req, I got:
C:\herong>more server.req GET /anything HTTP/1.1 Host: localhost:8888 Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTMLlike Gecko) Chrome/69.0.3497.81 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, imagepng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9
Very nice. I can capture what my browser is sending now!
Last update: 2018.
Table of Contents