Class HttpListenerResponse
Represents a response to a request being handled by an HttpListener object.
public sealed class HttpListenerResponse : IDisposable
- Inheritance
-
HttpListenerResponse
- Implements
- Inherited Members
- Extension Methods
Properties
ContentEncoding
Gets or sets the encoding for this response's
public Encoding ContentEncoding { get; set; }
Property Value
- Encoding
An
Encoding object suitable for use with the data in the OutputStream property, ornull reference if no encoding is specified.
Remarks
Only UTF8 encoding is supported.
ContentLength64
Gets or sets the number of bytes in the body data included in the response.
public long ContentLength64 { get; set; }
Property Value
- long
The value of the response's
Content-Length header.
ContentType
Gets or sets the MIME type of the returned content.
public string ContentType { get; set; }
Property Value
- string
A
String instance that contains the text of the response'sContent-Type header.
Headers
Gets or sets the collection of header name/value pairs that is returned by the server.
public WebHeaderCollection Headers { get; set; }
Property Value
- WebHeaderCollection
A
WebHeaderCollection instance that contains all the explicitly set HTTP headers to be included in the response.
KeepAlive
Gets or sets whether the server requests a persistent connection.
public bool KeepAlive { get; set; }
Property Value
- bool
true if the server requests a persistent connection; otherwise,false . The default istrue .
OutputStream
Gets a
public Stream OutputStream { get; }
Property Value
- Stream
A
Stream object to which a response can be written.
Remarks
The first write to the output stream sends a response to the client.
ProtocolVersion
Gets or sets the HTTP version that is used for the response.
public Version ProtocolVersion { get; set; }
Property Value
- Version
A
Version object indicating the version of HTTP used when responding to the client. This property is obsolete.
RedirectLocation
Gets or sets the value of the HTTP
public string RedirectLocation { get; set; }
Property Value
- string
A
String that contains the absolute URL to be sent to the client in theLocation header.
SendChunked
Gets or sets whether the response uses chunked transfer encoding.
public bool SendChunked { get; set; }
Property Value
- bool
true if the response is set to use chunked transfer encoding; otherwise,false . The default isfalse .
StatusCode
Gets or sets the HTTP status code to be returned to the client.
public int StatusCode { get; set; }
Property Value
- int
An
Int32 value that specifies the HttpStatusCode for the requested resource. The default isOK , indicating that the server successfully processed the client's request and included the requested resource in the response body.
StatusDescription
Gets or sets a text description of the HTTP status code that is returned to the client.
public string StatusDescription { get; set; }
Property Value
- string
The text description of the HTTP status code returned to the client.
Methods
Close()
Sends the response to the client and releases the resources held by this HttpListenerResponse instance.
public void Close()
Remarks
This method flushes data to the client and closes the network connection.
Detach()
public void Detach()
Finalize()
Called to close the socket if necessary.
protected override void Finalize()