[PR #1172] [MERGED] Fix JSON parsing of text/plain content type #1265

Closed
opened 2025-12-29 09:19:06 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/1172
Author: @ruxo
Created: 9/15/2024
Status: Merged
Merged: 9/20/2024
Merged by: @StefH

Base: masterHead: FixJsonDetection


📝 Commits (7)

  • 5edf150 UseContentType
  • 4c35696 Fix unit tests
  • 579354c Add a unit test and an integration test for the fix.
  • e732721 Simplify body type checking with GetBodyType extension.
  • f746584 Split IBodyDataExtension, and use imperative style instead of functional style
  • 31516a7 Remove excessive null forgiving operators
  • 8e0e2d2 Adjust braces

📊 Changes

5 files changed (+174 additions, -17 deletions)

View changed files

src/WireMock.Net.Abstractions/Models/IBodyDataExtension.cs (+20 -0)
📝 src/WireMock.Net/Http/HttpRequestMessageHelper.cs (+8 -5)
📝 src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs (+19 -11)
📝 test/WireMock.Net.Tests/Http/HttpRequestMessageHelperTests.cs (+21 -1)
test/WireMock.Net.Tests/ResponseBuilders/ResponseWithProxyIntegrationTests.cs (+106 -0)

📄 Description

Hello,

I am submitting a pull request to address the behavior of request body parsing, as discussed in issue #1168. My fix attempts to correct this behavior.

However, I'm not entirely sure if this fix is appropriate, as I don't fully understand why the current code relies on the body's detected type instead of the body's content type in both the request and response flows. I believe that the correction should prioritize the content type first, using the body's detected type as a fallback. But I'm not aware of all the history behind this implementation.

Could you please provide guidance or suggest any improvements?

Best regards,

Rux


🔄 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/1172 **Author:** [@ruxo](https://github.com/ruxo) **Created:** 9/15/2024 **Status:** ✅ Merged **Merged:** 9/20/2024 **Merged by:** [@StefH](https://github.com/StefH) **Base:** `master` ← **Head:** `FixJsonDetection` --- ### 📝 Commits (7) - [`5edf150`](https://github.com/wiremock/WireMock.Net/commit/5edf1508fa7947b96eb6602cd5c24110ba1a029e) UseContentType - [`4c35696`](https://github.com/wiremock/WireMock.Net/commit/4c3569677f7890b6df5c7e16e96f2759d3878183) Fix unit tests - [`579354c`](https://github.com/wiremock/WireMock.Net/commit/579354c8b6231684e7a0e4e3200ef98fde755ebe) Add a unit test and an integration test for the fix. - [`e732721`](https://github.com/wiremock/WireMock.Net/commit/e73272106e4603428b4a9484d6b46a6e54629119) Simplify body type checking with GetBodyType extension. - [`f746584`](https://github.com/wiremock/WireMock.Net/commit/f746584464ca1aba6171b52d29567ac6d26b850a) Split IBodyDataExtension, and use imperative style instead of functional style - [`31516a7`](https://github.com/wiremock/WireMock.Net/commit/31516a75c4102a80718874504792e4f870fe1317) Remove excessive null forgiving operators - [`8e0e2d2`](https://github.com/wiremock/WireMock.Net/commit/8e0e2d27aff8a30fa0d79a36926a8b4a67593c75) Adjust braces ### 📊 Changes **5 files changed** (+174 additions, -17 deletions) <details> <summary>View changed files</summary> ➕ `src/WireMock.Net.Abstractions/Models/IBodyDataExtension.cs` (+20 -0) 📝 `src/WireMock.Net/Http/HttpRequestMessageHelper.cs` (+8 -5) 📝 `src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs` (+19 -11) 📝 `test/WireMock.Net.Tests/Http/HttpRequestMessageHelperTests.cs` (+21 -1) ➕ `test/WireMock.Net.Tests/ResponseBuilders/ResponseWithProxyIntegrationTests.cs` (+106 -0) </details> ### 📄 Description Hello, I am submitting a pull request to address the behavior of request body parsing, as discussed in [issue #1168](https://github.com/WireMock-Net/WireMock.Net/issues/1168). My fix attempts to correct this behavior. However, I'm not entirely sure if this fix is appropriate, as I don't fully understand why the current code relies on the body's detected type instead of the body's content type in both the request and response flows. I believe that the correction should prioritize the content type first, using the body's detected type as a fallback. But I'm not aware of all the history behind this implementation. Could you please provide guidance or suggest any improvements? Best regards, Rux --- <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 09:19:06 +01:00
adam closed this issue 2025-12-29 09:19:06 +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#1265