If you want to enable both HTTP/1.1 pipelining and HTTP/2 multiplexing...
<?php
curl_multi_setopt($mh, CURLMOPT_PIPELINING, 3);
?>
or
<?php
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX);
?>
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
curl_multi_setopt — Set a cURL multi option
Sets an option on the given cURL multi handle.
multi_handle
A cURL multi handle returned by curl_multi_init().
option
One of the CURLMOPT_*
constants.
value
The value to be set on option
.
value
should be an int for the
following values of the option
parameter:
Option | Set value to |
---|---|
CURLMOPT_PIPELINING |
Pass 1 to enable or 0 to disable. Enabling pipelining on a multi handle will make it attempt to perform HTTP Pipelining as far as possible for transfers using this handle. This means that if you add a second request that can use an already existing connection, the second request will be "piped" on the same connection. As of cURL 7.43.0, the value is a bitmask, and you can also pass 2 to try to multiplex the new transfer over an existing HTTP/2 connection if possible. Passing 3 instructs cURL to ask for pipelining and multiplexing independently of each other. As of cURL 7.62.0, setting the pipelining bit has no effect. Instead of integer literals, you can also use the CURLPIPE_* constants if available. |
CURLMOPT_MAXCONNECTS |
Pass a number that will be used as the maximum amount of simultaneously open connections that libcurl may cache. By default the size will be enlarged to fit four times the number of handles added via curl_multi_add_handle(). When the cache is full, curl closes the oldest one in the cache to prevent the number of open connections from increasing. |
CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE |
Pass a number that specifies the chunk length threshold for pipelining in bytes. |
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE |
Pass a number that specifies the size threshold for pipelining penalty in bytes. |
CURLMOPT_MAX_CONCURRENT_STREAMS |
The set number will be used as the maximum number of concurrent streams for a connections that cURL
should support on connections done using HTTP/2. Valid values range from
1 to 2147483647 (2^31 - 1 ).
The value passed here would be honored based on other system resources properties.
Default is 100 .
|
CURLMOPT_MAX_HOST_CONNECTIONS |
Pass a number that specifies the maximum number of connections to a single host. |
CURLMOPT_MAX_PIPELINE_LENGTH |
Pass a number that specifies the maximum number of requests in a pipeline. |
CURLMOPT_MAX_TOTAL_CONNECTIONS |
Pass a number that specifies the maximum number of simultaneously open connections. |
CURLMOPT_PUSHFUNCTION |
Pass a callable that will be registered to handle server
pushes and should have the following signature:
CURL_PUSH_OK if it can handle the push, or
CURL_PUSH_DENY to reject it.
|
Returns true
on success or false
on failure.
Version | Description |
---|---|
8.2.0 |
Introduced CURLMOPT_MAX_CONCURRENT_STREAMS .
|
8.0.0 |
multi_handle expects a CurlMultiHandle
instance now; previously, a resource was expected.
|
7.1.0 |
Introduced CURLMOPT_PUSHFUNCTION .
|
7.0.7 |
Introduced CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE ,
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE ,
CURLMOPT_MAX_HOST_CONNECTIONS ,
CURLMOPT_MAX_PIPELINE_LENGTH and
CURLMOPT_MAX_TOTAL_CONNECTIONS .
|
If you want to enable both HTTP/1.1 pipelining and HTTP/2 multiplexing...
<?php
curl_multi_setopt($mh, CURLMOPT_PIPELINING, 3);
?>
or
<?php
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX);
?>