Skip to content
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

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

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

liorokman
Copy link
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
Copy link

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
Member

zirain commented Jan 29, 2024

/retest

@@ -97,6 +98,11 @@ type HTTP1Settings struct {
// By default, Envoy will lowercase all the headers.
// +optional
PreserveHeaderCase *bool `json:"preserveHeaderCase,omitempty"`
// EnableHTTP10 turns on support for HTTP/1.0 and HTTP/0.9 requests.
EnableHTTP10 *bool `json:"enableHttp10,omitempty"`
Copy link
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
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
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
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
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.

// If this is not set and an HTTP/1.0 request arrives without a host, then
// it will be rejected.
// +optional
SetHostHeder *bool `json:"setHostHeader,omitempty"`
Copy link
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
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
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
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
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
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 :-)


// HTTP10Settings provides HTTP/1.0 configuration on the listener.
type HTTP10Settings struct {
// SetHostHeader defines if the HTTP/1.0 request is is missing the Host header,
Copy link
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
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
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 zhaohuabing, zirain and a team February 8, 2024 04:40
Copy link
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!

@zhaohuabing zhaohuabing merged commit 151ae6a into envoyproxy:main Feb 8, 2024
19 of 20 checks passed
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