Module httoolsp.headers

Submodule for headers manipulation

Functions

parse_header(header) Parse a header into a main value and a table of parameters.
parse_accept_header(header, strict) Parse accept header and return instance of AcceptHeader.

Class AcceptHeader

AcceptHeader\get_weight(media_type) Get weight of passed media type.
AcceptHeader\negotiate(media_types) Get "best" media type and its weight.


Functions

parse_header(header)
Parse a header into a main value and a table of parameters. This function is partially based on cgi.parse_header from CPython.

Parameters:

  • header string

Returns:

  1. string main value
  2. table table of parameters
parse_accept_header(header, strict)
Parse accept header and return instance of AcceptHeader.

Parameters:

  • header string
  • strict optional bool enable strict mode. Default is false.

Returns:

    table AcceptHeader instance

Or

  1. nil
  2. string error message

Class AcceptHeader

A class representing parsed accept header. Cannot be instantiated directly, use parse_accept_header.
AcceptHeader\get_weight(media_type)
Get weight of passed media type. Returns nil if media type is not accepted.

Parameters:

  • media_type string media type

Returns:

    float weight

Or

    nil
AcceptHeader\negotiate(media_types)
Get "best" media type and its weight. Returns nil if no media type is accepted.

Parameters:

  • media_types table array of media types

Returns:

  1. string media type
  2. float weight

Or

    nil
generated by LDoc 1.4.6 Last updated 2020-02-26 02:04:34