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
Content-Length: 50
Connection: close
Content-Type: text/html;charset=utf-8

<p>Hello world!</p>

Now I can run my test server as:

\herong>java SocketRequestResponseServer http_1_0_server.res
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 /
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

 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 Message Exchange Patterns

 SOAP HTTP Binding

 SOAP Perl Implementations

 SOAP PHP Implementations

 SOAP Java Implementations

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

 Perl Socket Test Program for HTTP and SOAP

 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

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

Java Socket and HttpURLConnection for SOAP - Socket Client Testing Program - Socket Server Testing Program

Capturing the HTTP Request from a Browser

 "read(byteBuf) = -1" Not Working

 Using to Send SOAP Messages

 Using HttpURLConnection to Call GetSpeech SOAP 1.1

 Capturing HTTP Request Generated by the HttpURLConnection Class

 Calling GetSpeech SOAP 1.1 Web Service

 Using HttpURLConnection to Call GetSpeech SOAP 1.2

 Calling GetSpeech 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

 Web Services and SOAP Terminology


 PDF Printing Version