Share via


HttpWebResponse Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Provides an HTTP-specific implementation of the WebResponse class.

Inheritance Hierarchy

System. . :: . .Object
  System. . :: . .MarshalByRefObject
    System.Net. . :: . .WebResponse
      System.Net..::..HttpWebResponse

Namespace:  System.Net
Assembly:  System.Http (in System.Http.dll)

Syntax

'Declaration
Public Class HttpWebResponse _
    Inherits WebResponse
public class HttpWebResponse : WebResponse
public ref class HttpWebResponse : public WebResponse
type HttpWebResponse =  
    class
        inherit WebResponse
    end
public class HttpWebResponse extends WebResponse

The HttpWebResponse type exposes the following members.

Properties

  Name Description
Public property ContentEncoding Gets the method that is used to encode the body of the response.
Public property ContentLength Gets the length of the content returned by the request. (Overrides WebResponse. . :: . .ContentLength.)
Public property ContentType Gets the content type of the response. (Overrides WebResponse. . :: . .ContentType.)
Public property Headers Gets the headers that are associated with this response from the server. (Overrides WebResponse. . :: . .Headers.)
Public property LastModified Gets the last date and time that the contents of the response were modified.
Public property Method Gets the method that is used to return the response.
Public property ProtocolVersion Gets the version of the HTTP protocol that is used in the response.
Public property ResponseUri Gets the URI of the Internet resource that responded to the request. (Overrides WebResponse. . :: . .ResponseUri.)
Public property Server Gets the name of the server that sent the response.
Public property StatusCode Gets the status of the response.
Public property StatusDescription Gets the status description returned with the response.

Top

Methods

  Name Description
Public method Close When overridden by a descendant class, closes the response stream. (Inherited from WebResponse.)
Public method Dispose() () () () Releases the unmanaged resources used by the WebResponse object. (Inherited from WebResponse.)
Protected method Dispose(Boolean) Releases the unmanaged resources used by the HttpWebResponse, and optionally disposes of the managed resources. (Overrides WebResponse. . :: . .Dispose(Boolean).)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Performs clean-up operations. (Inherited from WebResponse.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetResponseHeader Gets the contents of a header that was returned with the response.
Public method GetResponseStream Gets the stream that is used to read the body of the response from the server. (Overrides WebResponse. . :: . .GetResponseStream() () () ().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

This class contains support for HTTP-specific uses of the properties and methods of the WebResponse class. The HttpWebResponse class is used to build HTTP stand-alone client applications that send HTTP requests and receive HTTP responses.

You should never directly create an instance of the HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest..::..GetResponse. You must call either the Stream..::..Close or the HttpWebResponse.Close method to close the response and release the connection for reuse. It is not necessary to call both Stream..::..Close and HttpWebResponse.Close, but doing so does not cause an error.

Common header information returned from the Internet resource is exposed as properties of the class. See the following table for a complete list. Other headers can be read from the Headers property as name/value pairs.

The following table shows the common HTTP headers that are available through properties of the HttpWebResponse class.

Header

Property

Content-Encoding

ContentEncoding

Content-Length

ContentLength

Content-Type

ContentType

Last-Modified

LastModified

Server

Server

The contents of the response from the Internet resource are returned as a Stream by calling the GetResponseStream method.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Net Namespace