Skip to content

impl a function to parse chunk sizes - #12

Merged
seanmonstar merged 1 commit into
seanmonstar:masterfrom
pyfisch:chunk_size
Dec 7, 2015
Merged

seanmonstar merged 1 commit into
seanmonstar:masterfrom
pyfisch:chunk_size

Conversation

@pyfisch

@pyfisch pyfisch commented Dec 5, 2015

Copy link
Copy Markdown
Contributor

All HTTP/1.1 clients and servers must understand the chunked encoding
and therefore must parse chunk sizes. The parse_chunk_size function
uses relies on the internals of httparse so it can't be implemented as
easily in an external crate. It is based on hypers implementation but
unlike hyper it operates on &[u8] and returns partial if the chunk size
is incomplete. For this reason it is more suitable for async HTTP code.

This is a breaking change because it adds a new variant to the Error
enum.

@seanmonstar

Copy link
Copy Markdown
Owner

Excellent, I've been meaning to do something like this.

I wonder if it makes sense to return httparse::Error from this function... The only error that could possibly happen is ChunkSize. Perhaps just make that pub struct InvalidChunkSize;? Would also mean it wouldn't be a breaking change...

All HTTP/1.1 clients and servers must understand the chunked encoding
and therefore must parse chunk sizes. The `parse_chunk_size` function
relies on the internals of httparse so it can't be implemented as
easily in an external crate. It is based on hypers implementation but
unlike hyper it operates on &[u8] and returns partial if the chunk size
is incomplete. For this reason it is more suitable for async HTTP code.
@pyfisch

pyfisch commented Dec 6, 2015

Copy link
Copy Markdown
Contributor Author

It now uses pub struct InvalidChunkSize; so it is no longer a breaking change but the return type of parse_chunk_size is a lot less nice.

seanmonstar added a commit that referenced this pull request Dec 7, 2015
impl a function to parse chunk sizes
@seanmonstar
seanmonstar merged commit 46c0915 into seanmonstar:master Dec 7, 2015
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.

2 participants