mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-17 20:24:24 +00:00
http client: add https support, fix parsing header with chained pbufs
This commit is contained in:
parent
e87392cc85
commit
bd656efd64
@ -288,7 +288,7 @@ httpc_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t r)
|
|||||||
}
|
}
|
||||||
if (req->parse_state == HTTPC_PARSE_WAIT_HEADERS) {
|
if (req->parse_state == HTTPC_PARSE_WAIT_HEADERS) {
|
||||||
u16_t total_header_len;
|
u16_t total_header_len;
|
||||||
err_t err = http_wait_headers(p, &req->hdr_content_len, &total_header_len);
|
err_t err = http_wait_headers(req->rx_hdrs, &req->hdr_content_len, &total_header_len);
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
/* hide header bytes in pbuf */
|
/* hide header bytes in pbuf */
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
@ -536,6 +536,16 @@ httpc_init_connection_common(httpc_state_t **connection, const httpc_connection_
|
|||||||
httpc_free_state(req);
|
httpc_free_state(req);
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
|
#if LWIP_ALTCP_TLS
|
||||||
|
if (settings->tls_config) {
|
||||||
|
struct altcp_pcb *pcbs = altcp_tls_new(settings->tls_config, req->pcb);
|
||||||
|
if (pcbs == NULL) {
|
||||||
|
httpc_free_state(req);
|
||||||
|
return ERR_MEM;
|
||||||
|
}
|
||||||
|
req->pcb = pcbs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
req->remote_port = settings->use_proxy ? settings->proxy_port : server_port;
|
req->remote_port = settings->use_proxy ? settings->proxy_port : server_port;
|
||||||
altcp_arg(req->pcb, req);
|
altcp_arg(req->pcb, req);
|
||||||
altcp_recv(req->pcb, httpc_tcp_recv);
|
altcp_recv(req->pcb, httpc_tcp_recv);
|
||||||
|
@ -109,6 +109,10 @@ typedef struct _httpc_connection {
|
|||||||
u8_t use_proxy;
|
u8_t use_proxy;
|
||||||
/* @todo: add username:pass? */
|
/* @todo: add username:pass? */
|
||||||
|
|
||||||
|
#if LWIP_ALTCP_TLS
|
||||||
|
struct altcp_tls_config *tls_config;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* this callback is called when the transfer is finished (or aborted) */
|
/* this callback is called when the transfer is finished (or aborted) */
|
||||||
httpc_result_fn result_fn;
|
httpc_result_fn result_fn;
|
||||||
/* this callback is called after receiving the http headers
|
/* this callback is called after receiving the http headers
|
||||||
|
Loading…
Reference in New Issue
Block a user