|
PeanutButter
|
Processor for HTTP requests on top of the generic TCP processor. More...
Public Member Functions | |
| HttpProcessor (TcpClient tcpClient, HttpServerBase server) | |
| void | ProcessRequest () |
| Process the request. | |
| void | ParseRequest () |
| Parses the request from the TcpClient. | |
| void | ReadHeaders () |
| Reads in the headers from the TcpClient. | |
| void | ParseFormElementsIfRequired (MemoryStream ms) |
| Parses form data on the request, if available. | |
| void | WriteSuccess (string mimeType=HttpConstants.MimeTypes.HTML, byte[] data=null) |
| Perform a successful write (ie, HTTP status 200) with the optionally provided mime type and data data. | |
| void | WriteMIMETypeHeader (string mimeType) |
| Writes the specified MIME header (Content-Type) | |
| void | WriteOKStatusHeader () |
| Writes the OK status header. | |
| void | WriteContentLengthHeader (int length) |
| Writes the Content-Length header with the provided length. | |
| void | WriteConnectionClosesAfterCommsHeader () |
| Writes the header informing the client that the connection will not be held open. | |
| void | WriteHeader (string header, string value) |
| Writes an arbitrary header to the response stream. | |
| void | WriteHeader (string header, int value) |
| Writes an integer-value header to the response stream. | |
| void | WriteStatusHeader (HttpStatusCode code, string message=null) |
| Writes the specified status header to the response stream, with the optional message. | |
| void | WriteDataToStream (byte[] data) |
| Writes arbitrary byte data to the response stream. | |
| void | WriteDataToStream (string data) |
| Writes an arbitrary string to the response stream. | |
| void | WriteFailure (HttpStatusCode code) |
| Writes out a simple http failure. | |
| void | WriteFailure (HttpStatusCode code, string message) |
| Writes a failure code and message to the response stream and closes the response. | |
| void | WriteFailure (HttpStatusCode code, string message, string body) |
| Writes out an http failure with body text. | |
| void | WriteFailure (HttpStatusCode code, string message, string body, string mimeType) |
| Write out a failure with a message, body and custom mime-type. | |
| void | WriteEmptyLineToStream () |
| Writes an empty line to the stream: HTTP is line-based, so the client will probably interpret this as an end of section / request. | |
| void | WriteResponseLine (string response) |
| Write an arbitrary string response to the response stream. | |
| void | WriteDocument (string document) |
| Write a textural document to the response stream with the assumption that the mime type is text/html. | |
| void | WriteDocument (string document, string mimeType) |
| Write a textural document to the response stream with the optionally-provided mime type. | |
Protected Member Functions | |
| void | HandleRequest (TcpIoWrapper io) |
| Handles the request, given an IO wrapper. | |
| Protected Member Functions inherited from PeanutButter.SimpleHTTPServer.TcpServerProcessor | |
| TcpServerProcessor (TcpClient client) | |
Properties | |
| Action< string > | LogAction [get] |
| Action to use when attempting to log arbitrary data. | |
| Action< RequestLogItem > | RequestLogAction [get] |
| Action to use when attempting to log requests. | |
| HttpServerBase | Server [get, protected set] |
| Provides access to the server associated with this processor. | |
| string | Method [get] |
| Method of the current request being processed. | |
| string | FullUrl [get] |
| Full url for the request being processed. | |
| string | FullPath [get] |
| The full path, including query, for the request being processed. | |
| string | Path [get] |
| Just the path for the request being processed. | |
| string | Protocol [get] |
| Protocol for the request being processed. | |
| Dictionary< string, string > | UrlParameters [get, set] |
| Url parameters for the request being processed. | |
| Dictionary< string, string > | HttpHeaders [get] |
| Headers on the request being processed. | |
| long | MaxPostSize = MAX_POST_SIZE [get, set] |
| Maximum size, in bytes, to accept for a POST. | |
| Dictionary< string, string > | FormData [get, set] |
| Form data associated with the request. | |
| Properties inherited from PeanutButter.SimpleHTTPServer.TcpServerProcessor | |
| TcpClient | TcpClient [get, protected set] |
| Provides access to the TcpClient. | |
Processor for HTTP requests on top of the generic TCP processor.
|
protected |
Handles the request, given an IO wrapper.
| io |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.ParseFormElementsIfRequired | ( | MemoryStream | ms | ) |
Parses form data on the request, if available.
| ms |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.ProcessRequest | ( | ) |
Process the request.
Implements PeanutButter.SimpleTcpServer.IProcessor.
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteContentLengthHeader | ( | int | length | ) |
Writes the Content-Length header with the provided length.
| length |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteDataToStream | ( | byte[] | data | ) |
Writes arbitrary byte data to the response stream.
| data |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteDataToStream | ( | string | data | ) |
Writes an arbitrary string to the response stream.
| data |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteDocument | ( | string | document | ) |
Write a textural document to the response stream with the assumption that the mime type is text/html.
| document |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteDocument | ( | string | document, |
| string | mimeType ) |
Write a textural document to the response stream with the optionally-provided mime type.
| document | |
| mimeType |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteFailure | ( | HttpStatusCode | code | ) |
Writes out a simple http failure.
| code |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteFailure | ( | HttpStatusCode | code, |
| string | message ) |
Writes a failure code and message to the response stream and closes the response.
| code | |
| message |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteFailure | ( | HttpStatusCode | code, |
| string | message, | ||
| string | body ) |
Writes out an http failure with body text.
| code | The http code to return |
| message | The message to add to the status line |
| body | The body to write out |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteFailure | ( | HttpStatusCode | code, |
| string | message, | ||
| string | body, | ||
| string | mimeType ) |
Write out a failure with a message, body and custom mime-type.
| code | |
| message | |
| body | |
| mimeType |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteHeader | ( | string | header, |
| int | value ) |
Writes an integer-value header to the response stream.
| header | |
| value |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteHeader | ( | string | header, |
| string | value ) |
Writes an arbitrary header to the response stream.
| header | |
| value |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteMIMETypeHeader | ( | string | mimeType | ) |
Writes the specified MIME header (Content-Type)
| mimeType |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteResponseLine | ( | string | response | ) |
Write an arbitrary string response to the response stream.
| response |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteStatusHeader | ( | HttpStatusCode | code, |
| string | message = null ) |
Writes the specified status header to the response stream, with the optional message.
| code | |
| message |
| void PeanutButter.SimpleHTTPServer.HttpProcessor.WriteSuccess | ( | string | mimeType = HttpConstants::MimeTypes::HTML, |
| byte[] | data = null ) |
Perform a successful write (ie, HTTP status 200) with the optionally provided mime type and data data.
| mimeType | |
| data |