feat(lnm): move request data to separate buffer if read buffer changes
This commit is contained in:
parent
d53a949946
commit
8bdf52da0d
6 changed files with 88 additions and 24 deletions
|
|
@ -13,24 +13,39 @@
|
|||
#define LNM_HTTP_MAX_REQ_HEADERS 32
|
||||
#define LNM_HTTP_MAX_REGEX_GROUPS 4
|
||||
|
||||
typedef struct lnm_http_req_header {
|
||||
struct {
|
||||
size_t o;
|
||||
size_t len;
|
||||
} name;
|
||||
struct {
|
||||
size_t o;
|
||||
size_t len;
|
||||
} value;
|
||||
} lnm_http_req_header;
|
||||
|
||||
/**
|
||||
* Represents the parsed HTTP request
|
||||
*/
|
||||
typedef struct lnm_http_req {
|
||||
size_t len;
|
||||
struct {
|
||||
char *s;
|
||||
size_t len;
|
||||
bool owned;
|
||||
} buf;
|
||||
int minor_version;
|
||||
lnm_http_method method;
|
||||
struct {
|
||||
const char *s;
|
||||
size_t o;
|
||||
size_t len;
|
||||
regmatch_t groups[LNM_HTTP_MAX_REGEX_GROUPS];
|
||||
} path;
|
||||
struct {
|
||||
const char *s;
|
||||
size_t o;
|
||||
size_t len;
|
||||
} query;
|
||||
struct {
|
||||
struct phr_header arr[LNM_HTTP_MAX_REQ_HEADERS];
|
||||
lnm_http_req_header arr[LNM_HTTP_MAX_REQ_HEADERS];
|
||||
size_t len;
|
||||
} headers;
|
||||
struct {
|
||||
|
|
@ -68,6 +83,9 @@ void lnm_http_req_reset(lnm_http_req *req);
|
|||
/**
|
||||
* Retrieve a specific header from the request.
|
||||
*
|
||||
* Pointers retrieved from this function should never be used between step
|
||||
* functions; simply request the header again if you need to.
|
||||
*
|
||||
* @param out where to write pointer to header value
|
||||
* @param out_len where to store length of out value
|
||||
* @param req request to look for header in
|
||||
|
|
@ -79,6 +97,9 @@ lnm_err lnm_http_req_header_get(const char **out, size_t *out_len,
|
|||
/**
|
||||
* Retrieve a specific header from the request by specifying its name.
|
||||
*
|
||||
* Pointers retrieved from this function should never be used between step
|
||||
* functions; simply request the header again if you need to.
|
||||
*
|
||||
* @param out where to write pointer to header value
|
||||
* @param out_len where to store length of out value
|
||||
* @param req request to look for header in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue