Mono Class Library: System.Net NamespaceSystem.Net.HttpWebRequest Class |
See Also: HttpWebRequest Members
System.Object
System.MarshalByRefObject
System.Net.WebRequest
System.Net.HttpWebRequest
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
This class implements properties and methods defined in System.Net.WebRequest and provides additional properties and methods that enable the user to interact directly with servers using the Hypertext Transfer Protocol (HTTP).
Note:[Edit]Instances of this class are automatically created by the System.Net.WebRequest class. For example, an instance of System.Net.HttpWebRequest is created when the WebRequest.Create(Uri, bool) method is called and a Uniform Resource Identifier (URI) beginning with http:// is specified. It is expected that an instance of this class will be constructed for every request made to the server. For example, after a call to HttpWebRequest.Abort cancels an asynchronous operation, a call to HttpWebRequest.GetRequestStream causes a System.Net.WebException to be thrown.
Requests can be sent synchronously or asynchronously. The HttpWebRequest.GetResponse method sends a request to a server synchronously and returns a System.Net.HttpWebResponse instance containing the response. An asynchronous request for a resource is sent using the HttpWebRequest.BeginGetResponse(AsyncCallback, object) and HttpWebRequest.EndGetResponse(IAsyncResult) methods.
Request data is sent using a request stream. The HttpWebRequest.GetRequestStream , HttpWebRequest.BeginGetRequestStream(AsyncCallback, object), and HttpWebRequest.EndGetRequestStream(IAsyncResult) methods return a System.IO.Stream instance used to send data.
When errors occur while accessing an Internet resource, the System.Net.HttpWebRequest class throws a System.Net.WebException , and the WebException.Status property that indicates the source of the error. When WebException.Status is WebExceptionStatus.ProtocolError, the WebException.Response property contains the System.Net.HttpWebResponse received from the Internet resource.
Certain HTTP headers are protected; the user cannot set them directly in the header collection obtained from the HttpWebRequest.Headers property. Instead, these headers are set using the associated properties of a System.Net.HttpWebRequest instance, or are set by the system. The following table describes how each protected header is set.
Header Set by Accept HttpWebRequest.Accept Connection Content-Length HttpWebRequest.ContentLength Content-Type HttpWebRequest.ContentType Expect HttpWebRequest.Expect Date Set to current date by the system. Host Set to current host by the system. if-Modified-since HttpWebRequest.IfModifiedSince Range HttpWebRequest.AddRange(int, int) Referer HttpWebRequest.Referer Transfer-Encoding User-Agent HttpWebRequest.UserAgent
Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0, 2.0.0.0