The HTTP library allows access to Internet resources using the HTTP protocol.
Communication is done with two objects; WebRequest which makes the request and
WebResponse which includes the data received from the server (like a html file).
The stages of communicating with a HTTP server are:
- Create a WebRequest object with the required URL.
- Set the WebRequest header properties.
- If you need to upload data with the request use WebRequest.GetStream and write to the
stream.
- Launch the request and assign the response to a WebResult object.
The last operation blocks until the data is received.
- Use the WebResult.GetStream to get the data stream and read the result from it.
- Close the WebResult.
As of version 1.5 it is possible to make asynchronous requests using
WebRequest.GetAsyncResponse, and it is possible to retrieve the data asynchronously
with WebResponse.GetAsyncStream or WebResponse.GetAsyncString.
Unlike the synchronous calls the asynchronous calls will not freeze the interface during
communication.