jeffheaton's picture

    This chapter showed how to use the HttpURLConnection class. This class adds much more functionality than was provided by using only an InputStream, as was done in Chapter 3.

    Using the HttpURLConnection allows access to both the HTTP request and response headers. Accessing these headers provides you with useful information about the HTTP transaction. These headers give such information as the type of document, the web server being used, the web browser being used and other important information.

    The HttpURLConnection class also allows you to specify the connection and read timeouts. The connection timeout specifies the amount of time that the HttpURLConnection object will wait for a connection. The read timeout specifies the amount of time that must pass before the read is terminated.

    This chapter presented four recipes. The first recipe showed how to scan a site and see the headers. The second recipe showed how to scan a range of IP addresses for web sites. The third recipe will download either a text or binary file. The fourth recipe will monitor a web site to make sure it does not go down.

    So far we have only made use of the HTTP protocol. The HTTP protocol is not secure, because it does not encrypt data being transmitted. For non-sensitive information this is fine. However, when you must pass sensitive information, the HTTPS protocol is usually used. The next chapter will discuss the HTTPS protocol.


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.