pub fn execute(
request: impl Into<HttpRequest>,
) -> Result<HttpResponse, HttpError>
Expand description
Executes a single HTTP request and returns a result containing either an HttpResponse
or an HttpError
.
This function delegates the execution of the HTTP request to the underlying HttpClient
, which handles
the asynchronous sending of the request in the host runtime. From the perspective of the guest, this operation is blocking.
While awaiting the response, other tasks can be executed concurrently by the host thread.
§Arguments
request
- A reference to anHttpRequest
that encapsulates the HTTP method, URL, headers, body, and optional timeout settings for the request to be sent.
§Returns
This function returns a Result<HttpResponse, HttpError>
, which represents either the successful response from the server
(HttpResponse
) or an error that occurred during the execution of the HTTP request (HttpError
).