Viewing Response Header Lines

This section describes how to view HTTP response header lines with a Web browser or with a Java program.

When the client program receives the HTTP response, it will look at the header lines first. Based on information contained in header lines, the client program will decide what to do with the actual response data in the entity body.

If you use a Web browser as a HTTP client program, it will process the data in the entity body differently depending on mainly the "Content-Type" entity header line: displaying the data as it is, rendering the data as a HTML document and displaying the resulting information, or passing the data to other registered programs to handle it.

Once the Web browser finishes processing the entity body, you can get some limited information from the header lines. For example, you can click the right mouse button and select the properties command on Internet Explorer, it will display some general properties about this response in a pop up window. The properties displayed are not always identical to the response header lines. The "Modified" property is probably identical to the "Last-Modified" entity header line. The "Type" property is sometime related to the "Content-Type" entity header line, and sometimes related to server side resource that generated the response.

How to view all the header lines received in the HTTP response? I couldn't find any existing tools to do this. So I wrote the following program to dump the entire response including all header lines received from a Web server:

 * Copyright (c) 2002 by Dr. Herong Yang. All rights reserved.
public class HttpRequestGet {
   public static void main(String[] args) {
      String path = "/index.html";
      int port = 80;
      String host = "localhost";
      if (args.length > 0) path = args[0];
      if (args.length > 1) port
         = Integer.valueOf(args[1]).intValue();
      if (args.length > 2) host = args[2];
      String result = "";
      try {
         Socket c = new Socket(host,port);
         BufferedWriter w = new BufferedWriter(new OutputStreamWriter(
         BufferedReader r = new BufferedReader(new InputStreamReader(
         String m = "GET "+ path + " HTTP/1.0";
         while ((m=r.readLine())!= null) {
      } catch (IOException e) {

Last update: 2002.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

 scrrun.dll - Scripting Runtime DLL

Managing Response Header Lines

 HTTP Response Syntax

 HTTP Response Header Lines

 Controlling Response Header Lines

Viewing Response Header Lines

 Response Header Lines for Static Files

 Controlling Response Header Line Example

 Sending Binary Files to Browsers

 Sending Files as Downloads

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

 Guest Book Application Example


 PDF Printing Version