aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http_msg.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-06 15:20:09 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-09 23:22:56 -0800
commit73f50e2679525e7df8734c875a3c12732565f953 (patch)
tree23bd167dfcd95305b58a29c142b51879011f63b2 /src/supplemental/http/http_msg.h
parenta381af4f5ca79576a4a9b461529a0f22fcf1e088 (diff)
downloadnng-http-client-trans.tar.gz
nng-http-client-trans.tar.bz2
nng-http-client-trans.zip
http: The big HTTP API refactoring of January 2025.v2.0.0-alpha.3http-client-trans
This represents a major change in the HTTP code base, consisting of a complete revamp of the HTTP API. The changes here are too numerous to mention, but the end result should be a vastly simpler API for both server and client applications. Many needless allocations were removed by providing fixed buffers for various parameters and headers when possible. A few bugs were fixed. Most especially we have fixed some bugs around very large URIs and headers, and we have also addressed conformance bugs to more closely conform to RFCs 9110 and 9112. As part of this work, the APIs for WebSockets changed slightly as well. In particular the properties available for accessing headers have changed. There is still documentation conversion work to do, and additional functionality (such as proper support for chunked transfers), but this is a big step in the right direction.
Diffstat (limited to 'src/supplemental/http/http_msg.h')
-rw-r--r--src/supplemental/http/http_msg.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/supplemental/http/http_msg.h b/src/supplemental/http/http_msg.h
index 7d9e7dcf..e08dab8a 100644
--- a/src/supplemental/http/http_msg.h
+++ b/src/supplemental/http/http_msg.h
@@ -22,36 +22,45 @@ typedef struct http_header {
char *name;
char *value;
nni_list_node node;
+ bool static_name : 1; // name is static, do not free it
+ bool static_value : 1; // value is static, do not free it
+ bool alloc_header : 1; // header is heap allocated
} http_header;
+typedef struct http_header nni_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
+ char *data;
+ size_t size;
+ bool own; // if true, data is "ours", and should be freed
+ char clen[24]; // 64-bit lengths, in decimal
+ char ctype[128]; // 63+63+; per RFC 6838
+ http_header content_type;
+ http_header content_length;
+ nni_list hdrs;
+ char *buf;
+ size_t bufsz;
+ bool parsed;
} nni_http_entity;
struct nng_http_req {
- nni_list hdrs;
nni_http_entity data;
char meth[32];
+ char host[260]; // 253 per IETF, plus 6 for :port plus null
+ char ubuf[200]; // Most URIs are smaller than this
char *uri;
const char *vers;
- char *buf;
- size_t bufsz;
- bool parsed;
+ http_header host_header;
};
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;
+ http_header location;
};
+extern void nni_http_free_header(http_header *);
+
#endif