Chapter 16: The HyperText Transfer Protocol
Note: this page applies to the now-obsolete first edition of the book. For
the second edition, please see
http://www.corewebprogramming.com.
This chapter of
Core Web Programming (pages 866-911) covers HTTP. In addition to
an overview of the basic "conversation" between an HTTP client and
server, it gives details of legal request methods, the various request
headers, the response status line, and various response headers. Gives
particular details on cookies, plus presents an overview of public-key
cryptography (as used in SSL and elsewhere).
Contents
The .sh and .csh scripts are Unix-specific, and must
be set executable and placed in the CGI directory.
Reminder: On Windows 95/NT and Unix, click on the links with
the right mouse button to save the referenced file to a new location.
On any platform, you can also click on the links with the SHIFT key
held down. On Netscape, this lets you save the source for the
referenced file to a new location. In Internet Explorer, this puts the
referenced file in a separate browser window (without frames), where
you can then save it.
-
WebClient.java. This is a window that lets you type
HTTP requests and additional request headers, and then
displays the raw results (response headers and all).
Requires
HttpClient,
NetworkClient,
SocketUtil,
QuittableFrame,
Interruptable, and
LabeledTextField.
-
HttpClient.java. This is the underlying network code
used by WebClient to make a connection to an HTTP server
and send explicit HTTP headers.
-
Interruptable.java. An interface used by WebClient that
makes it easier to handle interrupted downloads.
-
Broken.sh. An example of an improper CGI script that will
cause a 500 error because it sends whitespace instead of a blank
line between the response header and the text. This is a Unix
shell script, but a very similar .bat file could be used on
Windows.
-
chocolate-chip.csh. A very simple script that sends
a cookie to the browser. This is a Unix
shell script, but a very similar .bat file could be used on
Windows.
-
oatmeal.csh. A very simple script that sends
a cookie to the browser. It is a Unix
shell script, but a very similar .bat file could be used on
Windows.
-
gingersnap.csh. A very simple script that sends
a cookie to the browser. It is a Unix
shell script, but a very similar .bat file could be used on
Windows.
-
flavors.csh. A simple script that reports the cookies
your browser is sending to that server.
-
ShowCookies.java. A program that reads cookie values and
places them into an HTML table. Note that Netscape may try to
interpret the strings used to generate the HTML, so the result may
not be very readable on-line. Save the file to the location of
your choice via right clicking or shift-clicking on the link.
- ShowCookies A simple one-line script
that simply invokes the ShowCookies Java program. It is a Unix
shell script, but a very similar .bat file could be used on
Windows. Requires
CgiShow,
CookieParser,
CgiParser,
LookupTable,
StringVector, and
URLDecoder.