You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add v114 documentation and Docusaurus version snapshot (#2368)
* Add v114 documentation: changelog, RedirectOptions, parameter formatting, error handling
- Add v114.0 changelog with breaking changes, new features, behavior changes, and bug fixes
- Document RedirectOptions for fine-grained redirect control
- Document MultipartFormQuoteParameters default change (false -> true)
- Document InvariantCulture default for parameter formatting
- Document improved ErrorMessage for timeouts and wrapped exceptions
- Update options table entries for FollowRedirects, MaxRedirects, Expect100Continue
- Create Docusaurus v114 versioned docs snapshot
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add .DS_Store and .grok/ to .gitignore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix code snippets in docs: Uri type, semicolons, property names, example constructor
- Fix `new Url(...)` to `new Uri(...)` in configuration example
- Remove stray semicolon in serialization lambda example
- Replace deprecated `MaxTimeout` with `Timeout` in client docs
- Replace `BaseAddress` with `BaseUrl` in HttpClient reuse section
- Fix example constructor to use `RestClientOptions` instead of `IOptions<>`
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@@ -161,12 +161,13 @@ RestSharp allows configuring `RestClient` using client options, as mentioned at
161
161
|`UseDefaultCredentials`| Whether to use default OS credentials for NTLM or Kerberos authentication. Not supported in browsers. |
162
162
|`DisableCharset`| When set to `true`, the `Content-Type` header won't have the `charset` portion. Some older web servers don't understand the `charset` portion in the header and fail to process the request. |
163
163
|`AutomaticDecompression`| Allows customizing supported decompression methods. Default is `All` except for .NET Framework that only support `GZip`. Not supported in browsers. |
164
-
|`MaxRedirects`| The number of redirects to follow. Not supported in browsers. |
164
+
|`MaxRedirects`| The number of redirects to follow. Delegates to `RedirectOptions.MaxRedirects`. Default is 50.|
165
165
|`ClientCertificates`| A collection of X.509 client certificates to be used for authentication. Not supported in browsers. |
166
166
|`Proxy`| Can be used if the client needs to use an explicit, non-default proxy. Not supported in browsers, on iOS and tvOS. |
167
167
|`CachePolicy`| Shortcut for setting the default value for `Cache-Control` header. |
168
-
|`FollowRedirects`| Instructs the client to follow redirects. Default is `true`. |
169
-
|`Expect100Continue`| Gets or sets a value that indicates if the `Expect` header for an HTTP request contains `Continue`. |
168
+
|`FollowRedirects`| Instructs the client to follow redirects. Default is `true`. Delegates to `RedirectOptions.FollowRedirects`. |
169
+
|`RedirectOptions`| Fine-grained control over redirect behavior. See [Redirect Options](#redirect-options) below. |
170
+
|`Expect100Continue`| Gets or sets a value that indicates if the `Expect` header for an HTTP request contains `Continue`. Set per-request, not on `HttpClient.DefaultRequestHeaders`. |
170
171
|`UserAgent`| Allows overriding the default value for `User-Agent` header, which is `RestSharp/{version}`. |
171
172
|`PreAuthenticate`| Gets or sets a value that indicates whether the client sends an `Authorization` header with the request. Not supported in browsers. |
172
173
|`RemoteCertificateValidationCallback`| Custom function to validate the server certificate. Normally, it's used when the server uses a certificate that isn't trusted by default. |
@@ -186,10 +187,8 @@ Some of the options are used by RestSharp code, but some are only used to config
186
187
-`UseDefaultCredentials`
187
188
-`AutomaticDecompression`
188
189
-`PreAuthenticate`
189
-
-`MaxRedirects`
190
190
-`RemoteCertificateValidationCallback`
191
191
-`ClientCertificates`
192
-
-`FollowRedirects`
193
192
-`Proxy`
194
193
195
194
:::note
@@ -207,6 +206,7 @@ Client options apply to all requests made by the client. Sometimes, you want to
207
206
|`AlwaysMultipartFormData`| When set to `true`, the request will be sent as a multipart form, even though it's not required. By default, RestSharp only sends requests with multiple attachments as multipart forms. Default is `false`. |
208
207
|`AlwaysSingleFileAsContent`| When set to true, the request with file attachment will not be sent as a multipart form, but as plain content. Default is `false`. It cannot be set to `true` when `AlwaysMultipartFormData` is set to `true`, or when the request has `POST` parameters. |
209
208
|`MultipartFormQuoteBoundary`| Default is `true`, which means that the form boundary string will be wrapped in quotes. If the server has an issue with that, setting this to `false` will remove quotes around the boundary. |
209
+
|`MultipartFormQuoteParameters`| Whether to quote parameter names in multipart form `Content-Disposition` headers per RFC 7578. Default is `true` (changed from `false` in v114). |
210
210
|`FormBoundary`| Allows specifying a custom multipart form boundary instead of using the default random string. |
211
211
|`RequestParameters`| Collection of request parameters. Normally, you won't need to use it as parameters are added to the request using `Add...` functions. |
212
212
|`CookieContainer`| Custom request-level cookie container. Default is `null`. You can still set request cookies using `AddCookie` and get response cookies from the response object without using cooking container. |
@@ -275,3 +275,44 @@ var longRunningRequest = new RestRequest("long-operation") {
275
275
Timeout=Timeout.InfiniteTimeSpan
276
276
};
277
277
```
278
+
279
+
## Redirect Options
280
+
281
+
RestSharp handles redirects internally (rather than delegating to `HttpClient`) so it can capture `Set-Cookie` headers from intermediate redirect responses. The `RedirectOptions` class provides fine-grained control over redirect behavior.
282
+
283
+
The convenience properties `RestClientOptions.FollowRedirects` and `RestClientOptions.MaxRedirects` delegate to `RedirectOptions` for backward compatibility.
|`FollowRedirects`|`true`| Whether to follow redirects. |
299
+
|`MaxRedirects`|`50`| Maximum number of redirects to follow. |
300
+
|`FollowRedirectsToInsecure`|`false`| Whether to follow redirects from HTTPS to HTTP. |
301
+
|`ForwardHeaders`|`true`| Whether to forward request headers on redirect. |
302
+
|`ForwardAuthorization`|`false`| Whether to forward the `Authorization` header on same-host redirects. |
303
+
|`ForwardAuthorizationToExternalHost`|`false`| Whether to forward `Authorization` on cross-host redirects. Only applies when `ForwardAuthorization` is true. |
304
+
|`ForwardCookies`|`true`| Whether to forward cookies on redirect. `Set-Cookie` headers are always captured regardless. |
305
+
|`ForwardBody`|`true`| Whether to forward the request body when the HTTP verb is preserved. Body is always dropped when verb changes to GET. |
306
+
|`ForwardQuery`|`true`| Whether to forward the original query string parameters on redirect. |
307
+
|`RedirectStatusCodes`| 301, 302, 303, 307, 308 | HTTP status codes considered as redirects. |
308
+
309
+
## Parameter formatting
310
+
311
+
By default, all generic parameter methods (`AddParameter<T>`, `AddQueryParameter<T>`, `AddUrlSegment<T>`, `AddHeader<T>`, etc.) format values using `CultureInfo.InvariantCulture`. This ensures consistent behavior regardless of the server's or client's locale.
312
+
313
+
If you need locale-specific formatting, pass a `CultureInfo` explicitly:
Copy file name to clipboardExpand all lines: docs/docs/advanced/error-handling.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ If there is a network transport error (network is down, failed DNS lookup, etc.)
5
5
If an API returns a 404, `ResponseStatus` will still be `Completed`. If you need access to the HTTP status code returned, you will find it at `RestResponse.StatusCode`.
6
6
The `Status` property is an indicator of completion independent of the API error handling.
7
7
8
+
When a request times out, `ResponseStatus` is set to `TimedOut` and `ErrorMessage` will say `"The request timed out."`. For other transport errors, `ErrorMessage` shows the root cause by using `GetBaseException().Message`, so you see the actual error (e.g., a TLS failure) rather than a generic wrapper message like `"An error occurred while sending the request"`. The full exception chain is always available in `ErrorException`.
9
+
8
10
Normally, RestSharp doesn't throw an exception if the request fails.
9
11
10
12
However, it is possible to configure RestSharp to throw in different situations when it normally doesn't throw
Copy file name to clipboardExpand all lines: docs/docs/changelog.md
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,36 @@ For release notes of previous versions, please check the [Releases page](https:/
10
10
11
11
Changes between major versions are documented in the documentation for each version on this website.
12
12
13
-
#v112.0
13
+
## v114.0
14
14
15
-
* Security fix for [CVE-2024-45302](https://github.com/restsharp/RestSharp/security/advisories/GHSA-4rr6-2v9v-wcpc). Header values cannot contain `CRLF`.
15
+
### Breaking changes
16
16
17
-
## v112.1
17
+
***`IAuthenticator` interface signature changed** — `Authenticate` now accepts an optional `CancellationToken` parameter. All custom authenticator implementations must be recompiled. ([#2362](https://github.com/restsharp/RestSharp/pull/2362))
18
+
***`FollowRedirects` and `MaxRedirects` removed from `ReadOnlyRestClientOptions`** — these properties are now excluded from the generated immutable wrapper. Use `RedirectOptions` instead. Code accessing these properties on `ReadOnlyRestClientOptions` must be updated. ([#2360](https://github.com/restsharp/RestSharp/pull/2360))
19
+
***Extension method signatures changed** — `AddParameter<T>`, `AddOrUpdateParameter<T>`, `AddHeader<T>`, `AddOrUpdateHeader<T>`, `AddQueryParameter<T>`, and `AddUrlSegment<T>` now have an additional optional `CultureInfo? culture` parameter. Assemblies compiled against v113 must be recompiled. ([#2354](https://github.com/restsharp/RestSharp/pull/2354))
18
20
19
-
* Follow up on v112.0 security fix: remove `\t` from the list of forbidden characters in headers.
21
+
### New features
22
+
23
+
***OAuth2 token lifecycle authenticators** — new `OAuth2ClientCredentialsAuthenticator`, `OAuth2RefreshTokenAuthenticator`, and `OAuth2TokenAuthenticator` that handle obtaining, caching, and refreshing tokens automatically. ([#2362](https://github.com/restsharp/RestSharp/pull/2362))
24
+
***Custom redirect handling with `RedirectOptions`** — RestSharp now manages redirects internally instead of delegating to `HttpClient`, fixing lost `Set-Cookie` headers on redirects. New `RedirectOptions` class provides fine-grained control over redirect behavior. ([#2360](https://github.com/restsharp/RestSharp/pull/2360))
25
+
***`MergedParameters` on `RestResponse`** — provides a combined view of request and default parameters at execution time, useful for logging and debugging. ([#2349](https://github.com/restsharp/RestSharp/pull/2349))
26
+
***Restored `AddCookie(name, value)` overload** — the simple two-parameter form defers domain resolution to execution time. ([#2351](https://github.com/restsharp/RestSharp/pull/2351))
27
+
28
+
### Behavior changes
29
+
30
+
***`MultipartFormQuoteParameters` now defaults to `true`** — multipart form parameter names are now quoted per RFC 7578. ([#2357](https://github.com/restsharp/RestSharp/pull/2357))
31
+
***`InvariantCulture` used for parameter formatting** — all generic parameter methods now format values using `CultureInfo.InvariantCulture` by default. Pass a `CultureInfo` explicitly if locale-specific formatting is needed. ([#2354](https://github.com/restsharp/RestSharp/pull/2354))
32
+
***Improved `ErrorMessage` for timeouts** — now shows `"The request timed out."` instead of `"A task was canceled."`. ([#2356](https://github.com/restsharp/RestSharp/pull/2356))
33
+
***`ErrorMessage` surfaces root cause** — uses `GetBaseException().Message` to show the actual error instead of generic wrapper messages. ([#2352](https://github.com/restsharp/RestSharp/pull/2352))
34
+
***`HttpClient.DefaultRequestHeaders` no longer modified** — `Expect100Continue` is now set per-request. Safe to share an `HttpClient` across multiple `RestClient` instances. ([#2363](https://github.com/restsharp/RestSharp/pull/2363))
35
+
36
+
### Bug fixes
37
+
38
+
* Fix `ConfigureAwait(false)` missing on several `await` calls, preventing deadlocks in sync-over-async scenarios. ([#2367](https://github.com/restsharp/RestSharp/pull/2367))
39
+
* Fix `ResponseUri` returning original URL instead of redirect target when `FollowRedirects=false`. ([#2350](https://github.com/restsharp/RestSharp/pull/2350))
@@ -47,7 +47,7 @@ Another way to create the client instance is to use a simple client factory. The
47
47
*`RemoteCertificateValidationCallback`
48
48
*`ClientCertificates`
49
49
*`MaxRedirects`
50
-
*`MaxTimeout`
50
+
*`Timeout`
51
51
*`UserAgent`
52
52
*`Expect100Continue`
53
53
@@ -66,8 +66,8 @@ RestSharp uses `HttpClient` internally to make HTTP requests. It's possible to r
66
66
67
67
One way of doing it is to use `RestClient` constructors that accept an instance of `HttpClient` or `HttpMessageHandler` as an argument. Note that in that case not all the options provided via `RestClientOptions` will be used. Here is the list of options that will work:
68
68
69
-
-`BaseAddress` is be used to set the base address of the `HttpClient` instance if base address is not set there already.
70
-
-`MaxTimeout` is used to cancel the call using the cancellation token source, so
69
+
-`BaseUrl` will be taken from `httpClient.BaseAddress`if not set explicitly.
70
+
-`Timeout` is used to cancel the call using the cancellation token source.
71
71
-`UserAgent` will be added to the `RestClient.DefaultParameters` list as a HTTP header. This will be added to each request made by the `RestClient`, and the `HttpClient` instance will not be modified. This is to allow the `HttpClient` instance to be reused for scenarios where different `User-Agent` headers are required.
0 commit comments