antikythera v0.2.0 Antikythera.Httpc View Source

HTTP client library.

This is a wrapper around hackney, an HTTP client library. Httpc supports the following features:

  • gzip-compression is tranparently handled
  • headers are represented by maps instead of lists
  • header names are always lower case
  • TCP connections are automatically re-established when closed by server due to keepalive timeout (see #86169)

Body format

The body argument in post/4, put/4, patch/4, request/5 takes either:

  • binary - Sends raw data
  • {:form, [{key, value}]} - Sends key-value data as x-www-form-urlencoded
  • {:json, map} - Converts map into JSON and sends as application/json
  • {:file, path} - Sends given file contents

Options

  • :timeout - Timeout to establish a connection, in milliseconds. Default is 8000.
  • :recv_timeout - Timeout used when receiving a response. Default is 5000.
  • :params - An enumerable of 2-tuples that will be URL-encoded and appended to the URL as query string parameters.
  • :cookie - An enumerable of name-value pairs of cookies. Httpc automatically URL-encodes the given names/values for you.
  • :basic_auth - A pair of {username, password} tuple to be used for HTTP basic authentication.
  • :proxy - A proxy to be used for the request; it can be a regular URL or a {host, port} tuple.
  • :proxy_auth - Proxy authentication {username, password} tuple.
  • :ssl - SSL options supported by the ssl erlang module.
  • :skip_ssl_verification - Whether to verify server’s SSL certificate or not. Defaults to false. Specify skip_ssl_verification: true when accessing insecure server with HTTPS.
  • :max_body - Maximum content-length of the response body (compressed size if it’s compressed). Defaults to 10485760 (10MB) and must not exceed 100MB. Responses having body larger than the specified size will be rejected with {:error, :response_too_large}.
  • :follow_redirect - A boolean that causes redirects to be followed. Defaults to false.
  • :max_redirect - An integer denoting the maximum number of redirects to follow if follow_redirect: true is given.
  • :skip_body_decompression - By default gzip-compressed body is automatically decompressed (i.e. defaults to false). Pass skip_body_decompression: true if compressed body is what you need.

Link to this section Summary

Link to this section Functions