Skip to content

Fix response chunk encoding.#106

Merged
dpatti merged 3 commits into
inhabitedtype:masterfrom
bogdan2412:master
Mar 3, 2019
Merged

Fix response chunk encoding.#106
dpatti merged 3 commits into
inhabitedtype:masterfrom
bogdan2412:master

Conversation

@bogdan2412
Copy link
Copy Markdown
Contributor

When using transfer-encoding: chunked, each chunk that's sent over the
wire needs to be terminated with \r\n.

When using transfer-encoding: chunked, each chunk that's sent over the
wire needs to be terminated with \r\n.
Comment thread lib/serialize.ml
write_chunk_length t.encoder length;
schedule_fixed t iovecs
schedule_fixed t iovecs;
write_crlf t.encoder
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to write the final empty chunk. With the change it will write to CRLFs to it, which isn't correct.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec this is actually the correct behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought it was as well. It's consistent with the format of other chunks - one CRLF following the (0) size and one CRLF following the (empty) block of data.

@seliopou
Copy link
Copy Markdown
Member

seliopou commented Mar 3, 2019

@dpatti can you take a look and confirm that this matches the spec?

@dpatti
Copy link
Copy Markdown
Collaborator

dpatti commented Mar 3, 2019

Yup, this looks right. I guess I haven't used chunked encoding on the server-side of things yet. Thanks Bogdan!

@dpatti dpatti merged commit 53042e5 into inhabitedtype:master Mar 3, 2019
seliopou added a commit that referenced this pull request Apr 5, 2019
The last chunk of a chunk-encoded body was not being properly parsed.
Specifically, the final eol was not being consumed.

This is the other side of the same coin fixed in #106.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants