Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add
Plug.Conn.register_before_chunk/2
#1154Add
Plug.Conn.register_before_chunk/2
#1154Changes from all commits
7514d05
cce8150
cae6a0d
eb653a2
3958b6f
66bcae2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we also need to add tests for:
AlreadySentError
exceptionregister_before_chunk/2
callback (like adding a header or something) and you make sure that the new connection is passed to further callbacksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test for 1 (https://github.com/elixir-plug/plug/pull/1154/files#diff-5115eb93e759386d8da8b04d13db4e24d30f2d9ece59b85fe63068236aac9dfeR1452-R1458). For 2-3, almost all the methods which modify
Conn
raise anAlreadySentError
sinceconn.state == :chunked
fails thestate in @unsent
guard.We could:
conn
manually inside the callback for the purpose of the test, but that feels a bit contrived and not representative of real world use.conn
argument could be misleading misleading and we could remove it alongside the extra logic (ArugmentError
, merging headers) inrun_before_chunk
.:chunked
as an@unsent
state. But I don't think this is semantically correct, since the connection status / headers / cookies will have already been sent by the earlier call tosend_chunked
.I prefer 2, but curious if you had any thoughts or if I am missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should simply document the
conn
is read-only, as you can't really do anything useful with them. The main goal is to get a copy of any assigns or headers stored in it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, scratch that, I can see a connection is being returned all the way up.
@feynmanliang you can set a assigns/private field, like a counter, and measure it is being bumped. That should be supported :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I've exercised that in https://github.com/elixir-plug/plug/pull/1154/files#diff-5115eb93e759386d8da8b04d13db4e24d30f2d9ece59b85fe63068236aac9dfeR427-R444