Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@i110
Copy link
Contributor

@i110 i110 commented Jun 21, 2018

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?

@kazuho
Copy link
Member

kazuho commented Jun 21, 2018

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.

@deweerdt
Copy link
Member

Thank you @i110 it does fix the issue.

@deweerdt
Copy link
Member

@i110 i believe that this is breaking the t/40tls13-early-data.t test, the reason for that being that the test expects the connection to be kept alive on a 425

@i110 i110 force-pushed the i110/fix-broken-trailers branch from a4e1eca to 89f06db Compare June 22, 2018 07:23
@i110
Copy link
Contributor Author

i110 commented Jun 22, 2018

Thank you for your comments.

@kazuho I did it (but github appearance isn't changed..)

@deweerdt I fixed it by reverting d59d29b which changes the behavior in specific cases

@deweerdt
Copy link
Member

@deweerdt I fixed it by reverting d59d29b which changes the behavior in specific cases

that makes sense, thanks for the changes, they look good to me.

Copy link
Member

@kazuho kazuho left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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;
Copy link
Member

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.

Copy link
Contributor Author

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;

Copy link
Member

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;
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@i110
Copy link
Contributor Author

i110 commented Jul 25, 2018

@kazuho Thank you, I replied to your comments.

…ng transfer-encoding or TE: trailers existence
@i110
Copy link
Contributor Author

i110 commented Jul 27, 2018

NOTE: a4dced5 fixes the problem that when using ON (not ENFORCE) mode, server-timing header doesn't also appear along with trailer in certain conditions. In other words, by that commit server-timing header always appear without regarding transfer-encoding or TE: trailers existence

@kazuho
Copy link
Member

kazuho commented Jul 27, 2018

Thank you for all the hard work. The code looks good to me. Please feel free to merge the PR once the CI succeeds.

@i110 i110 merged commit 414561e into master Jul 27, 2018
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.

4 participants