Repository: traefik/traefik (language: go)

Issue:
Buffering middleware responds with 500 when request is canceled amidst executing
### Welcome!

- [X] Yes, I've searched similar issues on [GitHub](https://github.com/traefik/traefik/issues) and didn't find any.
- [X] Yes, I've searched similar issues on the [Traefik community forum](https://community.traefik.io) and didn't find any.

### What did you do?

1. Make a request to the K8S Traefik IngressRoute with buffering middleware
2. Cancel the request before it's finished

I expected Traefik to not do anything or to allow to change the error code.

If you can't reproduce the bug, try to set the Content-Length explicitly to some big value, e.g. 10000. This way the response will be active for some time (for me it was 10 minutes) before it fails with 504 gateway timeout. You should not wait for the timeout, cancel the request right away. This way the response will be 500 for whoever did the request.

Approximate CURL query for reproduction:
```
curl --location --request POST 'https://{CLUSTER OUTER IP OR DOMAIN NAME}/{INGRESS ROUTE}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'something=blahblahblah'
```
(If you cannot reproduce the bug try adding the `--header 'Content-Length: 10000'` option)

### What did you see instead?

I saw 500 response code and `vulcand/oxy/buffer: error when reading request body, err: unexpected EOF` error message in the traefik logs

### What version of Traefik are you using?

2.6.0

### What is your environment & configuration?

```yaml
entryPoints:
- websecure
routes:
- kind: Rule
  match: /* redacted, confidential, does not play a role in the bug report. it will be different if you try to reproduce the issue anyways */
  middlewares:
  - name: security-headers
    namespace: traefik-api
  - name: app-buffering
    namespace: traefik-api
  priority: 42
  services:
  - kind: Service
    name: app-services
    namespace: app
    port: 8080
tls:
  options:
    name: bgrade-tls-options
    namespace: traefik-api
```
(app is replaced with the actual app name, redacted for itsec purposes)

buffering middleware:
```yaml
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: app-buffering
spec:
  buffering:
    maxRequestBodyBytes: 20000
```

The application is running in Kubernetes
The framework used is ASP.NET Core with .NET 6.0 runtime
Also we use this buffering middleware: https://github.com/vulcand/oxy/tree/master/buffer (if the issue should be created there I'm sorry, I will also create it there because I don't know where it belongs to and who is responsible for this bug)


### If applicable, please paste the log output in DEBUG level

_No response_


Discussion / hints:
any update on this? thank you 
Hello @longquan0104 ,

are you saying you've been able to reproduce this issue? if yes, have you tried with the latest version of traefik (2.9.8) ?
Yes. Vulcand/oxy/buffer no longer log `vulcand/oxy/buffer: error when reading request body, err: unexpected EOF` but the HTTP status return is  500. Tried 2.9.8 
I meet this error when I cancel a request before it comes to the service. Expect that it would be better to return the status 499

Fix patch:
diff --git a/go.mod b/go.mod
index 8659206326..8cc17b6005 100644
--- a/go.mod
+++ b/go.mod
@@ -66,7 +66,7 @@ require (
 	github.com/unrolled/render v1.0.2
 	github.com/unrolled/secure v1.0.9
 	github.com/vdemeester/shakers v0.1.0
-	github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467
+	github.com/vulcand/oxy/v2 v2.0.0-20230227135449-a0e9f7ff1040
 	github.com/vulcand/predicate v1.2.0
 	go.elastic.co/apm v1.13.1
 	go.elastic.co/apm/module/apmot v1.13.1
diff --git a/go.sum b/go.sum
index ee6b75bd4b..68881132af 100644
--- a/go.sum
+++ b/go.sum
@@ -1776,8 +1776,8 @@ github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac
 github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
 github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
 github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
-github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467 h1:Dbv3KJLgwtDKLpCZzTf1ISeG5ZYudPaLfTdYi4O2dSU=
-github.com/vulcand/oxy/v2 v2.0.0-20221121151423-d5cb734e4467/go.mod h1:0kOEB8mKzSeGHknF53gTM47UEvQnPoAPnM+58baqn2o=
+github.com/vulcand/oxy/v2 v2.0.0-20230227135449-a0e9f7ff1040 h1:L+nLher4530BUkyOpxxBsl2SLbrD4fSlDH5rGZ8DRBM=
+github.com/vulcand/oxy/v2 v2.0.0-20230227135449-a0e9f7ff1040/go.mod h1:A2voDnpONyqdplUDK0lt5y4XHLiBXPBw7iQES8+ZWRw=
 github.com/vulcand/predicate v1.2.0 h1:uFsW1gcnnR7R+QTID+FVcs0sSYlIGntoGOTb3rQJt50=
 github.com/vulcand/predicate v1.2.0/go.mod h1:VipoNYXny6c8N381zGUWkjuuNHiRbeAZhE7Qm9c+2GA=
 github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=


Test patch: