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

 About This Book

 Introduction to Web Service

 Introduction to SOAP (Simple Object Access Protocol)

 SOAP Message Structure

 SOAP Message Transmission and Processing

 SOAP Data Model

 SOAP Encoding

 SOAP RPC Presentation

 SOAP Properties Model

 SOAP MEP (Message Exchange Patterns)

 SOAP HTTP Binding

 SOAP PHP Implementations

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

 PHP SOAP Web Service Example - getTemp

 SOAP Perl Implementations

 Perl SOAP::Lite - SOAP Server-Client Communication Module

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

 Perl SOAP::Lite for SOAP 1.2 Web Services

 Perl SOAP::Lite for WSDL

 SOAP Java Implementations

Java Socket and HttpURLConnection for SOAP

 SocketRequestResponse.java - Socket Client Testing Program

 SocketRequestResponseServer.java - Socket Server Testing Program

Capturing the HTTP Request from a Browser

 "read(byteBuf) = -1" Not Working

 Using java.net.HttpURLConnection to Send SOAP Messages

 Using HttpURLConnection to Call SOAP 1.1

 Capturing HTTP Request Generated by the HttpURLConnection Class

 Calling NumberToWords SOAP 1.1 Web Service

 Using HttpURLConnection to Call SOAP 1.2

 Calling NumberToWords SOAP 1.2 Web Service

 SAAJ - SOAP with Attachments API for Java

 SoapUI - SOAP Web Service Testing Tool

 WS-Security - SOAP Message Security Extension

 WS-Security X.509 Certificate Token

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

 Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Perl SOAP::Lite 0.710 for WSDL

 Web Services and SOAP Terminology

 Outdated Tutorials

 References

 Full Version in PDF/EPUB