-
Notifications
You must be signed in to change notification settings - Fork 895
Closed
Labels
Type: BugSomething isn't workingSomething isn't working
Description
Describe the bug
Trying to replace the request body is something that is not officially supported but should be possible. See #1473 (comment) for more information about this.
That thread doesn't really provide a real full solution on how to do this. So I create this issue to get this fully cleared up. This is also related to #520 but this seems all a bit bloated and unclear to me.
With this issue I want to get 2 things cleared up:
- How do I change the request body before forwarding with
Direct forwarding - How do I change the request body before forwarding with the normal YARP flow? (Not using direct forwarding but using middleware/transforms instead so it fits better into other yarp configurations)
To Reproduce
Take a look at program.cs from my repro repo:
https://github.com/sander1095/yarp-body-manipulation
info: Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
Request: An error was encountered before receiving a response.
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The request was aborted.
---> System.Net.Http.Http2StreamException: The HTTP/2 server reset the stream. HTTP/2 error code 'PROTOCOL_ERROR' (0x1).
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.ThrowRequestAborted(Exception innerException)
at System.Net.Http.Http2Connection.Http2Stream.CheckResponseBodyState()
at System.Net.Http.Http2Connection.Http2Stream.TryEnsureHeaders()
at System.Net.Http.Http2Connection.Http2Stream.ReadResponseHeadersAsync(CancellationToken cancellationToken)
at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.HttpForwarder.SendAsync(HttpContext context, String destinationPrefix, HttpMessageInvoker httpClient, ForwarderRequestConfig requestConfig, HttpTransformer transformer)
Further technical details
- YARP v1.0.0
- Windows
- Net 6.0
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't workingSomething isn't working