diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-01-05 11:47:03 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-01-05 22:39:17 -0800 |
| commit | bce6a79fc55852032e9d653b099a121353aaa238 (patch) | |
| tree | 6e6aa44e73ea7e671a50103539c55443df8c4dc2 /src/supplemental/http/http_msg.h | |
| parent | d31844817a5b304a894c5b963cd52aeb9e47c627 (diff) | |
| download | nng-bce6a79fc55852032e9d653b099a121353aaa238.tar.gz nng-bce6a79fc55852032e9d653b099a121353aaa238.tar.bz2 nng-bce6a79fc55852032e9d653b099a121353aaa238.zip | |
http: changing transaction API to inline req and res structures
This is a step towards simplifying this API and ultimately simplifying
the HTTP callback API used for the server side.
Diffstat (limited to 'src/supplemental/http/http_msg.h')
| -rw-r--r-- | src/supplemental/http/http_msg.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/supplemental/http/http_msg.h b/src/supplemental/http/http_msg.h new file mode 100644 index 00000000..7d9e7dcf --- /dev/null +++ b/src/supplemental/http/http_msg.h @@ -0,0 +1,57 @@ +// +// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2018 Capitar IT Group BV <info@capitar.com> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#ifndef NNG_SUPPLEMENTAL_HTTP_HTTP_MSG +#define NNG_SUPPLEMENTAL_HTTP_HTTP_MSG + +#include "core/defs.h" +#include "core/list.h" + +// Note that as we parse headers, the rule is that if a header is already +// present, then we can append it to the existing header, separated by +// a comma. From experience, for example, Firefox uses a Connection: +// header with two values, "keepalive", and "upgrade". +typedef struct http_header { + char *name; + char *value; + nni_list_node node; +} http_header; + +typedef struct nni_http_entity { + char *data; + size_t size; // allocated/expected size + size_t len; // current length + bool own; // if true, data is "ours", and should be freed +} nni_http_entity; + +struct nng_http_req { + nni_list hdrs; + nni_http_entity data; + char meth[32]; + char *uri; + const char *vers; + char *buf; + size_t bufsz; + bool parsed; +}; + +struct nng_http_res { + nni_list hdrs; + nni_http_entity data; + uint16_t code; + char *rsn; + const char *vers; + char *buf; + size_t bufsz; + bool parsed; + bool iserr; +}; + +#endif |
