Java Reference
In-Depth Information
Table 4.2 shows the header used by most major browsers to identify them. As you can
see, this header also communicates what operating system the user is running as well.
Table 4.2: Identities of Several Major Browsers
Browser User-Agent Header
Firefox 1.5 (PC) Mozilla/5.0(PC) (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Internet Explorer 6.0 (PC) Mozilla/4.0(PC) (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322)
Safari v2 (Mac) Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) Ap-
pleWebKit/418.8 (KHTML, like Gecko) Safari/419.3
Firefox v1.5 (Mac) Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-
US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Internet Explorer 5.1 (Mac) Mozilla/4.0 (compatible; MSIE 5.14; Mac_PowerPC)
Java(PC/Mac)
Java/1.5.0_06
You will also notice from the above list, I have Java listed as a browser. This is what Java
will report to a web site, if you do not override the user-agent . It is usually better to
override this value with something else.
Server Headers
The server headers contain many useful pieces of information. Server headers are com-
monly used for:
• Determining the type of data at a URL
• Determining the cookies in use
• Determining the web server software in use
• Determining the size of the content at this URL
For the bots that you create, you will most commonly use server headers to determine
the type of data at a URL and to support cookies.
Reading Server Headers
Once you retrieve the contents of a URL back from the server, there are head-
ers available to the program. The web server provided this second set of headers. The
HttpURLConnection class provides several functions and methods to access these
server response headers. These functions and methods are listed in Table 4.3.
Search WWH ::




Custom Search