C# Class logv.http.ResponseExtensions

Helper class for IServer response extension methods
Mostrar archivo Open project: coolya/logv.http

Public Methods

Method Description
CachePrivate ( this res ) : IServerResponse

Appends a "private" to the Cache-Control header to deny caching on shared caches.

CachePublic ( this res ) : IServerResponse

Appends a "public" to the Cache-Control header to allow public cache to cache the resource

ETag ( this res, string tag ) : IServerResponse

Set the ETag header.

GetCachedResponse ( this res ) : IServerResponse

Gets the cached response that caches the data into a MemoryStream

MaxAge ( this res, int seconds ) : IServerResponse

Sets the max-age part of the Cache-Control header

NoCache ( this res ) : IServerResponse

Set the Cache-Control header to no-cache to enforce revalidation

Response201 ( this res, Uri newLocation ) : IServerResponse

Response with the status code: 201 Created The request has been fulfilled and resulted in a new resource being created.

Response202 ( this res ) : IServerResponse

Response with the status code: 202 Accepted The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. You might add additional data to the response body for the client to check the state of the operation.

Response204 ( this res ) : void

Response with the status code: 204 No Content The server successfully processed the request, but is not returning any content

Response204 ( this res, System additinalHeaders ) : void

Response with the status code: 204 No Content The server successfully processed the request, but is not returning any content

Response301 ( this res, Uri newLocation ) : void

Response with the status code: 301 Moved Permanently This and all future requests should be directed to the given URI. The client normally will issue a GET request to that url not matter what the original request was.

Response303 ( this res, Uri other ) : void

Response with the status code: 303 See Other The response to the request can be found under another URI using a GET method. When received in response to a POST (or PUT/DELETE), it should be assumed that the server has received the data and the redirect should be issued with a separate GET message.

Response304 ( this res ) : void

Response with the status code: 304 Not Modified Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header to provide a time against which to compare. Using this saves bandwidth and reprocessing on both the server and client, as only the header data must be sent and received in comparison to the entirety of the page being re-processed by the server, then sent again using more bandwidth of the server and client.

Response307 ( this res, Uri newLocation ) : void

Response with the status code: 307 Temporary Redirect In this case, the request should be repeated with another URI; however, future requests should still use the original URI. In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. For instance, a POST request repeated using another POST request.

Response400 ( this res ) : IServerResponse

Response with the status code: 400 Bad Request The request cannot be fulfilled due to bad syntax.

Response401 ( this res ) : IServerResponse

Response with the status code: 401 Unauthorized Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.

Response403 ( this res ) : void

Response with the status code: 403 Forbidden The request was a valid request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference. On servers where authentication is required, this commonly means that the provided credentials were successfully authenticated but that the credentials still do not grant the client permission to access the resource (e.g. a recognized user attempting to access restricted content).

Response404 ( this res ) : void

Response with the status code: 404 Not Found The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.

Response405 ( this res ) : void

Response with the status code: 405 Method Not Allowed A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.

Response409 ( this res ) : void

Response with the status code: 409 Conflict Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.

Response418 ( this res ) : void

Response with the status code: 418 I'm a teapot (RFC 2324) This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.

Response451 ( this res ) : IServerResponse

Response with the status code: 451 Unavailable For Legal Reasons (Internet draft) Defined in the internet draft "A New HTTP Status Code for Legally-restricted Resources". Intended to be used when resource access is denied for legal reasons, e.g. censorship or government-mandated blocked access. A reference to the 1953 dystopian novel Fahrenheit 451, where books are outlawed.

Response500 ( this res ) : IServerResponse

Response with the status code: 500 Internal Server Error A generic error message, given when no more specific message is suitable.

Response500 ( this res, Exception ex ) : IServerResponse

Response with the status code: 500 Internal Server Error A generic error message, given when no more specific message is suitable.

Response503 ( this res ) : IServerResponse

Response with the status code: 503 Service Unavailable The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

Response503 ( this res, Exception ex ) : IServerResponse

Response with the status code: 503 Service Unavailable The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

Response507 ( this res ) : IServerResponse

Response with the status code: 507 Insufficient Storage The server is unable to store the representation needed to complete the request

ServeFile ( this res, string path ) : void

Serves the given file to the client and closes the request when done.

ServeFile ( this res, string path, string mimeType ) : void

Serves the given file to the client and closes the request when done.

Write ( this res, EncodingType type, byte data ) : IServerResponse

Writes the specified byte data to the response

Write ( this res, string data ) : IServerResponse

Writes the given string to the response

Write ( this res, string data, Encoding charset, EncodingType encoding ) : IServerResponse

Writes the given string to the response

WriteAsJson ( this res, object obj ) : IServerResponse

Writes the given object to the response as JSON

WriteAsJson ( this res, object obj, Encoding charset, EncodingType encoding ) : IServerResponse

Writes the given object to the response as JSON

Method Details

CachePrivate() public static method

Appends a "private" to the Cache-Control header to deny caching on shared caches.
public static CachePrivate ( this res ) : IServerResponse
res this The res.
return IServerResponse

CachePublic() public static method

Appends a "public" to the Cache-Control header to allow public cache to cache the resource
public static CachePublic ( this res ) : IServerResponse
res this The res.
return IServerResponse

ETag() public static method

Set the ETag header.
public static ETag ( this res, string tag ) : IServerResponse
res this The res.
tag string The tag.
return IServerResponse

GetCachedResponse() public static method

Gets the cached response that caches the data into a MemoryStream
public static GetCachedResponse ( this res ) : IServerResponse
res this The res.
return IServerResponse

MaxAge() public static method

Sets the max-age part of the Cache-Control header
public static MaxAge ( this res, int seconds ) : IServerResponse
res this The res.
seconds int The seconds.
return IServerResponse

NoCache() public static method

Set the Cache-Control header to no-cache to enforce revalidation
public static NoCache ( this res ) : IServerResponse
res this The res.
return IServerResponse

Response201() public static method

Response with the status code: 201 Created The request has been fulfilled and resulted in a new resource being created.
public static Response201 ( this res, Uri newLocation ) : IServerResponse
res this The response to the client
newLocation System.Uri The new location of the created resource
return IServerResponse

Response202() public static method

Response with the status code: 202 Accepted The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. You might add additional data to the response body for the client to check the state of the operation.
public static Response202 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response204() public static method

Response with the status code: 204 No Content The server successfully processed the request, but is not returning any content
public static Response204 ( this res ) : void
res this The response to the client
return void

Response204() public static method

Response with the status code: 204 No Content The server successfully processed the request, but is not returning any content
public static Response204 ( this res, System additinalHeaders ) : void
res this The response to the client
additinalHeaders System The additional headers.
return void

Response301() public static method

Response with the status code: 301 Moved Permanently This and all future requests should be directed to the given URI. The client normally will issue a GET request to that url not matter what the original request was.
public static Response301 ( this res, Uri newLocation ) : void
res this The response to the client
newLocation System.Uri The new location.
return void

Response303() public static method

Response with the status code: 303 See Other The response to the request can be found under another URI using a GET method. When received in response to a POST (or PUT/DELETE), it should be assumed that the server has received the data and the redirect should be issued with a separate GET message.
public static Response303 ( this res, Uri other ) : void
res this The response to the client
other System.Uri The other location.
return void

Response304() public static method

Response with the status code: 304 Not Modified Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header to provide a time against which to compare. Using this saves bandwidth and reprocessing on both the server and client, as only the header data must be sent and received in comparison to the entirety of the page being re-processed by the server, then sent again using more bandwidth of the server and client.
public static Response304 ( this res ) : void
res this The response to the client
return void

Response307() public static method

Response with the status code: 307 Temporary Redirect In this case, the request should be repeated with another URI; however, future requests should still use the original URI. In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. For instance, a POST request repeated using another POST request.
public static Response307 ( this res, Uri newLocation ) : void
res this The response to the client
newLocation System.Uri The new location.
return void

Response400() public static method

Response with the status code: 400 Bad Request The request cannot be fulfilled due to bad syntax.
public static Response400 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response401() public static method

Response with the status code: 401 Unauthorized Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.
public static Response401 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response403() public static method

Response with the status code: 403 Forbidden The request was a valid request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference. On servers where authentication is required, this commonly means that the provided credentials were successfully authenticated but that the credentials still do not grant the client permission to access the resource (e.g. a recognized user attempting to access restricted content).
public static Response403 ( this res ) : void
res this The response to the client
return void

Response404() public static method

Response with the status code: 404 Not Found The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
public static Response404 ( this res ) : void
res this The response to the client
return void

Response405() public static method

Response with the status code: 405 Method Not Allowed A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.
public static Response405 ( this res ) : void
res this The response to the client
return void

Response409() public static method

Response with the status code: 409 Conflict Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.
public static Response409 ( this res ) : void
res this The response to the client
return void

Response418() public static method

Response with the status code: 418 I'm a teapot (RFC 2324) This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.
public static Response418 ( this res ) : void
res this The response to the client
return void

Response451() public static method

Response with the status code: 451 Unavailable For Legal Reasons (Internet draft) Defined in the internet draft "A New HTTP Status Code for Legally-restricted Resources". Intended to be used when resource access is denied for legal reasons, e.g. censorship or government-mandated blocked access. A reference to the 1953 dystopian novel Fahrenheit 451, where books are outlawed.
public static Response451 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response500() public static method

Response with the status code: 500 Internal Server Error A generic error message, given when no more specific message is suitable.
public static Response500 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response500() public static method

Response with the status code: 500 Internal Server Error A generic error message, given when no more specific message is suitable.
public static Response500 ( this res, Exception ex ) : IServerResponse
res this The response to the client
ex System.Exception The ex.
return IServerResponse

Response503() public static method

Response with the status code: 503 Service Unavailable The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.
public static Response503 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

Response503() public static method

Response with the status code: 503 Service Unavailable The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.
public static Response503 ( this res, Exception ex ) : IServerResponse
res this The response to the client
ex System.Exception The ex.
return IServerResponse

Response507() public static method

Response with the status code: 507 Insufficient Storage The server is unable to store the representation needed to complete the request
public static Response507 ( this res ) : IServerResponse
res this The response to the client
return IServerResponse

ServeFile() public static method

Serves the given file to the client and closes the request when done.
File does not exist
public static ServeFile ( this res, string path ) : void
res this The res.
path string The path.
return void

ServeFile() public static method

Serves the given file to the client and closes the request when done.
public static ServeFile ( this res, string path, string mimeType ) : void
res this The res.
path string The path.
mimeType string Type of the MIME type.
return void

Write() public static method

Writes the specified byte data to the response
public static Write ( this res, EncodingType type, byte data ) : IServerResponse
res this The res.
type EncodingType The type.
data byte The data.
return IServerResponse

Write() public static method

Writes the given string to the response
public static Write ( this res, string data ) : IServerResponse
res this The res.
data string The data.
return IServerResponse

Write() public static method

Writes the given string to the response
public static Write ( this res, string data, Encoding charset, EncodingType encoding ) : IServerResponse
res this The res.
data string The data.
charset System.Text.Encoding The charset.
encoding EncodingType The encoding.
return IServerResponse

WriteAsJson() public static method

Writes the given object to the response as JSON
public static WriteAsJson ( this res, object obj ) : IServerResponse
res this The res.
obj object The obj.
return IServerResponse

WriteAsJson() public static method

Writes the given object to the response as JSON
public static WriteAsJson ( this res, object obj, Encoding charset, EncodingType encoding ) : IServerResponse
res this The res.
obj object The obj.
charset System.Text.Encoding The charset.
encoding EncodingType The encoding.
return IServerResponse