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

kong.service.request.enable_buffering handler transfer-encoding:chunked lost body #7544

Closed
Hexiaopi opened this issue Jul 7, 2021 · 6 comments
Labels
core/proxy pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... stale task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.

Comments

@Hexiaopi
Copy link

Hexiaopi commented Jul 7, 2021

I use kong.service.request.enable_buffering() in custom plugin
client send transfer-encoding:chunked request and server can not get request body and content-length.

kong version:2.0.4

@bungle
Copy link
Member

bungle commented Jul 7, 2021

@Hexiaopi can you provide us an example code? Also be specific in what you mean that server cannot get request body or content-lenght. Do you mean upstream service? And in that case, what does it get? There are a lot of limitations with ngx.location.capture that is used to implement the response buffering.

@bungle bungle added core/proxy task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not. labels Jul 7, 2021
@locao locao added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Jul 7, 2021
@bungle
Copy link
Member

bungle commented Jul 7, 2021

@Hexiaopi I will try to reproduce this tomorrow, but if you have some examples, it would be perhaps a bit faster, but I have idea that chunked responses or requests are problematic with response buffering. Perhaps both.

@Hexiaopi
Copy link
Author

Hexiaopi commented Jul 8, 2021

client use curl like :
curl -XPOST -H 'Transfer-Encoding: chunked' -H 'Connection: Keep-Alive' -H 'User-Agent: okhttp/3.14.0' -H 'some header' 'http://xxx.com/yyy/zzz' -d 'some json' -v

plugin use
image

server tcpdump
image
in this case server can not get content-length and http body

@Hexiaopi Hexiaopi closed this as completed Jul 9, 2021
@Hexiaopi Hexiaopi reopened this Jul 9, 2021
@bungle bungle removed the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Jul 9, 2021
@bungle
Copy link
Member

bungle commented Jul 9, 2021

Here is my test:

curl -XPOST -H 'Transfer-Encoding: chunked' -H 'Connection: Keep-Alive' -H 'User-Agent: okhttp/3.14.0' -H 'some header' 'http://kong.test:8000/anything' -d 'some json' -v
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1:8000...
* connect to ::1 port 8000 failed: Connection refused
*   Trying 127.0.0.1:8000...
* Connected to kong.test (127.0.0.1) port 8000 (#0)
> POST /anything HTTP/1.1
> Host: kong.test:8000
> Accept: */*
> Transfer-Encoding: chunked
> Connection: Keep-Alive
> User-Agent: okhttp/3.14.0
> Content-Type: application/x-www-form-urlencoded
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< Server: gunicorn/19.9.0
< Date: Fri, 09 Jul 2021 19:10:58 GMT
< Content-Length: 495
< Access-Control-Allow-Credentials: true
< Response-Phase: Executed
< X-Kong-Upstream-Latency: 4
< X-Kong-Proxy-Latency: 1
< Via: kong/2.4.1
< 
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "some json": ""
  }, 
  "headers": {
    "Accept": "*/*", 
    "Connection": "keep-alive", 
    "Content-Length": "9", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "bin.test", 
    "User-Agent": "okhttp/3.14.0", 
    "X-Forwarded-Host": "kong.test", 
    "X-Forwarded-Path": "/anything"
  }, 
  "json": null, 
  "method": "POST", 
  "origin": "127.0.0.1", 
  "url": "http://kong.test/anything/anything"
}

This seems to be working

@bungle
Copy link
Member

bungle commented Jul 9, 2021

@Hexiaopi, Can you try Kong 2.4.1?

@bungle bungle added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Jul 9, 2021
@stale
Copy link

stale bot commented Jul 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 23, 2021
@stale stale bot closed this as completed Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core/proxy pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... stale task/needs-investigation Requires investigation and reproduction before classifying it as a bug or not.
Projects
None yet
Development

No branches or pull requests

3 participants