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
Transfer-Encoding:chunked tests #16678
Transfer-Encoding:chunked tests #16678
Changes from 6 commits
bb12d43
09ad8ea
fd61db3
c36f855
1fd913a
c850be5
057c88d
d5035ba
08bb764
df08ce2
3ca6cf8
27f9714
03af833
a7a916a
b2433a3
f3b2aad
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.
You don't need this,
assert
is already removed by the compiler when this option is not specified.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 was told in a different comment (or maybe IRC) that doing something like this would save an extra string allocation. Additionally, if one compiles with asserts off, will
cause an
Unused identifier
warning?That said, I don't mind removing it as it definitely looks cleaner without 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.
can this fail in practice (eg client that violates spec)? if so, it's an external condition (not internal logic), so raising exception should be used instead
silently skipping the last 2 bytes can be really bad if they're not \r\n.
I doubt checking this condition has any real performance impact compared to rest of surrounding code.
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.
Well, it is external input, so sure, it can trigger the assert, but it would be a malformed request according to (my understanding of) the spec.
If the bytes are never received, the
await
should never finish, so I don't think an exception would be thrown.If the bytes are received, but are not
"\r\n"
, they simply get discarded. I also don't think this is exception worthy, especially if exceptions are explicitly disabled.I'm not sure (and have no strong feelings) about what the "right" thing to do if the last two bytes are not
"\r\n"
, but I would err towards saying that it is a malformed request (maybe return 400?) and is not a server exception.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.
what do other languages do?
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.
Here's what Python does: https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/http/client.py#L558
where
self._safe_read
is defined asThere 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.
ok we can deal with it in future PR's then, keep the code as is (with
when compileOption("assertions"): ...
maybe with a comment:
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.
Instead of adding a TODO just do it properly: raise a ValueError.
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 agree with ValueError and that was my initial wish too in #16678 (comment)
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.
(previous comment got lost)
discarding a future seems buggy (eg refs #11912)
note that #16695 doesn't have this issue (see its code with
await server.serve(Port(5555), cb)
), can you make something like it work? if not, add a comment: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.
So, I spent some time and dug through some docs, and with a bit of intuition and a lot of luck, I was able to replace this by using
callSoon
. I have no clue if that solution is any better than usingdiscard
, but I couldn't replicate what #16695 was doing.Please advise.
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.
EDIT: I don't know if
callSoon
is the right thing here;runSleepLoop
seems more complicated than it should, there may be a better, but I don't know which, so please add a# xxx check if there is a better way
so we can move forward with this PRThere 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.
It's definitely not the right thing here. All you need to do is use
asyncCheck
on the code that calls asynchttpserver'sserve
. I think you've made the code harder to work with by creating thatgenTest
template which is not necessary, turn it into an async proc and thenwaitFor
that async proc.