phr_decode_chunked
- a function for decoding chunked-encoded input - to picohttpparser.As suggested in the doc-comment of the function (shown below), the function is designed to decode the data in-place. In other words, it is not copy-less.
/* the function rewrites the buffer given as (buf, bufsz) removing the chunked- * encoding headers. When the function returns without an error, bufsz is * updated to the length of the decoded data available. Applications should * repeatedly call the function while it returns -2 (incomplete) every time * supplying newly arrived data. If the end of the chunked-encoded data is * found, the function returns a non-negative number indicating the number of * octets left undecoded at the tail of the supplied buffer. Returns -1 on * error. */ ssize_t phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, size_t *bufsz);It is intentionally designed as such.
Consider a input like the following. The example is more than 2MB long even though it contains only 2 bytes of data. The input is conformant to the HTTP/1.1 specification since it does not define the maximum length of the chunked extensions, requires every conforming implementation to ignore unknown extensions.
1 very-very-veery long extension that lasts ...(snip) 1MB a 1 very-very-veery long extension that lasts ...(snip) 1MB aTo handle such input without getting the memory exhausted, a decoder should either a) only preserve the decoded data (requires a copy), or b) limit the size of the chunked-encoded data.
B might have been easier to implement, but such a feature might be difficult to administer. So I decided to take the route a, and for simplicity implemented the decoder to always adjust the position of the data in-place.
Always calling
memmove
for adjusting the position might induce some overhead, but I assume it to be negligible for two reasons: both the source and destination would exist in the CPU cache / the overhead of unaligned memory access is small on recent Intel CPU.For ease-of-use, I have added examples to the README.
timberland boots outlet
ReplyDeletelongchamp sale
pandora charms sale clearance
polo ralph lauren
true religion jeans outlet
uggs outlet
hermes bags
longchamp bag
oakley sunglasses outlet
ysl outlet store
zhi20161216
تور تایلند
ReplyDelete20170613 junda
ReplyDeletecheap oakley sunglasses
lacoste outlet
coach outlet
nike air max 1
michael kors outlet online
ray ban sunglasses uk
true religion outlet
swarovski jewelry
nike roshe run
ralph lauren?uk
IPL 2018 Online Stream
ReplyDeleteIPL Live Stream Free
IPL 2018
Vivo IPL Live
Vivo IPL Live Stream
IPL 2018 Live
IPL Live Streaming
IPL 2018 Live Stream
This comment has been removed by the author.
ReplyDeletecoach outlet online
ReplyDeletefitflops sale clearance
adidas outlet online
cheap jordan shoes
nike outlet
birkenstock outlet
ferragamo shoes
私服发布
basketball shoes
cheap jordans
coach outlet
golden goose sneakers
reebok outlet store
christian louboutin outlet
christian louboutin outlet
mowang05-20
I'm shakshi.I am working in India top most Escort service Mumbai Call girls.If u want to join the all facility of escorts Puri call girls
ReplyDeletepls call me & whatssap Cuttack call girls
visit the sites. Bhubaneswar call girls or follow me. jaipur call girls
please visit @ agen bola dengan komisi terbesar cek disini
ReplyDeleteNice post
ReplyDeletehow long does your hair have to be to braid for guys
How to strengthen weak hair
Katy Perry puts on no makeup
apohair
Vietnamese hair extensions
What a way to express things. I have found comfort in reading this post and i am sure other users may feel the same, because this post carries a social message in it. Keep it up ! Regards:-
ReplyDeleteoffice.com/setup | norton.com/setup | mcafee.com/activate