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

Problems with POST and forms #62

Open
TobiasMorell opened this issue Feb 18, 2019 · 4 comments
Open

Problems with POST and forms #62

TobiasMorell opened this issue Feb 18, 2019 · 4 comments

Comments

@TobiasMorell
Copy link

I'm trying to use this proxy to forward requests to an ASP.NET server on another domain. When I send a login request (POST to /api/login, request body containing a form) directly to the ASP.NET server it works fine, but when it has passed through the proxy I get an exception:

System.IO.IOException: Unexpected end of Stream, the content may have already been read by another component.

This exception occurs when I attempt to read the form from the request body.

I'm running the proxy with the default setup as provided in the readme file. Do I need to do something special to have the proxy include the forms in the proxied requests?

@mohrajab
Copy link

same thing here on two laravel projects with POST requests, any recommendation ??

@TobiasMorell
Copy link
Author

I ended up giving up, so sadly no recommendations from my side.

@ivantcholakov
Copy link

Maybe this old piece of code would give an idea.
gentics/proxy-php@d825be1

@idontusenumbers
Copy link

It seems to be related to chunked transfer encoding.

My caddy reverse proxy server gets this error:

{"level":"error","ts":1618986004.5862067,"logger":"http.handlers.reverse_proxy","msg":"reading from backend","error":"invalid byte in chunk length"}
{"level":"error","ts":1618986004.5862992,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"invalid byte in chunk length"}

I've worked around it by just removing that transfer encoding header just before emiting and it seems to work alright:

// chunked transfer encoding is broken; try just removing the header
if ($response->getHeader('Transfer-Encoding')[0] ?? "" === "chunked") {
    $response = $response->withoutHeader('Transfer-Encoding');
}
	
(new Laminas\HttpHandlerRunner\Emitter\SapiEmitter)->emit($response);
die();

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

No branches or pull requests

4 participants