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

Add content length and date headers to CORS response #2290

Closed
wants to merge 1 commit into from

Conversation

m0wfo
Copy link
Contributor

@m0wfo m0wfo commented Mar 6, 2014

Load balancers such as ELB will return a 502 to a client's preflight request due to the omission of date and content-length headers in Netty.

Am not sure this is the best place to put this, but some way of appending minimal standard response headers would be nice... maybe as a flag in HttpServerCodec?

@normanmaurer
Copy link
Member

@m0wfo thanks merged into 4.0, 4.1 and master. About some minimal headers I have no idea yet ;)

@normanmaurer normanmaurer added this to the 4.0.18.Final milestone Mar 6, 2014
@m0wfo
Copy link
Contributor Author

m0wfo commented Mar 6, 2014

Just went for a walk and thought about it- the codecs are quite unopinionated and low-level enough that it's probably not necessary or desirable IMHO- but CorsHandler solves a very specific and relatively high-level use case. Therefore to say it works, it should include the bare minimum of headers to keep common load balancers happy.

Just my 2c :)

@danbev
Copy link
Member

danbev commented Mar 7, 2014

I think it might be difficult for know up front all the possible response headers that different load balancers require, but this could be due to my limited knowledge of load balancers.

Should we try to specify a default set and also enable the CorsHandler to be configured to take any additional that we might miss?

@normanmaurer
Copy link
Member

Maybe we could allow the user to override it?

Am 07.03.2014 um 09:17 schrieb Daniel Bevenius notifications@github.com:

I think it might be difficult for know up front all the possible response headers that different load balancers require, but this could be due to my limited knowledge of load balancers.

Should we try to specify a default set and also enable the CorsHandler to be configured to take any additional that we might miss?


Reply to this email directly or view it on GitHub.

@danbev
Copy link
Member

danbev commented Mar 7, 2014

@normanmaurer That would work to. Have a default set and then be able to override that by adding any number of preflight response headers.

withOrigin("*").addPreflightHeader("X-Header", "value1", "value2").build();

Or something like that, wdyt?
This would not work for the Date header as that value must be generated when the response is created. But we could have a separate configuration method for it that.

Really not sure what the default response headers should be though. I don't understand what a load balancer would use the Content-Length and the Date header for in regards to a preflight request. It's just a request asking if it can perform the real request. There is no body and for caching CORS uses Access-Control-Max-Age. I assume that I'm missing something here though.

@danbev
Copy link
Member

danbev commented Mar 8, 2014

Added a suggestion in this branch.

@danbev
Copy link
Member

danbev commented Mar 12, 2014

@normanmaurer @m0wfo Let me know if you think this is alright for a PR?

@trustin
Copy link
Member

trustin commented Mar 18, 2014

@danbev Yes, please issue a pull request.

danbev added a commit to danbev/netty that referenced this pull request Mar 18, 2014
Motivation:

An intermediary like a load balancer might require that a Cross Origin
Resource Sharing (CORS) preflight request have certain headers set.
As a concrete example the Elastic Load Balancer (ELB) requires the
'Date' and 'Content-Length' header to be set or it will fail with a 502
error code.

This works is an enhancement of netty#2290

Modifications:

CorsConfig has been extended to make additional HTTP response headers
configurable for preflight responses. Since some headers, like the
'Date' header need to be generated each time, m0wfo suggested using a
Callable.

Result:

By default, the 'Date' and 'Content-Lenght' headers will be sent in a
preflight response. This can be overriden and users can specify
any headers that might be required by different intermediaries.
danbev added a commit to danbev/netty that referenced this pull request Mar 21, 2014
Motivation:

An intermediary like a load balancer might require that a Cross Origin
Resource Sharing (CORS) preflight request have certain headers set.
As a concrete example the Elastic Load Balancer (ELB) requires the
'Date' and 'Content-Length' header to be set or it will fail with a 502
error code.

This works is an enhancement of netty#2290

Modifications:

CorsConfig has been extended to make additional HTTP response headers
configurable for preflight responses. Since some headers, like the
'Date' header need to be generated each time, m0wfo suggested using a
Callable.

Result:

By default, the 'Date' and 'Content-Lenght' headers will be sent in a
preflight response. This can be overriden and users can specify
any headers that might be required by different intermediaries.
danbev added a commit to danbev/netty that referenced this pull request Mar 21, 2014
Motivation:

An intermediary like a load balancer might require that a Cross Origin
Resource Sharing (CORS) preflight request have certain headers set.
As a concrete example the Elastic Load Balancer (ELB) requires the
'Date' and 'Content-Length' header to be set or it will fail with a 502
error code.

This works is an enhancement of netty#2290

Modifications:

CorsConfig has been extended to make additional HTTP response headers
configurable for preflight responses. Since some headers, like the
'Date' header need to be generated each time, m0wfo suggested using a
Callable.

Result:

By default, the 'Date' and 'Content-Lenght' headers will be sent in a
preflight response. This can be overriden and users can specify
any headers that might be required by different intermediaries.
danbev added a commit to danbev/netty that referenced this pull request Mar 21, 2014
Motivation:

An intermediary like a load balancer might require that a Cross Origin
Resource Sharing (CORS) preflight request have certain headers set.
As a concrete example the Elastic Load Balancer (ELB) requires the
'Date' and 'Content-Length' header to be set or it will fail with a 502
error code.

This works is an enhancement of netty#2290

Modifications:

CorsConfig has been extended to make additional HTTP response headers
configurable for preflight responses. Since some headers, like the
'Date' header need to be generated each time, m0wfo suggested using a
Callable.

Result:

By default, the 'Date' and 'Content-Lenght' headers will be sent in a
preflight response. This can be overriden and users can specify
any headers that might be required by different intermediaries.
pulllock pushed a commit to pulllock/netty that referenced this pull request Oct 19, 2023
Motivation:

An intermediary like a load balancer might require that a Cross Origin
Resource Sharing (CORS) preflight request have certain headers set.
As a concrete example the Elastic Load Balancer (ELB) requires the
'Date' and 'Content-Length' header to be set or it will fail with a 502
error code.

This works is an enhancement of netty#2290

Modifications:

CorsConfig has been extended to make additional HTTP response headers
configurable for preflight responses. Since some headers, like the
'Date' header need to be generated each time, m0wfo suggested using a
Callable.

Result:

By default, the 'Date' and 'Content-Lenght' headers will be sent in a
preflight response. This can be overriden and users can specify
any headers that might be required by different intermediaries.
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.

None yet

4 participants