diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-11-01 23:41:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-11-02 20:57:08 -0700 |
| commit | db92342b43d429b8b07244cc003a8589a1b1c542 (patch) | |
| tree | 5624a3142b8309257ff523b0bf85343bee08033d /src/supplemental/http/http_api.h | |
| parent | 156604bd07ee60faa323968c71627f1c701b473a (diff) | |
| download | nng-db92342b43d429b8b07244cc003a8589a1b1c542.tar.gz nng-db92342b43d429b8b07244cc003a8589a1b1c542.tar.bz2 nng-db92342b43d429b8b07244cc003a8589a1b1c542.zip | |
fixes #682 Support for Chunked Transfer Coding
This is the client side only, although the work is structured to
support server applications. The chunked API is for now private,
although the intent to is to make it public for applications who
really want to use it.
Note that chunked transfer encoding puts data through extra copies.
First it copies through the buffering area (because I have to be able
to extract variable length strings from inside the data stream), and then
again to reassemble the chunks into a single unified object.
We do assume that the user wants the entire thing as a single object.
This means that using this to pull unbounded data will just silently
consume all memory. Use caution!
Diffstat (limited to 'src/supplemental/http/http_api.h')
| -rw-r--r-- | src/supplemental/http/http_api.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h index 14e842be..fdee70e9 100644 --- a/src/supplemental/http/http_api.h +++ b/src/supplemental/http/http_api.h @@ -27,6 +27,8 @@ typedef struct nng_http_conn nni_http_conn; typedef struct nng_http_handler nni_http_handler; typedef struct nng_http_server nni_http_server; typedef struct nng_http_client nni_http_client; +typedef struct nng_http_chunk nni_http_chunk; +typedef struct nng_http_chunks nni_http_chunks; // These functions are private to the internal framework, and really should // not be used elsewhere. @@ -46,6 +48,33 @@ extern int nni_http_res_parse(nni_http_res *, void *, size_t, size_t *); extern void nni_http_res_get_data(nni_http_res *, void **, size_t *); extern char *nni_http_res_headers(nni_http_res *); +// Chunked transfer encoding. For the moment this is not part of our public +// API. We can change that later. + +// nni_http_chunk_list_init creates a list of chunks, which shall not exceed +// the specified overall size. (Size 0 means no limit.) +extern int nni_http_chunks_init(nni_http_chunks **, size_t); + +extern void nni_http_chunks_free(nni_http_chunks *); + +// nni_http_chunk_iter iterates over all chunks in the list. +// Pass NULL for the last chunk to start at the head. Returns NULL when done. +extern nni_http_chunk *nni_http_chunks_iter( + nni_http_chunks *, nni_http_chunk *); + +// nni_http_chunk_list_size returns the combined size of all chunks in list. +extern size_t nni_http_chunks_size(nni_http_chunks *); + +// nni_http_chunk_size returns the size of given chunk. +extern size_t nni_http_chunk_size(nni_http_chunk *); +// nni_http_chunk_data returns a pointer to the data. +extern void *nni_http_chunk_data(nni_http_chunk *); + +extern int nni_http_chunks_parse(nni_http_chunks *, void *, size_t, size_t *); + +extern void nni_http_read_chunks( + nni_http_conn *, nni_http_chunks *, nni_aio *); + // Private to the server. (Used to support session hijacking.) extern void nni_http_conn_set_ctx(nni_http_conn *, void *); extern void *nni_http_conn_get_ctx(nni_http_conn *); |
