[PR #294] [MERGED] don't strip request body if we don't recognize the request method #844

Closed
opened 2025-12-29 08:33:44 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/294
Author: @eli-darkly
Created: 6/29/2019
Status: Merged
Merged: 7/3/2019
Merged by: @StefH

Base: masterHead: AllowBodyForUnknownMethods


📝 Commits (2)

  • 8ba9c40 don't strip request body if we don't recognize the request method
  • 06a7395 use IsNullOrEmpty

📊 Changes

3 files changed (+108 additions, -2 deletions)

View changed files

📝 src/WireMock.Net/Util/BodyParser.cs (+26 -2)
📝 test/WireMock.Net.Tests/FluentMockServerTests.cs (+59 -0)
📝 test/WireMock.Net.Tests/Util/BodyParserTests.cs (+23 -0)

📄 Description

This addresses https://github.com/WireMock-Net/WireMock.Net/issues/290 by changing the request-processing behavior from this--

  • Is the request method is one of the specific methods that we know can have a body?
  • If so, then preserve the request body.
  • Otherwise, discard the request body.

--to this:

  • Is the request method is one of the specific methods that we know cannot have a body?
  • If so, then discard the request body.
  • Otherwise, preserve the request body.

For any of the methods that were already listed in BodyParser.cs, this change has no effect: request bodies will still be discarded for GET or DELETE, preserved for POST or PUT, etc. But for methods that were not specifically mentioned there (like REPORT), the request body (if any) will be preserved. I believe this is more in line with the HTTP specification, which only says that a server should discard the body if the method is known not to allow one.

While REPORT was the method I wanted to use in my own code, I didn't bother adding it to this list because it's just one of many rarely-used methods that appear in the HTTP Method Registry.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/wiremock/WireMock.Net/pull/294 **Author:** [@eli-darkly](https://github.com/eli-darkly) **Created:** 6/29/2019 **Status:** ✅ Merged **Merged:** 7/3/2019 **Merged by:** [@StefH](https://github.com/StefH) **Base:** `master` ← **Head:** `AllowBodyForUnknownMethods` --- ### 📝 Commits (2) - [`8ba9c40`](https://github.com/wiremock/WireMock.Net/commit/8ba9c40d6599fe4eb9a5367f9d947dfcaf2592a9) don't strip request body if we don't recognize the request method - [`06a7395`](https://github.com/wiremock/WireMock.Net/commit/06a7395dfaf00cc6ee38e3815c0af52e55268ab3) use IsNullOrEmpty ### 📊 Changes **3 files changed** (+108 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net/Util/BodyParser.cs` (+26 -2) 📝 `test/WireMock.Net.Tests/FluentMockServerTests.cs` (+59 -0) 📝 `test/WireMock.Net.Tests/Util/BodyParserTests.cs` (+23 -0) </details> ### 📄 Description This addresses https://github.com/WireMock-Net/WireMock.Net/issues/290 by changing the request-processing behavior from this-- * Is the request method is one of the specific methods that we _know_ can have a body? * If so, then preserve the request body. * Otherwise, discard the request body. --to this: * Is the request method is one of the specific methods that we _know_ **_cannot_** have a body? * If so, then discard the request body. * Otherwise, preserve the request body. For any of the methods that were already listed in BodyParser.cs, this change has no effect: request bodies will still be discarded for GET or DELETE, preserved for POST or PUT, etc. But for methods that were not specifically mentioned there (like REPORT), the request body (if any) will be preserved. I believe this is more in line with the HTTP specification, which only says that a server should discard the body if the method is known _not_ to allow one. While REPORT was the method I wanted to use in my own code, I didn't bother adding it to this list because it's just one of many rarely-used methods that appear in the [HTTP Method Registry](https://www.iana.org/assignments/http-methods). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 08:33:44 +01:00
adam closed this issue 2025-12-29 08:33:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#844