spring-cloud / spring-cloud/spring-cloud-gateway

MVC ProxyExchange returns ResponseEntity<> that causes a error for the client in some cases

Open
#674 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Bug Report

I am using ProxyExchange to proxy a call through to the backend, and want to return the response unchanged upstream.
In some cases this works, in others it does not.

When it does not work, curl displays the following error: "curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding"

I attached two projects: demo-projects.zip

  • backend: contains one endpoint, with a required requestParameter and returns a simple object
  • gateway: contains one endpoint with @RequestMapping(value = "/**), and it uses ProxyExchange to map all the incoming request onto the backend

Steps to reproduce the problem (backend runs on port 8787, gateway runs on port 7878):

  1. Run the two projects
  2. Call GET http://localhost:8787/resource?requestParam=1
    The response is 200: { "content": "hello" }
  3. Call GET http://localhost:8787/resource
    The response is

400: {
"timestamp": "2018-11-22T14:50:11.949+0000",
"status": 400,
"error": "Bad Request",
"message": "Required Integer parameter 'requestParam' is not present",
"path": "/resource"
}

  1. Call GET http://localhost:7878/resource?requestParam=1
    The response is 200: { "content": "hello" }
  2. Call GET http://localhost:7878/resource
    This gives the error mentioned above:

curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding

I do not see a reason why both cases should be handled differently by the gateway, and think this behaviour is a bug. I expect the gateway to just forward the ResponseEntity<?> objects.

I can fix the unexcpeted chunked-encoding error by constructing a new ResponseEntity by copying the body, status and headers from the ResponseEntity returned by the ProxyExchange, but when copying over the headers I remove the Transfer-Encoding

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached demo-projects.zip, running the backend on port 8787 and the gateway on port 7878. Reproduce the two GET requests with and without requestParam, then inspect the gateway endpoint using ProxyExchange and compare the returned headers. Done means the gateway forwards both responses unchanged without curl reporting a chunked-encoding error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.