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

transport: Make error-handling for bad HTTP method consistent between HTTP/2 server transport and handler server transport #6989

Merged

Conversation

jhump
Copy link
Member

@jhump jhump commented Feb 16, 2024

This tweaks transport.NewServerHandlerTransport so that it behaves more like the normal HTTP/2 transport returned by transport.NewServerTransport with regard to requests with the wrong HTTP method. In particular, it now sends back a 405 Method Not Allowed status code and correctly sets an Allow response header.

I've also moved the HTTP version check to after we've confirmed that this is a gRPC request (via content-type check) and changed that to also use a more appropriate HTTP status code: 505 HTTP Version Not Supported. (This is not really related to consistency since the other transport never has to worry about HTTP 1.1 requests. But it makes the checks a little more coherent since IMO it seems more appropriate to reject the HTTP version only once we've confirmed that it's a gRPC request.)

RELEASE NOTES:

  • server: Fix some error cases when using a grpc.Server as an http.Handler with the Go stdlib HTTP server.

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Merging #6989 (d58a618) into master (3c2a44d) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6989      +/-   ##
==========================================
- Coverage   82.30%   82.20%   -0.10%     
==========================================
  Files         296      296              
  Lines       31454    31455       +1     
==========================================
- Hits        25888    25858      -30     
- Misses       4502     4525      +23     
- Partials     1064     1072       +8     
Files Coverage Δ
internal/transport/handler_server.go 85.95% <100.00%> (+1.42%) ⬆️

... and 14 files with indirect coverage changes

@dfawley dfawley added this to the 1.63 Release milestone Feb 16, 2024
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

LGTM

@zasweq zasweq changed the title Make error-handling for bad HTTP method consistent between HTTP/2 server transport and handler server transport transport: Make error-handling for bad HTTP method consistent between HTTP/2 server transport and handler server transport Feb 16, 2024
@zasweq zasweq merged commit 40d6adb into grpc:master Feb 16, 2024
14 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants