mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
uridecoding lws_hdr_fragment_length
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
0f8b1919ef
commit
00e5eb8658
2 changed files with 33 additions and 1 deletions
|
@ -1555,11 +1555,25 @@ lws_b64_decode_string(const char *in, char *out, int out_size);
|
||||||
LWS_VISIBLE LWS_EXTERN const char *
|
LWS_VISIBLE LWS_EXTERN const char *
|
||||||
lws_get_library_version(void);
|
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_VISIBLE LWS_EXTERN int
|
||||||
lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
|
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
|
* copies the whole, aggregated header, even if it was delivered in
|
||||||
* several actual headers piece by piece
|
* several actual headers piece by piece
|
||||||
|
@ -1576,6 +1590,7 @@ LWS_VISIBLE LWS_EXTERN int
|
||||||
lws_hdr_copy_fragment(struct lws *wsi, char *dest, int len,
|
lws_hdr_copy_fragment(struct lws *wsi, char *dest, int len,
|
||||||
enum lws_token_indexes h, int frag_idx);
|
enum lws_token_indexes h, int frag_idx);
|
||||||
|
|
||||||
|
|
||||||
/* get the active file operations struct */
|
/* get the active file operations struct */
|
||||||
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *
|
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *
|
||||||
lws_get_fops(struct lws_context *context);
|
lws_get_fops(struct lws_context *context);
|
||||||
|
|
|
@ -81,6 +81,23 @@ int lws_free_header_table(struct lws *wsi)
|
||||||
return 0;
|
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)
|
LWS_VISIBLE int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
Loading…
Add table
Reference in a new issue