Summary
This chapter showed how to use the HttpWebRequest and HttpWebResponse classes. These classes add much more functionality than was provided by using only a Stream, as was done in Chapter 3.
Using the HttpWebRequest and HttpWebResponse classes 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 HttpWebRequest and HttpWebResponse classes also allow you to specify the connection and read timeouts. The connection timeout specifies the length of time that the HttpWebRequest and HttpWebResponse classes 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 view 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.




