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

DELETE request with body does not include body in proxied request #112

Open
gjhommersom opened this issue Nov 9, 2023 · 2 comments
Open

Comments

@gjhommersom
Copy link

I have a 3th party service that uses the body of a DELETE to include additional data.

This library however does not include the body in the request it therefor fails with a 415 error.
Issue is at

!HttpMethods.IsDelete(requestMethod) &&

This is reproducible when sending the request directly to the 3th party service.

Is it possible that this gets fixed and the body is included?

@twitchax
Copy link
Owner

twitchax commented Nov 9, 2023

Yes, interesting issue.

However, I am not sure on the best fix. In practice, even though it is not strictly forbidden, it is generally accepted that the body of a DELETE should be ignored.

The best solution may be to allow someone to override the default?

@gjhommersom
Copy link
Author

For now I have managed to create workaround that does the job.

.WithBeforeSend((context, request) =>
{
   if (request.Method == HttpMethod.Delete)
   {
       request.Content = new StreamContent(context.Request.Body);
       request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(context.Request.ContentType);
       request.Content.Headers.ContentLength = context.Request.ContentLength;
   }
   return Task.CompletedTask;
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants