View Source jhn_shttpc (jhn_stdlib v5.0.6)
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.
Summary
Functions
Closes an already established connection.
Performs the CONNECT HTTP method
Performs the CONNECT HTTP method
Performs the DELETE HTTP method
Performs the DELET HTTP method
Performs the GET HTTP method
Performs the GET HTTP method
Performs the HEAD HTTP method
Performs the HEAD HTTP method
Opens a connection for later use, uses the HTTP HEAD method.
Opens a connection for later use, uses the HTTP Method.
Performs the OPTIONS HTTP method
Performs the OPTIONS HTTP method
Performs the PATCH HTTP method
Performs the PATCH HTTP method
Performs the POST HTTP method
Performs the POST HTTP method
Performs the PUT HTTP method
Performs the PUT HTTP method
Performs the PUT HTTP method
Performs the TRACE HTTP method
Performs the TRACE HTTP method
Types
-opaque connection()
-type method() :: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE'.
Functions
-spec close(connection()) -> ok | {error, _}.
Closes an already established connection.
Performs the CONNECT HTTP method
Performs the CONNECT HTTP method
Performs the DELETE HTTP method
Performs the DELET HTTP method
Performs the GET HTTP method
Performs the GET HTTP method
Performs the HEAD HTTP method
Performs the HEAD HTTP method
-spec open(iodata()) -> connection() | {error, _}.
Opens a connection for later use, uses the HTTP HEAD method.
-spec open(iodata(), method()) -> connection() | {error, _}.
Opens a connection for later use, uses the HTTP Method.
Performs the OPTIONS HTTP method
Performs the OPTIONS HTTP method
Performs the PATCH HTTP method
Performs the PATCH HTTP method
Performs the POST HTTP method
Performs the POST HTTP method
Performs the PUT HTTP method
Performs the PUT HTTP method
Performs the PUT HTTP method
Performs the TRACE HTTP method
Performs the TRACE HTTP method