Comments (5)
The rsize argument holds the actual length of what was decoded.
You have to limit printf by that size.
from picohttpparser.
A rough flow of my program(in pseudo C code):
rv = read(sock, buf, 4096);
phr_parse_response(...); /* I check the headers after this and set chunked_response = 1 if headers indicate */
if (chunked_response) {
size = rv /* setting this to offset buffer with what has been read so far */
do {
while ((rret = read(sock, buf + size, capacity - size)) == -1 && errno == EINTR)
;
if (rret <= 0)
return IOError;
/* decode */
rsize = rret;
pret = phr_decode_chunked(&decoder, buf + size, &rsize);
if (pret == -1)
return ParseError;
size += rsize;
} while (pret == -2);
}
printf("%s", buf); /* prints the output shown above */
from picohttpparser.
I am adding rsize
of each decode to size
. So I should limit it by size
to print the whole buffer?
from picohttpparser.
I would guess so, yes.
Where i am using it i simply cut off the buffer each time i use phr_decode_chunked.
from picohttpparser.
Thanks. When I limit the printf by the size
, it prints the decoded chunks correctly.
from picohttpparser.
Related Issues (20)
- Legacy support, what is the specification? HOT 1
- Why not hand written Boyer-Moore in is_complete? HOT 2
- Possible typo
- Correctly detect obsolete header line folding
- version number
- Questions about how to use picohttpparser? HOT 2
- Official release and git tag?
- Not able to properly parse using ruby FFI HOT 1
- Is it possible to avoid reallocation during chunked data processing?
- Is it possible to construct responses HOT 1
- What last_len actually means? HOT 2
- now is support https ? HOT 2
- Mystifying HTTP Response
- about http response "chunked" and "gzip".
- Can we use ranges2[16]="\000\040\177"? HOT 1
- Support for request body parsing HOT 1
- Dead / duplicated code in `is_complete()`
- Examples HOT 2
- Overly aggressive slowloris check? HOT 1
- `phr_parse_request()` partial parsing doesn't seem to work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from picohttpparser.