@@ -21,11 +21,10 @@ implementations for [PSR-17 (HTTP Factories)](https://www.php-fig.org/psr/psr-17
2121$client = new \Aternos\CurlPsr\Psr18\Client();
2222```
2323
24- When creating a client, you can optionally provide a PSR-17 ` ResponseFactoryInterface ` instance. By default,
25- the client will use the ` Aternos\CurlPsr\Psr17\Psr17Factory ` class included in this library.
24+ When creating a client, you can optionally provide PSR-17 ` ResponseFactoryInterface ` and ` UriFactoryInterface ` instances.
25+ By default, the client will use the ` Aternos\CurlPsr\Psr17\Psr17Factory ` class included in this library.
2626
27- Additionally, you can pass an optional ` CurlHandleFactoryInterface ` instance as the second argument,
28- which is mainly used for testing purposes.
27+ Additionally, you can pass an optional ` UriResolverInterface ` instance, which is used to resolve redirect targets.
2928
3029### Configuring the client
3130
@@ -52,7 +51,34 @@ $client->setProgressCallback(function (
5251});
5352```
5453
54+ #### Custom cURL options
55+
56+ You can set custom cURL options using the ` setCurlOption ` method. Note that some options cannot be set, since they are
57+ used internally by the client.
58+
59+ #### Redirects
60+
61+ The client will follow redirects by default. You can set the maximum number of redirects to follow using the
62+ ` setMaxRedirects ` method. It is also possible to disable redirects using ` setFollowRedirects ` . The difference between
63+ setting the maximum number of redirects to 0 and disabling redirects is that the former will throw an exception if a
64+ redirect is received, while the latter will simply return the redirect response.
65+
66+ Only when status ` 303 See Other ` is received, the client will automatically change the request method to ` GET ` and
67+ remove the request body. Historically, this behavior was also sometimes present for ` 301 ` and ` 302 ` , so it is possible
68+ to enable it for other status codes using the ` setRedirectToGetStatusCodes ` method.
69+
70+ Status ` 300 Multiple Choices ` will only be treated as a redirect if the ` Location ` header is present.
71+ Otherwise, the response will be returned as is.
72+
73+ To manage how redirect targets are resolved, or limit what locations the client can be redirected to,
74+ you can pass an instance of ` UriResolverInterface ` to the client constructor.
75+
76+ When a redirect response is received that does not prompt the client to change the request method to ` GET `
77+ and the body stream cannot be rewound, an exception is thrown. This is because the client cannot resend the request
78+ with the same body stream.
79+
5580#### Progress callback
81+
5682The progress callback function works the same way as the ` CURLOPT_PROGRESSFUNCTION ` in cURL,
5783except that it receives the PSR-7 request object instead of a cURL handle as the first argument.
5884Please note that the request object passed to the callback is not necessarily same instance that was
0 commit comments