Copyright © (C) 2015-2020, Jan Henry Nystrom <JanHenryNystrom@gmail.com> -------------------------------------------------------------------
Authors: Jan Henry Nystrom (JanHenryNystrom@gmail.com).
A simple HTTP client based on: Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing (rfc7230) Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content (rfc7231) The Hypertext Transfer Protocol Status Code 308 (Permanent Redirect) (rfc7538) PATCH Method for HTTP (rfc5789) HTTP Over TLS (rfc2818)
Options that are available to open/1, open/2 and all HTTP method functions: timeout -> the time in milliseconds the request is allowed to complete limit -> the endtime for the request as system_time in milliseconds headers -> a map of HTTP headers where the headers name can be an atom or binary and the value a binary options -> options to the transport's (tcp or ssl) connection function redirect -> a boolean that determines if redirect are automatically followed for status codes 301, 302, 303, 307, 308 and in the case of 303 use the GET as the method close -> a boolean that determines if the connection should be closed by this client upon completion of the function connection -> if present provides an already established connection to server that will be used for the request
Returned by open/1, open/2 and all HTTP method functions is a map with: status -> {Code, Text} where the code is an integer and Text a binary headers -> a map of HTTP headers from the server reply, recognised names ones are returned as atoms body -> the body of the server reply as a binary, possibly empty connection -> present if neither the server ot the client closed the connection, the value is opaque and should used in later HTTP mehod calls
N.B. The established connections do not time out, if not closed explicitly they will remain and cause a resource leak. For HTTPS requires the ssl OTP lib which is not included in the application resource file. Only supports R18 and later.abstract datatype: connection()
method() = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE'
close/1 | Closes an already established connection. |
connect/1 | Performs the CONNECT HTTP method. |
connect/2 | Performs the CONNECT HTTP method. |
delete/1 | Performs the DELETE HTTP method. |
delete/2 | Performs the DELET HTTP method. |
get/1 | Performs the GET HTTP method. |
get/2 | Performs the GET HTTP method. |
head/1 | Performs the HEAD HTTP method. |
head/2 | Performs the HEAD HTTP method. |
open/1 | Opens a connection for later use, uses the HTTP HEAD method. |
open/2 | Opens a connection for later use, uses the HTTP Method. |
options/1 | Performs the OPTIONS HTTP method. |
options/2 | Performs the OPTIONS HTTP method. |
patch/2 | Performs the PATCH HTTP method. |
patch/3 | Performs the PATCH HTTP method. |
post/2 | Performs the POST HTTP method. |
post/3 | Performs the POST HTTP method. |
put/1 | Performs the PUT HTTP method. |
put/2 | Performs the PUT HTTP method. |
put/3 | Performs the PUT HTTP method. |
trace/1 | Performs the TRACE HTTP method. |
trace/2 | Performs the TRACE HTTP method. |
close(Connection::connection()) -> ok | {error, term()}
Closes an already established connection.
connect(URL::iodata()) -> map() | {error, term()}
Performs the CONNECT HTTP method
connect(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the CONNECT HTTP method
delete(URL::iodata()) -> map() | {error, term()}
Performs the DELETE HTTP method
delete(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the DELET HTTP method
get(URL::iodata()) -> map() | {error, term()}
Performs the GET HTTP method
get(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the GET HTTP method
head(URL::iodata()) -> map() | {error, term()}
Performs the HEAD HTTP method
head(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the HEAD HTTP method
open(URL::iodata()) -> connection() | {error, term()}
Opens a connection for later use, uses the HTTP HEAD method.
open(URL::iodata(), Method::method()) -> connection() | {error, term()}
Opens a connection for later use, uses the HTTP Method.
options(URL::iodata()) -> map() | {error, term()}
Performs the OPTIONS HTTP method
options(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the OPTIONS HTTP method
patch(URL::iodata(), Body::iodata()) -> map() | {error, term()}
Performs the PATCH HTTP method
patch(URL::iodata(), Body::iodata(), Opts::map()) -> map() | {error, term()}
Performs the PATCH HTTP method
post(URL::iodata(), Body::iodata()) -> map() | {error, term()}
Performs the POST HTTP method
post(URL::iodata(), Body::iodata(), Opts::map()) -> map() | {error, term()}
Performs the POST HTTP method
put(URL::iodata()) -> map() | {error, term()}
Performs the PUT HTTP method
put(URL::iodata(), Body::iodata()) -> map() | {error, term()}
Performs the PUT HTTP method
put(URL::iodata(), Body::iodata(), Opts::map()) -> map() | {error, term()}
Performs the PUT HTTP method
trace(URL::iodata()) -> map() | {error, term()}
Performs the TRACE HTTP method
trace(URL::iodata(), Opts::map()) -> map() | {error, term()}
Performs the TRACE HTTP method
Generated by EDoc