Skip to content

net/http/httputil: ReverseProxy should use ErrAbortHandler on read error while copying body #23643

@jameshartig

Description

@jameshartig

What version of Go are you using (go version)?

1.9.2

Does this issue reproduce with the latest release?

Yes, additionally, looking at the code, it doesn't seem to be different in master.

What operating system and processor architecture are you using (go env)?

OS independent (tested on Windows/Linux)

What did you do?

https://play.golang.org/p/dK-zOdvklm1

If there's an error reading the body of a request, the ReverseProxy returns 200. The above script uses http.MaxBytesReader to cause an error reading the body and then prints the status code returned by the proxy.

What did you expect to see?

I expect the proxy to return a 502 bad gateway error instead of 200.

It looks like the problem is that *ReverseProxy.copyResponse doesn't return the error from *ReverseProxy.copyBuffer. An error channel, or similar, will need to be used for the FlushInterval case, but I'd expect the error to make it back into ServeHTTP. However, since the headers are already written before the body is read, that would need to be changed.

What did you see instead?

If you run the go playground above you get:

2009/11/10 23:00:00 httputil: ReverseProxy read error during body copy: http: request body too large
200

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions