Module cowmachine_util

Utilities for parsing, quoting, and negotiation.

Copyright © 2007-2008 Basho Technologies

Authors: Justin Sheehy (justin@basho.com), Andy Gross (andy@basho.com).

Description

Utilities for parsing, quoting, and negotiation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Index

choose_charset/2Select the best fitting character set or 'none'.
choose_encoding/2Select the best fitting encoding or 'none'.
choose_media_type_accepted/2
choose_media_type_provided/2Match the Accept request header with content_types_provided Return the Content-Type for the response.
convert_request_date/1Parse the HTTP date (IMF-fixdate, rfc850, asctime).
format_content_type/1
is_media_type_accepted/2Match the Content-Type request header with content_types_accepted against.
normalize_content_type/1
parse_header/1 Parse a Content-Type like header, return the main Content-Type and a property list of options.
parse_qs/1Parse an application/x-www-form-urlencoded string.
quoted_string/1
split_quoted_strings/1

Function Details

choose_charset/2

choose_charset(CSets::[binary()], AccCharHdr::binary()) -> binary() | none

Select the best fitting character set or 'none'

choose_encoding/2

choose_encoding(Encs::[binary()], AccEncHdr::binary()) -> binary() | none

Select the best fitting encoding or 'none'

choose_media_type_accepted/2

choose_media_type_accepted(ContentTypesAccepted::[cowmachine_req:media_type()], ReqHeader::cow_http_hd:media_type()) -> cowmachine_req:media_type()

choose_media_type_provided/2

choose_media_type_provided(Provided::list(), AcceptHead::binary()) -> cow_http_hd:media_type() | none

Match the 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. each is either a binary e.g. -- <<"text/html">> or a binary and parameters e.g. -- {<<"text/html">>,[{<<"level">>,<<"1">>}]} or two binaries e.g. {<<"text">>, <<"html">>} or two binaries and parameters e.g. -- {<<"text">>,<<"html">>,[{<<"level">>,<<"1">>}]} (the plain string case with no parameters is much more common)

convert_request_date/1

convert_request_date(Date::binary()) -> calendar:datetime()

Parse the HTTP date (IMF-fixdate, rfc850, asctime).

format_content_type/1

format_content_type(X1::cow_http_hd:media_type()) -> binary()

is_media_type_accepted/2

is_media_type_accepted(ContentTypesAccepted::list(), ReqHeader::cow_http_hd:media_type()) -> boolean()

Match the Content-Type request header with content_types_accepted against

normalize_content_type/1

normalize_content_type(Type) -> any()

parse_header/1

parse_header(String::binary()) -> {binary(), [{binary(), binary()}]}

Parse a Content-Type like header, return the main Content-Type and a property list of options.

parse_qs/1

parse_qs(Qs::binary()) -> [{binary(), binary()}]

Parse an application/x-www-form-urlencoded string.

quoted_string/1

quoted_string(Str::binary()) -> binary()

split_quoted_strings/1

split_quoted_strings(Str::binary()) -> [binary()]


Generated by EDoc