Skip to content

http: do not add content-length: 0 to 101 responses on upgrade#10811

Merged
mattklein123 merged 1 commit into
envoyproxy:masterfrom
zuercher:zuercher_fix_illegal_content_length
Apr 16, 2020
Merged

http: do not add content-length: 0 to 101 responses on upgrade#10811
mattklein123 merged 1 commit into
envoyproxy:masterfrom
zuercher:zuercher_fix_illegal_content_length

Conversation

@zuercher
Copy link
Copy Markdown
Member

Per RFC 7230 Section 3.3.2, 101 responses should not contain
either a content-length or transfer-encoding. This change
removes the forced addition of a Content-Length: 0 header in
this case. Upstreams that return 101 or 204 responses with
Content-Length or Transfer-Encoding continue to be forwarded
downstream.

Risk Level: low
Testing: updated tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Stephan Zuercher zuercher@gmail.com

Per RFC 7230 Section 3.3.2, 101 responses should not contain
either a content-length or transfer-encoding. This change
removes the forced addition of a Content-Length: 0 header in
this case. Upstreams that return 101 or 204 responses with
Content-Length or Transfer-Encoding continue to be forwarded
downstream.

Risk Level: low
Testing: updated tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
@zuercher zuercher requested a review from alyssawilk April 16, 2020 17:37
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one test nit

{"upgrade", upgrade_type},
{"content-length", "0"}};
return Http::TestResponseHeaderMapImpl{
{":status", "101"}, {"connection", "upgrade"}, {"upgrade", upgrade_type}};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you're in here, I think this should be a 200.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For http/1.1, it seems like it has to be 101. But maybe something different happens in h2?

From https://tools.ietf.org/html/rfc6455#section-4.2.2:

  1. If the server chooses to accept the incoming connection, it MUST
    reply with a valid HTTP response indicating the following.

    1. A Status-Line with a 101 response code as per RFC 2616
      [RFC2616]. Such a response could look like "HTTP/1.1 101
      Switching Protocols".

@zuercher
Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10811 (comment) was created by @zuercher.

see: more, trace.

Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes sorry, I've been so embedded in the CONNECT work I mixed my upgrades up. Never mind me.

@mattklein123 mattklein123 merged commit 1a9f185 into envoyproxy:master Apr 16, 2020
zuercher added a commit to zuercher/envoy that referenced this pull request Jun 5, 2020
Follow-on to envoyproxy#10811. The previous change would strip the
transfer-encoding: chunked header if returned by an upstream
during upgrade, but the http/1.1 codec adds the header back.
RFC 7230, Section 3.3.1 requires that no such header appear
in a 1xx response.

Additional Description:
Unfortunately in the first attempt I failed to realize that transfer-encoding
is handled in the HTTP/1 codec. Adds checks and a flag in that codec to
disable adding transfer-encoding: chunked to 1xx responses.

Risk Level: low
Testing: updated tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
zuercher added a commit that referenced this pull request Jun 10, 2020
…1458)

Follow-on to #10811. The previous change would strip the
transfer-encoding: chunked header if returned by an upstream
during upgrade, but the http/1.1 codec adds the header back.
RFC 7230, Section 3.3.1 requires that no such header appear
in a 1xx or 204 response.

Use runtime feature "envoy.reloadable_features.strict_1xx_and_204_response_headers"
to disable.

Risk Level: medium
Testing: updated tests
Docs Changes: n/a
Release Notes: updated

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jun 24, 2020
…voyproxy#11458)

Follow-on to envoyproxy#10811. The previous change would strip the
transfer-encoding: chunked header if returned by an upstream
during upgrade, but the http/1.1 codec adds the header back.
RFC 7230, Section 3.3.1 requires that no such header appear
in a 1xx or 204 response.

Use runtime feature "envoy.reloadable_features.strict_1xx_and_204_response_headers"
to disable.

Risk Level: medium
Testing: updated tests
Docs Changes: n/a
Release Notes: updated

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
songhu pushed a commit to songhu/envoy that referenced this pull request Jun 25, 2020
…voyproxy#11458)

Follow-on to envoyproxy#10811. The previous change would strip the
transfer-encoding: chunked header if returned by an upstream
during upgrade, but the http/1.1 codec adds the header back.
RFC 7230, Section 3.3.1 requires that no such header appear
in a 1xx or 204 response.

Use runtime feature "envoy.reloadable_features.strict_1xx_and_204_response_headers"
to disable.

Risk Level: medium
Testing: updated tests
Docs Changes: n/a
Release Notes: updated

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
…voyproxy#11458)

Follow-on to envoyproxy#10811. The previous change would strip the
transfer-encoding: chunked header if returned by an upstream
during upgrade, but the http/1.1 codec adds the header back.
RFC 7230, Section 3.3.1 requires that no such header appear
in a 1xx or 204 response.

Use runtime feature "envoy.reloadable_features.strict_1xx_and_204_response_headers"
to disable.

Risk Level: medium
Testing: updated tests
Docs Changes: n/a
Release Notes: updated

Signed-off-by: Stephan Zuercher <zuercher@gmail.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
@zuercher zuercher deleted the zuercher_fix_illegal_content_length branch March 15, 2021 18:13
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.

3 participants