-
Thank you for this library. I am running it in front of few APIs + UI projects and everything works flawlessly. I would like to rewrite response body for some APIs hosted internally. Assuming the response Transform this json payload {
"Link": "http://192.168.0.1/Connector/ConnectorService/",
} to this {
"Link": "https://contoso.com/Connector/ConnectorService/",
} Previously, I have been able to achieve this behaviour using IIS URL Rewrite Module - Outbound rule |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
This line is redundant with
This is backwards, it should be
You have to set the ContentLength before any writes to the originalResponse. Setting it after causes an exception and the response gets aborted. |
Beta Was this translation helpful? Give feedback.
This line is redundant with
context.Response.Body = memoryResponse;
, you can remove it.This is backwards, it should be
memoryResponse.Position = 0; await memoryResponse.CopyToAsync(originalResponse).ConfigureAwait(false);
You have to set the ContentLength before any writes to the originalResponse. Setting it after causes an exception and the response gets aborted.