|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
HTTP transport API. More...
#include <zephyr/net/http/client_multiprotocol.h>
Data Fields | |
| bool | secure |
| Whether the transport is secured with TLS. | |
| void(* | init )(void *transport_ctx) |
| Initialize transport context. | |
| int(* | connect )(struct http_client *client) |
| Connect the transport layer. | |
| int(* | send )(struct http_client *client, void *stream, const uint8_t *data, size_t len, bool end_stream) |
| Send data over the transport layer. | |
| int(* | recv )(struct http_client *client, void **stream, uint8_t *buf, size_t bufsize, bool *end_stream) |
| Receive data from the transport layer. | |
| int(* | wait )(struct http_client *client, k_timeout_t timeout) |
| Wait for data to become available. | |
| void(* | stop )(struct http_client *client) |
| Stop reporting reception events. | |
| int(* | close )(struct http_client *client) |
| Disconnect the transport layer and release resources. | |
HTTP transport API.
| int(* http_client_transport_ops::close) (struct http_client *client) |
Disconnect the transport layer and release resources.
Called with the client lock released, once the session is closed and nothing is sent any more. A transport with a receive context of its own waits here for a notification already dispatched for the client to return, so that the client can be reinitialized or freed once http_client_disconnect() returns.
| client | HTTP client instance |
| int(* http_client_transport_ops::connect) (struct http_client *client) |
Connect the transport layer.
The function is expected to establish the connection. For an asynchronous session (http_client_session::async) it also sets up asynchronous reception and calls http_client_received_data() whenever data is available. A synchronous session receives on the calling thread through wait() and recv() instead.
| client | HTTP client instance |
| void(* http_client_transport_ops::init) (void *transport_ctx) |
Initialize transport context.
| transport_ctx | A pointer to the transport context to initialize |
| int(* http_client_transport_ops::recv) (struct http_client *client, void **stream, uint8_t *buf, size_t bufsize, bool *end_stream) |
Receive data from the transport layer.
The function is expected to be non-blocking, returning immediately with whatever data is currently available. If no data is available, the function should return -EAGAIN.
A multi-stream transport receives from the stream requested in stream, or from any stream when NULL is requested, and reports the stream the data came from in the same parameter. It may return -EAGAIN when the requested stream has no data even if other streams do. A single-stream transport ignores the request and reports NULL.
| client | HTTP client instance |
| stream | Transport stream to receive from on entry, the stream the data came from on return |
| buf | Buffer for the received data |
| bufsize | Size of the receive buffer |
| end_stream | Set when the peer ended the stream after the returned data. Never set by single-stream transports, which report 0 bytes instead. |
| bool http_client_transport_ops::secure |
Whether the transport is secured with TLS.
Selects the URL scheme (http or https) used in requests.
| int(* http_client_transport_ops::send) (struct http_client *client, void *stream, const uint8_t *data, size_t len, bool end_stream) |
Send data over the transport layer.
The function is expected to send all of the data requested, or fail. The sending is always blocking.
| client | HTTP client instance |
| stream | Transport stream to send on, NULL for the connection itself. A single-stream transport (TCP, TLS) is only ever asked to send on the connection. |
| data | Data to send |
| len | Length of the data to send |
| end_stream | Whether this is the last data sent on the stream. Ignored by single-stream transports. |
| void(* http_client_transport_ops::stop) (struct http_client *client) |
Stop reporting reception events.
Called when the session ends, before close, which may be left to a thread still sending on the transport. From then on nothing received is read. May be NULL.
| client | HTTP client instance |
| int(* http_client_transport_ops::wait) (struct http_client *client, k_timeout_t timeout) |
Wait for data to become available.
Used by synchronous sessions, which receive on the calling thread.
| client | HTTP client instance |
| timeout | Maximum time to wait |