Module hb_http.erl¶
Function Index¶
accept_to_codec/2 | Calculate the codec name to use for a reply given its initiating Cowboy request, the parsed TABM request, and the response message. |
add_cors_headers/3* | Add permissive CORS headers to a message, if the message has not already specified CORS headers. |
allowed_status/2* | Check if a status is allowed, according to the configuration. |
ans104_wasm_test/0* | |
codec_to_content_type/2* | Call the content-type key on a message with the given codec, using
a fast-path for options that are not needed for this one-time lookup. |
cors_get_test/0* | |
default_codec/1* | Return the default codec for the given options. |
empty_inbox/1* | Empty the inbox of the current process for all messages with the given reference. |
encode_reply/4* | Generate the headers and body for a HTTP response message. |
get/2 | Gets a URL via HTTP and returns the resulting message in deserialized form. |
get/3 | |
get_deep_signed_wasm_state_test/0* | |
get_deep_unsigned_wasm_state_test/0* | |
http_response_to_httpsig/4* | Convert a HTTP response to a httpsig message. |
httpsig_to_tabm_singleton/3* | HTTPSig messages are inherently mixed into the transport layer, so they require special handling in order to be converted to a normalized message. |
index_request_test/0* | |
index_test/0* | |
message_to_request/2 | Given a message, return the information needed to make the request. |
mime_to_codec/2* | Find a codec name from a mime-type. |
multirequest/5* | Dispatch the same HTTP request to many nodes. |
multirequest_opt/5* | Get a value for a multirequest option from the config or message. |
multirequest_opts/3* | Get the multirequest options from the config or message. |
nested_ao_resolve_test/0* | |
normalize_unsigned/3* | Add the method and path to a message, if they are not already present. |
parallel_multirequest/8* | Dispatch the same HTTP request to many nodes in parallel. |
parallel_responses/7* | Collect the necessary number of responses, and stop workers if configured to do so. |
post/3 | Posts a message to a URL on a remote peer via HTTP. |
post/4 | |
prepare_request/6* | Turn a set of request arguments into a request message, formatted in the preferred format. |
remove_unless_signed/3* | Remove all keys from the message unless they are signed. |
reply/4 | Reply to the client's HTTP request with a message. |
reply/5* | |
req_to_tabm_singleton/3 | Convert a cowboy request to a normalized message. |
request/2 | Posts a binary to a URL on a remote peer via HTTP, returning the raw binary body. |
request/4 | |
request/5 | |
route_to_request/3* | Parse a dev_router:route response and return a tuple of request
parameters. |
run_wasm_signed_test/0* | |
run_wasm_unsigned_test/0* | |
send_large_signed_request_test/0* | |
serial_multirequest/7* | Serially request a message, collecting responses until the required number of responses have been gathered. |
simple_ao_resolve_signed_test/0* | |
simple_ao_resolve_unsigned_test/0* | |
start/0 | |
wasm_compute_request/3* | |
wasm_compute_request/4* |
Function Details¶
accept_to_codec/2¶
accept_to_codec(TABMReq, Opts) -> any()
Calculate the codec name to use for a reply given its initiating Cowboy
request, the parsed TABM request, and the response message. The precidence
order for finding the codec is:
1. The accept-codec
field in the message
2. The accept
field in the request headers
3. The default codec
Options can be specified in mime-type format (application/*
) or in
AO device format (device@1.0
).
add_cors_headers/3 *¶
add_cors_headers(Msg, ReqHdr, Opts) -> any()
Add permissive CORS headers to a message, if the message has not already specified CORS headers.
allowed_status/2 *¶
allowed_status(ResponseMsg, Statuses) -> any()
Check if a status is allowed, according to the configuration.
ans104_wasm_test/0 *¶
ans104_wasm_test() -> any()
codec_to_content_type/2 *¶
codec_to_content_type(Codec, Opts) -> any()
Call the content-type
key on a message with the given codec, using
a fast-path for options that are not needed for this one-time lookup.
cors_get_test/0 *¶
cors_get_test() -> any()
default_codec/1 *¶
default_codec(Opts) -> any()
Return the default codec for the given options.
empty_inbox/1 *¶
empty_inbox(Ref) -> any()
Empty the inbox of the current process for all messages with the given reference.
encode_reply/4 *¶
encode_reply(Status, TABMReq, Message, Opts) -> any()
Generate the headers and body for a HTTP response message.
get/2¶
get(Node, Opts) -> any()
Gets a URL via HTTP and returns the resulting message in deserialized form.
get/3¶
get(Node, PathBin, Opts) -> any()
get_deep_signed_wasm_state_test/0 *¶
get_deep_signed_wasm_state_test() -> any()
get_deep_unsigned_wasm_state_test/0 *¶
get_deep_unsigned_wasm_state_test() -> any()
http_response_to_httpsig/4 *¶
http_response_to_httpsig(Status, HeaderMap, Body, Opts) -> any()
Convert a HTTP response to a httpsig message.
httpsig_to_tabm_singleton/3 *¶
httpsig_to_tabm_singleton(Req, Body, Opts) -> any()
HTTPSig messages are inherently mixed into the transport layer, so they
require special handling in order to be converted to a normalized message.
In particular, the signatures are verified if present and required by the
node configuration. Additionally, non-committed fields are removed from the
message if it is signed, with the exception of the path
and method
fields.
index_request_test/0 *¶
index_request_test() -> any()
index_test/0 *¶
index_test() -> any()
message_to_request/2¶
message_to_request(M, Opts) -> any()
Given a message, return the information needed to make the request.
mime_to_codec/2 *¶
mime_to_codec(X1, Opts) -> any()
Find a codec name from a mime-type.
multirequest/5 *¶
multirequest(Config, Method, Path, Message, Opts) -> any()
Dispatch the same HTTP request to many nodes. Can be configured to await responses from all nodes or just one, and to halt all requests after after it has received the required number of responses, or to leave all requests running until they have all completed. Default: Race for first response.
Expects a config message of the following form: /Nodes/1..n: Hostname | #{ hostname => Hostname, address => Address } /Responses: Number of responses to gather /Stop-After: Should we stop after the required number of responses? /Parallel: Should we run the requests in parallel?
multirequest_opt/5 *¶
multirequest_opt(Key, Config, Message, Default, Opts) -> any()
Get a value for a multirequest option from the config or message.
multirequest_opts/3 *¶
multirequest_opts(Config, Message, Opts) -> any()
Get the multirequest options from the config or message. The options in the message take precidence over the options in the config.
nested_ao_resolve_test/0 *¶
nested_ao_resolve_test() -> any()
normalize_unsigned/3 *¶
normalize_unsigned(Req, Msg, Opts) -> any()
Add the method and path to a message, if they are not already present.
Remove browser-added fields that are unhelpful during processing (for example,
content-length
).
The precidence order for finding the path is:
1. The path in the message
2. The path in the request URI
parallel_multirequest/8 *¶
parallel_multirequest(Nodes, Responses, StopAfter, Method, Path, Message, Statuses, Opts) -> any()
Dispatch the same HTTP request to many nodes in parallel.
parallel_responses/7 *¶
parallel_responses(Res, Procs, Ref, Awaiting, StopAfter, Statuses, Opts) -> any()
Collect the necessary number of responses, and stop workers if configured to do so.
post/3¶
post(Node, Message, Opts) -> any()
Posts a message to a URL on a remote peer via HTTP. Returns the resulting message in deserialized form.
post/4¶
post(Node, Path, Message, Opts) -> any()
prepare_request/6 *¶
prepare_request(Format, Method, Peer, Path, RawMessage, Opts) -> any()
Turn a set of request arguments into a request message, formatted in the
preferred format. This function honors the accept-bundle
option, if it is
already present in the message, and sets it to true
if it is not.
remove_unless_signed/3 *¶
remove_unless_signed(Key, Msg, Opts) -> any()
Remove all keys from the message unless they are signed.
reply/4¶
reply(Req, TABMReq, Message, Opts) -> any()
Reply to the client's HTTP request with a message.
reply/5 *¶
reply(Req, TABMReq, BinStatus, RawMessage, Opts) -> any()
req_to_tabm_singleton/3¶
req_to_tabm_singleton(Req, Body, Opts) -> any()
Convert a cowboy request to a normalized message.
request/2¶
request(Message, Opts) -> any()
Posts a binary to a URL on a remote peer via HTTP, returning the raw binary body.
request/4¶
request(Method, Peer, Path, Opts) -> any()
request/5¶
request(Method, Config, Path, Message, Opts) -> any()
route_to_request/3 *¶
route_to_request(M, X2, Opts) -> any()
Parse a dev_router:route
response and return a tuple of request
parameters.
run_wasm_signed_test/0 *¶
run_wasm_signed_test() -> any()
run_wasm_unsigned_test/0 *¶
run_wasm_unsigned_test() -> any()
send_large_signed_request_test/0 *¶
send_large_signed_request_test() -> any()
serial_multirequest/7 *¶
serial_multirequest(Nodes, Remaining, Method, Path, Message, Statuses, Opts) -> any()
Serially request a message, collecting responses until the required number of responses have been gathered. Ensure that the statuses are allowed, according to the configuration.
simple_ao_resolve_signed_test/0 *¶
simple_ao_resolve_signed_test() -> any()
simple_ao_resolve_unsigned_test/0 *¶
simple_ao_resolve_unsigned_test() -> any()
start/0¶
start() -> any()
wasm_compute_request/3 *¶
wasm_compute_request(ImageFile, Func, Params) -> any()
wasm_compute_request/4 *¶
wasm_compute_request(ImageFile, Func, Params, ResultPath) -> any()