Skip to content

Commit

Permalink
Fixing broken links
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Jun 25, 2024
1 parent c6c8b2f commit e169671
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-v111/advanced/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Constructor parameters are:
| options | Client options | Yes |
| configureDefaultHeaders | Function to configure headers. Allows to configure default headers for `HttpClient`. Most of the time you'd prefer using `client.AddDefaultHeader` instead. | No |
| configureSerialization | Function to configure client serializers with non-default options or to use a different serializer ([learn more](serialization.md)) | No |
| useClientFactory | Instructs the client to use `SimpleFactory` ([learn more](../usage/basics#simple-factory)) to get an `HttpClient` instance | No |
| useClientFactory | Instructs the client to use `SimpleFactory` ([learn more](../usage/client#simple-factory)) to get an `HttpClient` instance | No |

Here's an example of how to create a client using client options:

Expand Down Expand Up @@ -227,4 +227,4 @@ Client options apply to all requests made by the client. Sometimes, you want to
| `AdvancedResponseWriter` | Allows custom handling of the response. The function gets an instance of `HttpResponseMessage` and an instance of `RestRequest`. It must return an instance of `RestResponse`, so it effectively overrides RestSharp default functionality for creating responses. |
| `Interceptors` | Allows adding interceptors to the request. Both client-level and request-level interceptors will be called. |

The table below contains all configuration properties of `RestRequest`. To learn more about adding request parameters, check the [usage page](../usage/basics#create-a-request) section about creating requests with parameters.
The table below contains all configuration properties of `RestRequest`. To learn more about adding request parameters, check the [usage page](../usage/request.md) section about creating requests with parameters.
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-v111/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var client = new RestClient(options);
var timeline = await client.GetJsonAsync<HomeTimeline>("statuses/home_timeline.json", cancellationToken);
```

Read [here](usage/basics#json-requests) about making JSON calls without preparing a request object.
Read [here](usage/execute#json-requests) about making JSON calls without preparing a request object.

### Content type

Expand Down
14 changes: 0 additions & 14 deletions docs/versioned_docs/version-v111/usage/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,6 @@ First, there's `DownloadDataAsync`, which returns `Task<byte[]`. It will read th

For larger responses, you can use `DownloadStreamAsync` that returns `Task<Stream>`. This function allows you to open a stream reader and asynchronously stream large responses to memory or disk.


## Reusing HttpClient

RestSharp uses `HttpClient` internally to make HTTP requests. It's possible to reuse the same `HttpClient` instance for multiple `RestClient` instances. This is useful when you want to share the same connection pool between multiple `RestClient` instances.

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:

- `BaseAddress` will be used to set the base address of the `HttpClient` instance if base address is not set there already.
- `MaxTimeout`
- `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.
- `Expect100Continue`

Another option is to use a simple HTTP client factory as described [above](#simple-factory).

## Blazor support

Inside a Blazor webassembly app, you can make requests to external API endpoints. Microsoft examples show how to do it with `HttpClient`, and it's also possible to use RestSharp for the same purpose.
Expand Down
14 changes: 14 additions & 0 deletions docs/versioned_docs/version-v111/usage/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,17 @@ You need to set the `useClientFactory` parameter to `true` in the `RestClient` c
```csharp
var client = new RestClient("https://api.twitter.com/2", true);
```

## Reusing HttpClient

RestSharp uses `HttpClient` internally to make HTTP requests. It's possible to reuse the same `HttpClient` instance for multiple `RestClient` instances. This is useful when you want to share the same connection pool between multiple `RestClient` instances.

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:

- `BaseAddress` is be used to set the base address of the `HttpClient` instance if base address is not set there already.
- `MaxTimeout` is used to cancel the call using the cancellation token source, so
- `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.
- `Expect100Continue`

Another option is to use a simple HTTP client factory as described [above](#simple-factory).

0 comments on commit e169671

Please sign in to comment.