C# Class MvcApi.HttpRequestBaseExtensions

Extension methods that facilitate support for content negotiation and HTTP method overload.
显示文件 Open project: dax70/MvcApi

Public Methods

Method Description
GetRequestFormat ( this request ) : ContentType

Returns the format of a given request.

GetResponseFormats ( this request ) : List

Returns the preferred content type to use for the response, based on the request, according to the following rules: 1. If the query string contains a key called "format", its value is returned as the content type 2. Otherwise, if the request has an Accepts header, the list of content types in order of preference is returned 3. Otherwise, if the request has a content type, its value is returned

IsBrowserRequest ( this request ) : bool

Determines whether the specified HTTP request was sent by a Browser. A request is considered to be from the browser if it's a GET or POST and has a known User-Agent header (as determined by the request's BrowserCapabilities property), and does not have a non-HTML entity format (XML/JSON)

Private Methods

Method Description
HasBody ( this request ) : bool

Method Details

GetRequestFormat() public static method

Returns the format of a given request.
If the format is unrecognized or not supported.
public static GetRequestFormat ( this request ) : ContentType
request this The request.
return System.Net.Mime.ContentType

GetResponseFormats() public static method

Returns the preferred content type to use for the response, based on the request, according to the following rules: 1. If the query string contains a key called "format", its value is returned as the content type 2. Otherwise, if the request has an Accepts header, the list of content types in order of preference is returned 3. Otherwise, if the request has a content type, its value is returned
public static GetResponseFormats ( this request ) : List
request this The request.
return List

IsBrowserRequest() public static method

Determines whether the specified HTTP request was sent by a Browser. A request is considered to be from the browser if it's a GET or POST and has a known User-Agent header (as determined by the request's BrowserCapabilities property), and does not have a non-HTML entity format (XML/JSON)
public static IsBrowserRequest ( this request ) : bool
request this The request.
return bool