C# Class HttpServer.HttpClientContextImp

Contains a connection to a browser/client.
Inheritance: IHttpClientContext
Show file Open project: 3di/3di-viewer-rei-libs

Public Methods

Method Description
Disconnect ( SocketError error ) : void

Disconnect from client

HttpClientContextImp ( bool secured, IPEndPoint remoteEndPoint, RequestReceivedHandler requestHandler, ClientDisconnectedHandler disconnectHandler, Stream stream, ILogWriter writer ) : System

Initializes a new instance of the HttpClientContextImp class.

HttpClientContextImp ( bool secured, IPEndPoint remoteEndPoint, Stream stream, RequestReceivedHandler requestHandler ) : System

Initializes a new instance of the HttpClientContextImp class.

Respond ( string body ) : void

Send a response.

Respond ( string httpVersion, HttpServer.HttpStatusCode statusCode, string reason ) : void

Send a response.

Respond ( string httpVersion, HttpServer.HttpStatusCode statusCode, string reason, string body, string contentType ) : void

Send a response.

Send ( byte buffer ) : void

send a whole buffer

Send ( byte buffer, int offset, int size ) : void

Send data using the stream

Protected Methods

Method Description
Check100Continue ( ) : void

This method checks the request if a responde to 100-continue should be sent.

100 continue is a value in the Expect header. It's used to let the webserver determine if a request can be handled. The client waits for a reply before sending the body.

Private Methods

Method Description
OnReceive ( IAsyncResult ar ) : void
OnRequestCompleted ( IHttpRequest request ) : void

Method Details

Check100Continue() protected method

This method checks the request if a responde to 100-continue should be sent.
100 continue is a value in the Expect header. It's used to let the webserver determine if a request can be handled. The client waits for a reply before sending the body.
protected Check100Continue ( ) : void
return void

Disconnect() public method

Disconnect from client
public Disconnect ( SocketError error ) : void
error SocketError error to report in the delegate.
return void

HttpClientContextImp() public method

Initializes a new instance of the HttpClientContextImp class.
If beginreceive fails
public HttpClientContextImp ( bool secured, IPEndPoint remoteEndPoint, RequestReceivedHandler requestHandler, ClientDisconnectedHandler disconnectHandler, Stream stream, ILogWriter writer ) : System
secured bool true if the connection is secured (SSL/TLS)
remoteEndPoint System.Net.IPEndPoint client that connected.
requestHandler RequestReceivedHandler delegate handling incoming requests.
disconnectHandler ClientDisconnectedHandler delegate being called when a client disconnectes
stream Stream Stream used for communication
writer ILogWriter delegate used to write log entries
return System

HttpClientContextImp() public method

Initializes a new instance of the HttpClientContextImp class.
If beginreceive fails
public HttpClientContextImp ( bool secured, IPEndPoint remoteEndPoint, Stream stream, RequestReceivedHandler requestHandler ) : System
secured bool true if the connection is secured (SSL/TLS)
remoteEndPoint System.Net.IPEndPoint client that connected
stream Stream Stream used for communication
requestHandler RequestReceivedHandler delegate handling incoming requests.
return System

Respond() public method

Send a response.
public Respond ( string body ) : void
body string
return void

Respond() public method

Send a response.
public Respond ( string httpVersion, HttpServer.HttpStatusCode statusCode, string reason ) : void
httpVersion string Either HttpHelper.HTTP10 or HttpHelper.HTTP11
statusCode HttpServer.HttpStatusCode http status code
reason string reason for the status code.
return void

Respond() public method

Send a response.
If httpVersion is invalid.
public Respond ( string httpVersion, HttpServer.HttpStatusCode statusCode, string reason, string body, string contentType ) : void
httpVersion string Either HttpHelper.HTTP10 or HttpHelper.HTTP11
statusCode HttpServer.HttpStatusCode http status code
reason string reason for the status code.
body string html body contents, can be null or empty.
contentType string A content type to return the body as, ie 'text/html' or 'text/plain', defaults to 'text/html' if null or empty
return void

Send() public method

send a whole buffer
public Send ( byte buffer ) : void
buffer byte buffer to send
return void

Send() public method

Send data using the stream
public Send ( byte buffer, int offset, int size ) : void
buffer byte Contains data to send
offset int Start position in buffer
size int number of bytes to send
return void