-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_client.h
More file actions
40 lines (32 loc) · 1.3 KB
/
Copy pathhttp_client.h
File metadata and controls
40 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
// ========= Includes Essenciais =========
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lwip/err.h"
#include "lwip/tcp.h"
#include "lwip/dns.h"
#include "pico/cyw43_arch.h"
// Strutura para armazenar o estado de uma requisição HTTP
typedef struct HTTP_REQUEST_STATE_T {
char *request;
char *host;
uint16_t port;
struct tcp_pcb *pcb;
ip_addr_t remote_addr;
} HTTP_REQUEST_STATE;
// ========= Funções Auxiliares =========
static err_t http_client_recv_cb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
static err_t http_client_connected_cb(void *arg, struct tcp_pcb *tpcb, err_t err);
static void http_client_err_cb(void *arg, err_t err);
static err_t http_client_sent_cb(void *arg, struct tcp_pcb *tpcb, u16_t len);
static void http_client_close(HTTP_REQUEST_STATE *state);
// ========= Protótipos das Funções =========
// Inicia uma requisição HTTP GET.
err_t http_get_request(const char *host, const char *path, uint16_t port);
// Inicia uma requisição HTTP POST.
err_t http_post_request(const char *host, const char *path, uint16_t port, const char *data);
// Incia uma requisição HTTP PATCH.
err_t http_patch_request(const char *host, const char *path, uint16_t port, const char *data);
#endif // HTTP_CLIENT_H