Laminas Http Client setTimeout versus Curl connect and read timeouts
0 reputation · 30 Mar 2025, 21:51 UTC
Goal
Configure outbound HTTP requests in Laminas Http 2.x or 3.x so that connection establishment and response reading have separate time limits, while keeping the client code portable across adapters.
Constraint
Laminas\Http\Client::setTimeout() is documented as a client-level timeout, but adapter documentation indicates it is interpreted per adapter and may cover connect, read, or both without central validation. The Curl adapter exposes setCurlOptions() for CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT, which gives separate control but couples the caller to the Curl adapter. No cooperative cancellation token is documented; stopping an in-flight request relies on timeout expiration or adapter destruction.
Questions
- Does
setTimeout()enforce distinct connect and read limits across Curl and Socket adapters, or only a combined limit? - Is
setCurlOptions()on the Curl adapter the only documented path to separate connect and read timeouts? - What is the supported way to cancel an in-flight request before its timeout expires without destroying the adapter instance?