Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

FramedRead only calls decode_eof when there is buffered data #7

Closed
carllerche opened this issue Mar 2, 2017 · 8 comments
Closed

FramedRead only calls decode_eof when there is buffered data #7

carllerche opened this issue Mar 2, 2017 · 8 comments
Milestone

Comments

@carllerche
Copy link
Member

This issue is related to the discussion in tokio-rs/tokio-core#178

Given the tokio-proto pattern of representing a body stream as Body(Option<Chunk>), an HTTP 1.1 Decoder would require decode_eof to be called even if there is no more data.

In the case of streaming bodies w/ Connection: close and no content length, the body stream is all the data until the socket is closed. This means that an HTTP 1.1 decoder would need to emit a Body(None) frame on EOF when there is no buffered data.

@alexcrichton
Copy link
Contributor

Yeah this was sort of the ... "easy" mode? Do we want it to support everything? Do you have an idea how to fix? (I don't)

@carllerche
Copy link
Member Author

It could be unconditionally called, but then it would require changing the return signature of decode_eof -> Result<Option<Item>> or something like that.

@alexcrichton
Copy link
Contributor

Perhaps yeah, but I'd be wary of how the meaning of None is then very different between decode and decode_eof.

@carllerche
Copy link
Member Author

carllerche commented Mar 2, 2017 via email

@alexcrichton
Copy link
Contributor

It's true yeah being a default method could help quite a bit here. That means most will never implement the method itself.

Perhaps we could try itout and see how it goes? (I can't think of any other alternatives myself)

@Ralith
Copy link
Contributor

Ralith commented Mar 3, 2017

It could be unconditionally called, but then it would require changing the return signature of decode_eof -> Result<Option> or something like that.

This was the approach that I introduced in #1, motivated purely by it seeming much more obvious to me. It was reverted in cddbdb3.

@carllerche
Copy link
Member Author

carllerche commented Mar 3, 2017 via email

@Ralith
Copy link
Contributor

Ralith commented Mar 3, 2017

To be clear, I was referring to the EOF handling, not generic errors (which are offtopic in this PR).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants