HTTP messages (response and request)

Author(s): The Ciao Development Team.

Parser/printer for HTTP response and request messages.

See RFC2616 for a reference of HTTP/1.1 protocol.

The request and response objects are represented as list of terms, which represent HTTP header fields and other elements (such as the status, and contents).

The current list of request headers is:

  • method(Method): Method is the HTTP method in lowercase (head, get, post, etc.).

  • timeout(T): T specifies the time in seconds to wait for the response. Default is 300 seconds.

  • if_modified_since(Date): Get document only if newer than Date. Date has the format defined by http_date/1.

  • user_agent(Agent): Provides a user-agent field, Agent is an atom.

  • authorization(Scheme,Params): To provide credentials. See RFC 1945 for details.

  • option(Value): Any unary term, being Value an atom, can be used to provide another valid option (e.g. from('user@machine')).

The current list of response headers is:

  • status(Type,Code,Reason): Type is an atom denoting the response type, Code is the status code (an integer), and Reason is a string holding the reason phrase.

  • date(Date): Date is the date of the response, with format defined by http_date/1.

  • location(Loc): This parameter appears when the document has moved, Loc is an atom holding the new location.

  • server(Server): Server is the server responding, as an atom.

  • www_authenticate(Params): Returned if document is protected, Params is a list of chagenges. See RFC 1945 for details.

  • allow(Methods): Methods are the methods allowed by the server, as a list of atoms.

  • content_encoding(Encoding): Encoding is an atom defining the encoding.

  • expires(Date): Date is the date after which the entity should be considered stale. Format defined by http_date/1.

  • last_modified(Date): Date is the date at which the sender believes the resource was last modified. Format defined by http_date/1.

  • pragma(String): Miscellaneous data.

  • header(String): Any other functor header/1 is an extension header.

The current list of some common headers is:

  • content_length(Length): Length is the length of the document (an integer).

  • content_type(Type,Subtype,Params): Specifies the document content type, Type and Subtype are atoms, Params a list of parameters (e.g. content_type(text,html,[])).

  • content(Bytes): Bytes is the document content (bytelist/1). If method(head) of the HTTP request is used, an empty list is get here.

Usage and interface

Documentation on exports


Request is a parameter of an HTTP request.

    Usage 1:http_request_str(RequestURI,Request,RequestBytes,RequestBytesTail)

    Parse a string into an HTTP request

    Usage 2:http_request_str(RequestURI,Request,RequestBytes,RequestBytesTail)

    Generate an HTTP request from a list of parameters

    No further documentation available for this predicate.


    Response is a parameter of an HTTP response.

      No further documentation available for this predicate.

      Documentation on imports

      This module has the following direct dependencies: