Uh oh!
There was an error while loading. Please reload this page.
Restore 2-param AddCookie(name, value) overload - #2351
Conversation
PR #1966 replaced the simple AddCookie(name, value) with a 4-param overload requiring domain upfront, breaking the public API. This restores the 2-param form by deferring domain resolution to execution time using CookieContainer.Add(Uri, Cookie). - Add _cookies pending list and PendingCookies accessor to RestRequest - Add AddCookie(name, value) extension that stores cookies for deferred resolution alongside the existing 4-param AddCookie overload - Resolve pending cookies at execution time in RestClient.Async.cs using the request URL to infer domain - Update cookie documentation across all doc versions to show both forms - Fix Cookes typo in docs Closes#2284 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Summary by QodoRestore 2-param AddCookie overload and fix documentation
WalkthroughsDescription• Restore 2-parameter AddCookie(name, value) overload for backward compatibility • Defer domain resolution to execution time using CookieContainer.Add(Uri, Cookie) • Add pending cookies list to RestRequest following existing _files pattern • Update documentation across all versions with both simple and explicit forms • Fix Cookes typo to Cookies in documentation Diagramflowchart LR
A["AddCookie(name, value)"] --> B["Create Cookie object"]
B --> C["Store in _cookies list"]
C --> D["ExecuteRequestAsync"]
D --> E["Resolve domain from URL"]
E --> F["Add to CookieContainer"]
G["AddCookie(name, value, path, domain)"] --> F
File Changes1. src/RestSharp/Request/RestRequest.cs
|
Code Review by Qodo
1. |
Deploying restsharp with |
| Latest commit: | 38c5e32 |
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fe50fb40.restsharp.pages.dev |
| Branch Preview URL: | https://feature-restore-addcookie-2p.restsharp.pages.dev |
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Test Results 26 files 26 suites 13m 22s ⏱️ Results for commit 9c040c2. |
- Wrap cookieContainer.Add in try/catch for CookieException, matching the existing pattern in CookieContainerExtensions.AddCookies - Clear pending cookies after transfer to avoid duplicate adds on request retry/reuse - Make PendingCookies public so BeforeRequest interceptors and authenticators can observe cookies added via the 2-param overload - Clarify docs: 4-param AddCookie populates CookieContainer immediately, 2-param stores in PendingCookies until execution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.



Summary
AddCookie(name, value)overload that was removed in PR Move Cookie handling out of HttpClient so we do not cross pollinate requests #1966 when cookies were refactored to useCookieContainerCookieContainer.Add(Uri, Cookie), which infers the domain from the request URL_cookiespending list toRestRequest(following the existing_filespattern) with pending cookies resolved inExecuteRequestAsyncbefore building headersCookestypo →Cookiesin docsTest plan
CookieTestspass across all 4 target frameworks (net10.0, net9.0, net8.0, net48)AddCookie("name", "value")sends cookie with domain inferred from URLAddCookie("name", "value", "/", "domain")still works as beforeCloses#2284
🤖 Generated with Claude Code