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

Problem with forwarding body of post method over OCELOT to asp.net API #792

Closed
CoviloMilos opened this issue Feb 22, 2019 · 7 comments
Closed
Labels
invalid Not actually an issue wontfix No plan to include this issue in the Ocelot core functionality.

Comments

@CoviloMilos
Copy link

Expected Behavior / New Feature

I am sending post method with body (Content-Type application/json) to asp.net Web API over Ocelot. Web API is working fine when I am testing it by sending request directly to him.

Actual Behavior / Motivation for New Feature

My request is received by asp.net Web API but with body which is null.

Steps to Reproduce the Problem

  1. Sending request with postman (post method, body application/json)
  2. Ocelot receive method and route it to the web api
  3. Web API receive null

Specifications

  • Version: Ocelot 13.0.0
  • Platform: Windows 10
  • Subsystem:
@osovitskiy
Copy link

I encountered the same issue. This happens when other middleware triggers request buffering before Ocelot.
I created sample solution to demonstrate problem: https://github.com/osovitskiy/ocelot-sample

@forgotten-warrior
Copy link

forgotten-warrior commented Aug 9, 2019

Any update on this topic, I encountered the same issue. This happens when other middleware triggers request buffering before Ocelot.

HttpContext.Request.EnableBuffering() <= call this one in the middleware before Ocelot process request cause issue

@sergey-bulavskiy
Copy link

@forgotten-warrior
Same one here. Sentry middleware triggers request buffering as well, and that leads to trimming of body request.
Solved it with turning off buffering for requests.

@osovitskiy
Copy link

@serjebulavsky
You can workaround problem by using delegating handler like this without turning off buffering
https://github.com/osovitskiy/ocelot-sample/blob/master/Gateway/MissingBodyDelegatingHandler.cs

@sergey-bulavskiy
Copy link

Thank you @osovitskiy, will have a look

@SuricateCan
Copy link

@osovitskiy I used your workaround for some time, and it worked.
But when I needed to upload a file, it failed with System.FormatException: The format of value 'multipart/form-data; boundary=--------------------------263426338817896429400771' is invalid..
I ended up rolling back and preventing Sentry to enable buffering, using this tip: getsentry/sentry-dotnet#387 (comment)

Another option is to disable request buffering:
leave MaxRequestBodySize as the default value which is None

@raman-m raman-m added invalid Not actually an issue wontfix No plan to include this issue in the Ocelot core functionality. labels Jan 14, 2024
@raman-m
Copy link
Member

raman-m commented Jan 14, 2024

@CoviloMilos
Not accepted! Lack of description and issue artifacts!

@raman-m raman-m closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Not actually an issue wontfix No plan to include this issue in the Ocelot core functionality.
Projects
None yet
Development

No branches or pull requests

6 participants