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

Allow custom status codes to be passed through from upstream #2270

Closed
kdorosh opened this issue Jan 23, 2020 · 4 comments
Closed

Allow custom status codes to be passed through from upstream #2270

kdorosh opened this issue Jan 23, 2020 · 4 comments
Assignees
Labels
Type: Enhancement New feature or request

Comments

@kdorosh
Copy link
Contributor

kdorosh commented Jan 23, 2020

Workflow that should be possible

  1. Install Gloo
  2. Deploy upstream
apiVersion: gloo.solo.io/v1
kind: Upstream
metadata:
  name: postman-echo
  namespace: gloo-system
spec:
  static:
    hosts:
    - addr: postman-echo.com
      port: 80
  1. Deploy VirtualService
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
  name: update-response-code
  namespace: gloo-system
spec:
  virtualHost:
    domains:
    - '*'
    routes:
    - matchers:
       - prefix: /
      routeAction:
        single:
          upstream:
            name: postman-echo
            namespace: gloo-system
      options:
        autoHostRewrite: true
  1. Run curl -v -H "Content-Type: application/json" "$(glooctl proxy url)/get?foo1=bar1&foo2=bar2= ="

Note the status code:

< HTTP/1.1 400 Bad Request

This modified from the upstream, which for curl -v --location --request GET 'https://postman-echo.com/get?foo1=bar1&foo2=bar2= =' returns:

< HTTP/1.1 400 BAD_REQUEST

We should allow the original status codes to be passed through.

@kdorosh kdorosh added the Type: Enhancement New feature or request label Jan 23, 2020
@kdorosh kdorosh self-assigned this Jan 23, 2020
@GrahamGoudeau
Copy link
Contributor

Note that this isn't piping through only the status code. The customer's use case is:

for example, instead of:
400 Bad Request
Our app actually returns:
400 Vehicle not Found

@kdorosh
Copy link
Contributor Author

kdorosh commented Jan 23, 2020

Correct, the http1 reason phrase needs to be preserved. This requires a change to upstream envoy, as the reason phrase is dropped by envoy for http2 compliance.

@kdorosh
Copy link
Contributor Author

kdorosh commented Jan 23, 2020

Related upstream envoy issue, similar to what we'd need to do: envoyproxy/envoy#8463

http1 codec needs to be updated: https://github.com/envoyproxy/envoy/blob/master/source/common/http/http1/codec_impl.cc

@kdorosh
Copy link
Contributor Author

kdorosh commented Jul 21, 2021

opted not to do this because the reason phrase should not be read by programs to make routing decisions

@kdorosh kdorosh closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants