Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] Configure total timeout of request #32765

Closed
@pyrech

Description

@pyrech

Symfony version(s) affected: 4.3.x

Description
Symfony's HTTP CURL Client supports a timeout option that will set the option CURLOPT_CONNECTTIMEOUT_MS of curl. This parameter only configures the timeout for the connect phase.

But in some use cases (like a crawler f.e) we need to limit the maximum time a request is allowed to take, not only the connect duration. This is what the curl options CURLOPT_TIMEOUT and CURLOPT_TIMEOUT_MS do.

Unless I'm wrong, there is no way to configure the curl client with some custom config. Is that really intended? If yes, how can we change this timeout behavior?

How to reproduce

$httpClient = new CurlHttpClient();
$httpClient->request('GET', 'http://example.com/a-page-that-takes-a-long-time-to-render',  [
    'timeout' => 1,
]);

Possible Solution
Either add a way to override curl option or change the timeout behavior of the curl client

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions