proto_http.h File Reference

Header for proto_http.c. More...

Go to the source code of this file.


int fetch_from_buf_http (struct buf_t *buf, char **headers_out, size_t max_headerlen, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete)
int peek_buf_has_http_command (const struct buf_t *buf)

Detailed Description

Header for proto_http.c.

Definition in file proto_http.h.

Function Documentation

◆ fetch_from_buf_http()

int fetch_from_buf_http ( buf_t *  buf,
char **  headers_out,
size_t  max_headerlen,
char **  body_out,
size_t *  body_used,
size_t  max_bodylen,
int  force_complete 

There is a (possibly incomplete) http statement on buf, of the form "\%s\\r\\n\\r\\n\%s", headers, body. (body may contain NULs.) If a) the headers include a Content-Length field and all bytes in the body are present, or b) there's no Content-Length field and all headers are present, then:

  • strdup headers into *headers_out, and NUL-terminate it.
  • memdup body into *body_out, and NUL-terminate it.
  • Then remove them from buf, and return 1.
  • If headers or body is NULL, discard that part of the buf.
  • If a headers or body doesn't fit in the arg, return -1. (We ensure that the headers or body don't exceed max len, even if we're planning to discard them.)
  • If force_complete is true, then succeed even if not all of the content has arrived.

Else, change nothing and return 0.

Definition at line 50 of file proto_http.c.

Referenced by connection_fetch_from_buf_http(), connection_read_https_proxy_response(), and metrics_connection_process_inbuf().