-
Notifications
You must be signed in to change notification settings - Fork 868
fix broken trailers issue #1798
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
Conversation
|
Considering that this is a bug fix, would you mind moving the test (that fails due to the bug) to the top of the commit chain? IMO that helps us understand the issue is. |
|
Thank you @i110 it does fix the issue. |
|
@i110 i believe that this is breaking the |
…1.c" This reverts commit 43ffb76cd2788e061c9ef9e7e85b85966970a695.
a4e1eca to
89f06db
Compare
kazuho
left 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.
Thank you for the changes, sorry for the delay.
I have left my comments. Please let me know what you think.
|
|
||
| /* TODO: make chunked filter a submodule of lib/http1.c so that we could eliminate this flag, protocol version checks, etc. */ | ||
| if (req->is_subrequest) | ||
| goto Next; |
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.
Shouldn't we jump to NextWithoutTrailer? Unless we do, I believe that there's a chance where send_server_timing_trailer remains true after returning from this function, when req->is_subrequest is true.
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.
Yes, but subrequests are never handled by protocol handlers, so any trailers won't be sent.
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.
That's true. I agree with you that we can leave the code as-is.
In my view, this is an unfortunate side-effect of chunked.c not being part of http1.c, even though chunked encoding is specific to HTTP/1. Hopefully we can address this issue when make chunked.c part of http1.c.
| if (req->res.content_length != SIZE_MAX || req->version != 0x101) | ||
| /* do nothing if not HTTP/1.1 */ | ||
| if (req->version != 0x101) | ||
| goto Next; |
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.
Same as above. I believe that send_server_timing_trailer should be cleared when the HTTP version does not permit sending trailers.
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.
Regarding HTTP/1.0, you're right. At the same time I think that using HTTP/2 we always can send trailers. So what we have to do here is like the following?
if (req->version >= 0x200)
goto Next;
if (req->version != 0x101)
goto NextWithoutTrailers;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.
The proposed change makes sense to me.
| } | ||
| /* skip if content-encoding header is being set */ | ||
| if (h2o_find_header(&req->res.headers, H2O_TOKEN_TRANSFER_ENCODING, -1) != -1) | ||
| goto Next; |
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.
Please do not remove this check.
The check exists for the case when a CGI returns it's own transfer-encoding. That is not disallowed, and in such case, we cannot append a trailer, since it is either the CGI that emits the trailer, or it is an unknown transfer encoding.
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.
In our previous discussion, we found that there're no chance that transfer-encoding header is filled (because fastcgi and other handlers drop it by seeing proxy_should_drop_for_res flag), so this is redundant check. Am I right?
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.
Thank you for the clarification.
|
@kazuho Thank you, I replied to your comments. |
…ng transfer-encoding or TE: trailers existence
|
NOTE: a4dced5 fixes the problem that when using |
|
Thank you for all the hard work. The code looks good to me. Please feel free to merge the PR once the CI succeeds. |
Regarding #1790, I thought that the source of problem is rather chunked.c, not server-timing.c. I couldn't find any reasons to disable chunked encoding when the status is not 200, so this PR removes that behavior. Additionally I moved some code from chunked.c to http1.c.
@deweerdt Can this PR solve your issue?