Skip to content

api: Add support for enabling HTTP/1.0 and HTTP/0.9#2534

Merged
zhaohuabing merged 3 commits intoenvoyproxy:mainfrom
liorokman:http1-api
Feb 8, 2024
Merged

api: Add support for enabling HTTP/1.0 and HTTP/0.9#2534
zhaohuabing merged 3 commits intoenvoyproxy:mainfrom
liorokman:http1-api

Conversation

@liorokman
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This PR adds the API for enabling support for HTTP/1.0 and HTTP/0.9 from downstream clients

@liorokman liorokman requested a review from a team as a code owner January 29, 2024 08:29
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (f21f9ff) 63.94% compared to head (2481763) 63.93%.
Report is 1 commits behind head on main.

Files Patch % Lines
...frastructure/kubernetes/proxy/resource_provider.go 50.00% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2534      +/-   ##
==========================================
- Coverage   63.94%   63.93%   -0.01%     
==========================================
  Files         117      117              
  Lines       18057    18061       +4     
==========================================
+ Hits        11546    11548       +2     
- Misses       5758     5761       +3     
+ Partials      753      752       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zirain
Copy link
Copy Markdown
Member

zirain commented Jan 29, 2024

/retest

Copy link
Copy Markdown
Contributor

@arkodg arkodg Jan 29, 2024

Choose a reason for hiding this comment

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

I'd prefer if this was

htp10: {}

so in the future we could opt into injecting a Host header, but id prefer if this was a bool as well and the value was derived from the listener's hostname

Copy link
Copy Markdown
Contributor Author

@liorokman liorokman Jan 30, 2024

Choose a reason for hiding this comment

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

I'm not sure I follow your intent here.

The Envoy Proxy documentation says that Envoy Proxy doesn't support HTTP/1.0 requests correctly iff these arrive without a Host header. That's why configuring a default host is recommended.

accept_http_10
(bool) Handle incoming HTTP/1.0 and HTTP 0.9 requests. This is off by default, and not fully standards compliant. There is support for pre-HTTP/1.1 style connect logic, dechunking, and handling lack of client host iff default_host_for_http_10 is configured.

default_host_for_http_10
(string) A default host for HTTP/1.0 requests. This is highly suggested if accept_http_10 is true as Envoy does not otherwise support HTTP/1.0 without a Host header. This is a no-op if accept_http_10 is not true.

According to the Listener definition in the Gateway resource, matching with a hostname is optional. Deriving the hostname from the listener is not guaranteed to be possible, because providing a hostname is not mandatory.

Would you prefer if the API was:

spec:
   http1:
      enableHttp10: host-name-to-use-as-a-default

Copy link
Copy Markdown
Contributor

@arkodg arkodg Jan 30, 2024

Choose a reason for hiding this comment

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

imo if a user wants to set the host header for http10, and listener hostname is missing, that should be reflected in the status and policy should not be accepted

http1
  http10: {}

optional opt in to set Host Header with the value begin populated from the Listener Hostname field

http1
  http10:
    setHostHeader: true

@envoyproxy/gateway-maintainers please weigh in

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing Jan 31, 2024

Choose a reason for hiding this comment

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

+1 It would be hard to debug if placing hostnames in two different places and mismatch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the proposed API.

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.

I know I proposed set earlier, would addHostHeader be a better name ?

Copy link
Copy Markdown
Contributor Author

@liorokman liorokman Feb 1, 2024

Choose a reason for hiding this comment

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

Since the host header is only added if it's missing, how about useDefaultHost? That's also closer to what the Envoy Proxy configuration key is called.

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.

@envoyproxy/gateway-maintainers any preferences here ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 for useDefaultHost

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.

lets go with useDefaultHost unless @zhaohuabing disagrees :)

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing Feb 7, 2024

Choose a reason for hiding this comment

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

If addHostHeaderWhenMissing is too long, then useDefaultHost :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// SetHostHeader defines if the HTTP/1.0 request is is missing the Host header,
// SetHostHeader defines if the HTTP/1.0 request is is missing the Host header,
// SetHostHeader defines if the HTTP/1.0 request is missing the Host header,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit :-)

Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Lior Okman <lior.okman@sap.com>
Signed-off-by: Lior Okman <lior.okman@sap.com>
Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@arkodg arkodg requested review from a team, zhaohuabing and zirain February 8, 2024 04:40
Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

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