PHP Velho Oeste 2024

http_throttle

(PECL pecl_http >= 0.10.0)

http_throttleÉtranglement HTTP

Description

void http_throttle ( float $sec [, int $bytes = 40960 ] )

Définit le délai d'étranglement et envoie la taille du buffer.

Note: Cette fonction doit être utilisée avec les fonctions http_send_data(), http_send_file() et http_send_stream().

Note: Fournit un mécanisme d'étranglement, qui gèrera le processus courant tant que l'entité n'aura pas été complètement envoyé.

Note:

Ne fonctionnera pas comme prévu avec les SAPIs suivants : FastCGI.

Liste de paramètres

sec

secondes à attendre après chaque partie envoyée

bytes

la taille d'une partie en octets

Exemples

Exemple #1 Exemple avec http_throttle()

Envoi un fichier à une vitesse approximative de 20 ko/s.

<?php
// ~ 20 ko/s
# http_throttle(1, 20000);
# http_throttle(0.5, 10000);
# http_throttle(0.1, 2000);
http_send_file('document.pdf');
?>

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
3
dr dot sane at gmail dot com
13 years ago
Note that in the example when it says "Send file with approximately 20 kbyte/s." that is only an upper bound. The file could still be sent at a lesser speed (e.g. 10 kb/s) if the client, network, or server, cannot handle the amount.
To Top