Conversation
…en encode=false The issue was that when AddQueryParameter was called with encode=false, the pipe character (|) was still being encoded to %7C. This happened because the AddQueryString method was creating a new Uri object directly, and the Uri constructor automatically encodes certain characters including the pipe character. The fix uses UriBuilder instead, which preserves the query string as-is without re-encoding it. This ensures that when encode=false is specified, characters like pipe (|) remain unencoded as expected. Added test case to verify pipe character is not encoded when encode=false.
…en encode=false - Modified BuildUriExtensions to add BuildUriString method that returns a string URI - Updated RestClient.Async to use string URI for HttpRequestMessage to preserve unencoded characters - Added RawUrl property to RequestBodyCapturer to capture the actual URL string sent over HTTP - Added integration test to verify pipe character is not encoded when encode=false - All existing tests pass
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||
Deploying restsharp with
|
| Latest commit: |
31f8508
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6a9299c9.restsharp.pages.dev |
| Branch Preview URL: | https://fix-issue-2207-pipe-encoding.restsharp.pages.dev |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
Test Results 42 files 42 suites 20m 8s ⏱️ Results for commit 31f8508. ♻️ This comment has been updated with latest results. |
5473f07 to
1fb6203
Compare
User description
Description
Fixes #2207
Purpose
This pull request is a:
Checklist
PR Type
Bug fix
Description
Fix pipe character encoding when AddQueryParameter encode=false
Refactor URI building to preserve unencoded query parameters
Use UriBuilder instead of Uri constructor to prevent re-encoding
Add BuildUriString method returning string URI for proper character preservation
Diagram Walkthrough
File Walkthrough
BuildUriExtensions.cs
Add BuildUriString method for unencoded query preservationsrc/RestSharp/BuildUriExtensions.cs
object
UriExtensions.cs
Use UriBuilder to prevent query string re-encodingsrc/RestSharp/Request/UriExtensions.cs
RestClient.Async.cs
Pass raw URL string to HttpRequestMessagesrc/RestSharp/RestClient.Async.cs
DefaultParameterTests.cs
Add integration test for pipe character encodingtest/RestSharp.Tests.Integrated/DefaultParameterTests.cs
RequestBodyCapturer.cs
Add RawUrl property for URL capturetest/RestSharp.Tests.Shared/Fixtures/RequestBodyCapturer.cs
characters
UrlBuilderTests.Get.cs
Add unit test for pipe character encodingtest/RestSharp.Tests/UrlBuilderTests.Get.cs
encode=false
.DS_Store
macOS system file update.DS_Store
.DS_Store
macOS system file updatetest/.DS_Store