Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
HTTP client API

HTTP client API. More...

Data Structures

struct  http_response
 HTTP response from the server. More...
 
struct  http_client_internal_data
 HTTP client internal data that the application should not touch. More...
 
struct  http_request
 HTTP client request. More...
 

Typedefs

typedef int(* http_payload_cb_t) (int sock, struct http_request *req, void *user_data)
 Callback used when data needs to be sent to the server.
 
typedef int(* http_header_cb_t) (int sock, struct http_request *req, void *user_data)
 Callback can be used if application wants to construct additional HTTP headers when the HTTP request is sent.
 
typedef void(* http_response_cb_t) (struct http_response *rsp, enum http_final_call final_data, void *user_data)
 Callback used when data is received from the server.
 

Enumerations

enum  http_final_call { HTTP_DATA_MORE = 0 , HTTP_DATA_FINAL = 1 }
 Is there more data to come. More...
 

Functions

int http_client_req (int sock, struct http_request *req, int32_t timeout, void *user_data)
 Do a HTTP request.
 

Detailed Description

HTTP client API.

Since
2.1
Version
0.2.0

Typedef Documentation

◆ http_header_cb_t

http_header_cb_t

#include <include/zephyr/net/http/client.h>

Callback can be used if application wants to construct additional HTTP headers when the HTTP request is sent.

Usage of this is optional.

Parameters
sockSocket id of the connection
reqHTTP request information
user_dataUser specified data specified in http_client_req()
Returns
>=0 amount of data sent, in this case http_client_req() should continue sending data, <0 if http_client_req() should return the error code to the caller.

◆ http_payload_cb_t

http_payload_cb_t

#include <include/zephyr/net/http/client.h>

Callback used when data needs to be sent to the server.

Parameters
sockSocket id of the connection
reqHTTP request information
user_dataUser specified data specified in http_client_req()
Returns
>=0 amount of data sent, in this case http_client_req() should continue sending data, <0 if http_client_req() should return the error code to the caller.

◆ http_response_cb_t

http_response_cb_t

#include <include/zephyr/net/http/client.h>

Callback used when data is received from the server.

Parameters
rspHTTP response information
final_dataDoes this data buffer contain all the data or is there still more data to come.
user_dataUser specified data specified in http_client_req()

Enumeration Type Documentation

◆ http_final_call

#include <include/zephyr/net/http/client.h>

Is there more data to come.

Enumerator
HTTP_DATA_MORE 

More data will come.

HTTP_DATA_FINAL 

End of data.

Function Documentation

◆ http_client_req()

int http_client_req ( int  sock,
struct http_request req,
int32_t  timeout,
void *  user_data 
)

#include <include/zephyr/net/http/client.h>

Do a HTTP request.

The callback is called when data is received from the HTTP server. The caller must have created a connection to the server before calling this function so connect() call must have be done successfully for the socket.

Parameters
sockSocket id of the connection.
reqHTTP request information
timeoutMax timeout to wait for the data. The timeout value cannot be 0 as there would be no time to receive the data. The timeout value is in milliseconds.
user_dataUser specified data that is passed to the callback.
Returns
<0 if error, >=0 amount of data sent to the server