International PHP Conference Berlin 2023

curl_upkeep

(PHP 8 >= 8.2.0)

curl_upkeepPerforms any connection upkeep checks

Descripción

curl_upkeep(CurlHandle $handle): bool

Available if built against libcurl >= 7.62.0.

Some protocols have "connection upkeep" mechanisms. These mechanisms usually send some traffic on existing connections in order to keep them alive; this can prevent connections from being closed due to overzealous firewalls, for example.

Connection upkeep is currently available only for HTTP/2 connections. A small amount of traffic is usually sent to keep a connection alive. HTTP/2 maintains its connection by sending a HTTP/2 PING frame.

Parámetros

ch

El recurso cURL devuelto por curl_init().

Valores devueltos

Devuelve true en caso de éxito o false en caso de error.

Ejemplos

Ejemplo #1 curl_upkeep() example

<?php
$url 
"https://example.com";

$ch curl_init();
curl_setopt($chCURLOPT_URL$url);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2_0);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_UPKEEP_INTERVAL_MS200);
if (
curl_exec($ch)) {
    
usleep(300);
    
var_dump(curl_upkeep($ch));
}
curl_close($ch);
?>

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top