View Source cowmachine_util (cowmachine v1.10.3)
Link to this section Summary
Functions
Select the best fitting character set or
none
Select the best fitting encoding or
none
Match the
Return the
If there is no acceptable/available match, return the atom
Accept
request header with content_types_provided
.Return the
Content-Type
for the response.If there is no acceptable/available match, return the atom
none
.AcceptHead
is the value of the request's Accept
header.Provided
is a list of media types the controller can provide:- a binary e.g. —
<<"text/html">>
- a binary and parameters e.g. —
{<<"text/html">>,[{<<"level">>,<<"1">>}]}
- two binaries e.g.
{<<"text">>, <<"html">>}
- two binaries and parameters e.g. —
{<<"text">>,<<"html">>,[{<<"level">>,<<"1">>}]}
Parse the HTTP date (IMF-fixdate, rfc850, asctime).
Match the
Content-Type
request header with content_types_accepted
against.Check header valid characters, see rfc822
Check if the given value is acceptaple for a http header value.
Parse a Content-Type like header, return the main Content-Type and a property list of options.
Check if the given location is safe to use as a location header. This is uses as a defense against urls with scripts. The test is quite strict and will drop values that might have been acceptable.
Link to this section Functions
-spec choose_charset(CSets, AccCharHdr) -> Result
when CSets :: [binary()], AccCharHdr :: binary(), Result :: none | binary().
none
-spec choose_encoding(Encs, AccEncHdr) -> Result
when Encs :: [binary()], AccEncHdr :: binary(), Result :: none | binary().
none
-spec choose_media_type_accepted(ContentTypesAccepted, ReqHeader) -> Result when ContentTypesAccepted :: [cowmachine_req:media_type()], ReqHeader :: cow_http_hd:media_type(), Result :: cowmachine_req:media_type() | none.
-spec choose_media_type_provided(Provided, AcceptHead) -> Result when Provided :: MediaTypes, MediaTypes :: [MediaType], MediaType :: cow_http_hd:media_type(), AcceptHead :: binary(), Result :: cow_http_hd:media_type() | none.
Accept
request header with content_types_provided
.Return the
Content-Type
for the response.If there is no acceptable/available match, return the atom
none
.AcceptHead
is the value of the request's Accept
header.Provided
is a list of media types the controller can provide:- a binary e.g. —
<<"text/html">>
- a binary and parameters e.g. —
{<<"text/html">>,[{<<"level">>,<<"1">>}]}
- two binaries e.g.
{<<"text">>, <<"html">>}
- two binaries and parameters e.g. —
{<<"text">>,<<"html">>,[{<<"level">>,<<"1">>}]}
-spec convert_request_date(Date) -> Result when Date :: binary(), Result :: calendar:datetime().
-spec format_content_type(MediaType) -> Result when MediaType :: cow_http_hd:media_type(), Result :: binary().
Link to this function
is_media_type_accepted(ContentTypesAccepted, ContentTypeReqHeader)
View Source-spec is_media_type_accepted(ContentTypesAccepted, ContentTypeReqHeader) -> Result when ContentTypesAccepted :: list(), ContentTypeReqHeader :: cow_http_hd:media_type(), Result :: boolean().
Content-Type
request header with content_types_accepted
against.
-spec is_valid_header(Header) -> Result when Header :: binary(), Result :: boolean().
-spec is_valid_header_value(Header) -> Result when Header :: binary(), Result :: boolean().
-spec normalize_content_type(Type) -> Result when Type :: cowmachine_req:media_type(), Result :: cow_http_hd:media_type().
-spec parse_header(String) -> Result
when String :: binary(), Result :: {binary(), [{binary(), binary()}]}.
-spec parse_qs(String) -> Result when String :: binary(), Result :: [{binary(), binary()}].
application/x-www-form-urlencoded
string.See also specification.
-spec quoted_string(String) -> Result when String :: binary(), Result :: binary().
-spec split_quoted_strings(String) -> Result when String :: binary(), Result :: [binary()].
-spec valid_location(Location) -> Result when Location :: binary(), Result :: {true, binary()} | false.