mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
uridecoding lws_hdr_fragment_length
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
ab5ed3c8e1
commit
e974f0c252
2 changed files with 33 additions and 1 deletions
|
@ -1556,11 +1556,25 @@ lws_b64_decode_string(const char *in, char *out, int out_size);
|
|||
LWS_VISIBLE LWS_EXTERN const char *
|
||||
lws_get_library_version(void);
|
||||
|
||||
/* access to headers... only valid while headers valid */
|
||||
/*
|
||||
* Access to http headers
|
||||
*
|
||||
* In lws the client http headers are temporarily malloc'd only for the
|
||||
* duration of the http part of the handshake. It's because in most cases,
|
||||
* the header content is ignored for the whole rest of the connection lifetime
|
||||
* and would then just be taking up space needlessly.
|
||||
*
|
||||
* During LWS_CALLBACK_HTTP when the URI path is delivered is the last time
|
||||
* the http headers are still allocated, you can use these apis then to
|
||||
* look at and copy out interesting header content (cookies, etc)
|
||||
*/
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx);
|
||||
|
||||
/*
|
||||
* copies the whole, aggregated header, even if it was delivered in
|
||||
* several actual headers piece by piece
|
||||
|
@ -1577,6 +1591,7 @@ LWS_VISIBLE LWS_EXTERN int
|
|||
lws_hdr_copy_fragment(struct lws *wsi, char *dest, int len,
|
||||
enum lws_token_indexes h, int frag_idx);
|
||||
|
||||
|
||||
/* get the active file operations struct */
|
||||
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *
|
||||
lws_get_fops(struct lws_context *context);
|
||||
|
|
|
@ -81,6 +81,23 @@ int lws_free_header_table(struct lws *wsi)
|
|||
return 0;
|
||||
};
|
||||
|
||||
LWS_VISIBLE int
|
||||
lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = wsi->u.hdr.ah->frag_index[h];
|
||||
if (!n)
|
||||
return 0;
|
||||
do {
|
||||
if (!frag_idx)
|
||||
return wsi->u.hdr.ah->frags[n].len;
|
||||
n = wsi->u.hdr.ah->frags[n].nfrag;
|
||||
} while (frag_idx-- && n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LWS_VISIBLE int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h)
|
||||
{
|
||||
int n;
|
||||
|
|
Loading…
Add table
Reference in a new issue