websocket-sharp : WebSocketSharp.Net Namespace

# HttpListenerResponse Class

Provides access to a response to a request being processed by a WebSocketSharp.Net.HttpListener instance.

## Syntax

public sealed class HttpListenerResponse : IDisposable

## Remarks

The HttpListenerResponse class cannot be inherited.

## Requirements

Namespace: WebSocketSharp.Net
Assembly: websocket-sharp (in websocket-sharp.dll)

## Members

See Also: Inherited members from object.

## Public Properties

| ContentEncoding | System.Text.Encoding . Gets or sets the encoding that can be used with the entity body data included in the response.
| ContentLength64 | long . Gets or sets the size of the entity body data included in the response.
| ContentType | string . Gets or sets the media type of the entity body included in the response.
| Cookies | CookieCollection . Gets or sets the cookies returned with the response.
| Headers | WebHeaderCollection . Gets or sets the HTTP headers returned to the client.
| KeepAlive | bool . Gets or sets a value indicating whether the server requests a persistent connection.
[read-only] | OutputStream | System.IO.Stream . Gets a System.IO.Stream to use to write the entity body data.
| ProtocolVersion | Version . Gets or sets the HTTP version used in the response.
| RedirectLocation | string . Gets or sets the URL to which the client is redirected to locate a requested resource.
| SendChunked | bool . Gets or sets a value indicating whether the response uses the chunked transfer encoding.
| StatusCode | int . Gets or sets the HTTP status code returned to the client.
| StatusDescription | string . Gets or sets a description of the HTTP status code returned to the client.

## Public Methods

| Abort () Closes the connection to the client without sending a response.
| AddHeader (string, string) Adds the specified HTTP header name and value to the headers for this response.
| AppendCookie (Cookie) Adds the specified WebSocketSharp.Net.Cookie to the HttpListenerResponse.Cookies sent with the response.
| AppendHeader (string, string) Appends a value to the specified HTTP header sent with the response.
| Close () Sends the response to the client and releases the resources associated with the WebSocketSharp.Net.HttpListenerResponse instance.
| Close (byte[], bool) Sends the response with the specified array of byte to the client and releases the resources associated with the WebSocketSharp.Net.HttpListenerResponse instance.
| CopyFrom (HttpListenerResponse) Copies properties from the specified WebSocketSharp.Net.HttpListenerResponse to this response.
| Redirect (string) Configures the response to redirect the client's request to the specified url.
| SetCookie (Cookie) Adds or updates a WebSocketSharp.Net.Cookie in the HttpListenerResponse.Cookies sent with the response.

## Explicitly Implemented Interface Members

| IDisposable.Dispose | Releases all resource used by the WebSocketSharp.Net.HttpListenerResponse.

## Extension Methods

static | IsNull<T> (this T) : bool Determines whether the specified object is `null`.
static | IsNullDo<T> (this T, Action) : bool Determines whether the specified object is `null`. And invokes the specified Action delegate if the specified object is `null`.
static | WriteContent (this HttpListenerResponse, byte[]) Writes the specified content data using the specified WebSocketSharp.Net.HttpListenerResponse.

## Member Details

### Abort Method

> Closes the connection to the client without sending a response.

> ## Syntax

> public void Abort ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### AddHeader Method

> Adds the specified HTTP header name and value to the headers for this response.

> ## Syntax

> public void AddHeader (string name, string value)

> #### Parameters

> > name
> >   A string that contains the name of the HTTP header to add.
> > value
> >   A string that contains the value of the HTTP header to add.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ArgumentNullException | name is `null` or string.Empty.
> > ArgumentOutOfRangeException | The length of value is greater than 65,535 characters.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### AppendCookie Method

> Adds the specified WebSocketSharp.Net.Cookie to the HttpListenerResponse.Cookies sent with the response.

> ## Syntax

> public void AppendCookie (Cookie cookie)

> #### Parameters

> > cookie
> >   A WebSocketSharp.Net.Cookie to add to the HttpListenerResponse.Cookies.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ArgumentNullException | cookie is `null`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### AppendHeader Method

> Appends a value to the specified HTTP header sent with the response.

> ## Syntax

> public void AppendHeader (string name, string value)

> #### Parameters

> > name
> >   A string that contains the name of the HTTP header to append value to.
> > value
> >   A string that contains the value to append to the HTTP header.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ArgumentException | name is `null` or string.Empty.
> > ArgumentOutOfRangeException | The length of value is greater than 65,535 characters.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Close Method

> Sends the response to the client and releases the resources associated with the WebSocketSharp.Net.HttpListenerResponse instance.

> ## Syntax

> public void Close ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Close Method

> Sends the response with the specified array of byte to the client and releases the resources associated with the WebSocketSharp.Net.HttpListenerResponse instance.

> ## Syntax

> public void Close (byte[] responseEntity, bool willBlock)

> #### Parameters

> > responseEntity
> >   An array of byte that contains the response entity body data.
> > willBlock
> >   `true` if this method blocks execution while flushing the stream to the client; otherwise, `false`.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ArgumentNullException | responseEntity is `null`.
> > ObjectDisposedException | This object is closed.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### ContentEncoding Property

> Gets or sets the encoding that can be used with the entity body data included in the response.

> ## Syntax

> public System.Text.Encoding ContentEncoding { get; set; }

> #### Value

> > A System.Text.Encoding that contains the encoding that can be used with the entity body data.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### ContentLength64 Property

> Gets or sets the size of the entity body data included in the response.

> ## Syntax

> public long ContentLength64 { get; set; }

> #### Value

> > A long that contains the value of the Content-Length entity-header field. The value is a number of bytes in the entity body data.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.
> > ArgumentOutOfRangeException | The value specified for a set operation is less than zero.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### ContentType Property

> Gets or sets the media type of the entity body included in the response.

> ## Syntax

> public string ContentType { get; set; }

> #### Value

> > The type of the content. A string that contains the value of the Content-Type entity-header field.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.
> > ArgumentNullException | The value specified for a set operation is `null`.
> > ArgumentException | The value specified for a set operation is a string.Empty.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Cookies Property

> Gets or sets the cookies returned with the response.

> ## Syntax

> public CookieCollection Cookies { get; set; }

> #### Value

> > A WebSocketSharp.Net.CookieCollection that contains the cookies returned with the response.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### CopyFrom Method

> Copies properties from the specified WebSocketSharp.Net.HttpListenerResponse to this response.

> ## Syntax

> public void CopyFrom (HttpListenerResponse templateResponse)

> #### Parameters

> > templateResponse
> >   A WebSocketSharp.Net.HttpListenerResponse to copy.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Headers Property

> Gets or sets the HTTP headers returned to the client.

> ## Syntax

> public WebHeaderCollection Headers { get; set; }

> #### Value

> > A WebSocketSharp.Net.WebHeaderCollection that contains the HTTP headers returned to the client.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### KeepAlive Property

> Gets or sets a value indicating whether the server requests a persistent connection.

> ## Syntax

> public bool KeepAlive { get; set; }

> #### Value

> > `true` if the server requests a persistent connection; otherwise, `false`. The default is `true`.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OutputStream Property

> Gets a System.IO.Stream to use to write the entity body data.

> ## Syntax

> public System.IO.Stream OutputStream { get; }

> #### Value

> > A System.IO.Stream to use to write the entity body data.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### ProtocolVersion Property

> Gets or sets the HTTP version used in the response.

> ## Syntax

> public Version ProtocolVersion { get; set; }

> #### Value

> > A Version that contains the HTTP version used in the response.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.
> > ArgumentNullException | The value specified for a set operation is `null`.
> > ArgumentException | The value specified for a set operation does not have its Version.Major property set to 1 or does not have its Version.Minor property set to either 0 or 1.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Redirect Method

> Configures the response to redirect the client's request to the specified url.

> ## Syntax

> public void Redirect (string url)

> #### Parameters

> > url
> >   A string that contains a URL to redirect the client's request to.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### RedirectLocation Property

> Gets or sets the URL to which the client is redirected to locate a requested resource.

> ## Syntax

> public string RedirectLocation { get; set; }

> #### Value

> > A string that contains the value of the Location response-header field.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.
> > ArgumentException | The value specified for a set operation is a string.Empty.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### SendChunked Property

> Gets or sets a value indicating whether the response uses the chunked transfer encoding.

> ## Syntax

> public bool SendChunked { get; set; }

> #### Value

> > `true` if the response uses the chunked transfer encoding; otherwise, `false`.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### SetCookie Method

> Adds or updates a WebSocketSharp.Net.Cookie in the HttpListenerResponse.Cookies sent with the response.

> ## Syntax

> public void SetCookie (Cookie cookie)

> #### Parameters

> > cookie
> >   A WebSocketSharp.Net.Cookie to set.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ArgumentNullException | cookie is `null`.
> > ArgumentException | cookie already exists in the HttpListenerResponse.Cookies and could not be replaced.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### StatusCode Property

> Gets or sets the HTTP status code returned to the client.

> ## Syntax

> public int StatusCode { get; set; }

> #### Value

> > An int that indicates the HTTP status code for the response to the request. The default is HttpStatusCode.OK.

> #### Exceptions

> > Type | Reason
> > --- | ---
> > ObjectDisposedException | This object is closed.
> > InvalidOperationException | The response has been sent already.
> > System.Net.ProtocolViolationException | The value specified for a set operation is invalid. Valid values are between 100 and 999.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### StatusDescription Property

> Gets or sets a description of the HTTP status code returned to the client.

> ## Syntax

> public string StatusDescription { get; set; }

> #### Value

> > A string that contains a description of the HTTP status code returned to the client.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)

### System.IDisposable.Dispose Method

> Releases all resource used by the WebSocketSharp.Net.HttpListenerResponse.

> ## Syntax

> void System.IDisposable.Dispose ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Net
> Assembly: websocket-sharp (in websocket-sharp.dll)