mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-24 17:02:18 +01:00
341 lines
9.7 KiB
XML
341 lines
9.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: e50e79746736dbdfbabe9bd3566793b3ddf38f58 Maintainer: jpauli Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<refentry xml:id="context.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_context_option">
|
|
<refnamediv>
|
|
<refname>Options de contexte HTTP</refname>
|
|
<refpurpose>Liste des options de contexte HTTP</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<para>
|
|
Options de contexte pour les protocoles <literal>http://</literal>
|
|
et <literal>https://</literal>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="options"><!-- {{{ -->
|
|
&reftitle.options;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry xml:id="context.http.method">
|
|
<term>
|
|
<parameter>method</parameter>
|
|
<type>&string;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
<constant>GET</constant>, <constant>POST</constant>, ou
|
|
n'importe quelle autre méthode HTTP supportée par le serveur distant.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut <constant>GET</constant>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.header">
|
|
<term>
|
|
<parameter>header</parameter>
|
|
<type>array</type> ou <type>string</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
En-têtes supplémentaires à envoyer lors de la requête.
|
|
Les valeurs de cette option écraseront les autres valeurs
|
|
(comme <literal>User-agent:</literal>, <literal>Host:</literal>,
|
|
et <literal>Authentication:</literal>),
|
|
même en suivant les redirections <literal>Location:</literal>.
|
|
Ainsi il n'est pas recommandé de définir l'en-tête
|
|
<literal>Host:</literal>, si <parameter>follow_location</parameter>
|
|
est activé.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.user-agent">
|
|
<term>
|
|
<parameter>user_agent</parameter>
|
|
<type>&string;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Valeur à envoyer avec l'en-tête <literal>User-Agent:</literal>. Cette valeur
|
|
ne doit être utilisée que si l'agent utilisateur n'est <emphasis>pas</emphasis>
|
|
spécifié dans l'option de contexte <literal>header</literal> ci-dessus.
|
|
</para>
|
|
<para>
|
|
Par défaut, la valeur de l'option de configuration
|
|
<link linkend="ini.user-agent">user_agent</link> du fichier
|
|
&php.ini; sera utilisée.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.content">
|
|
<term>
|
|
<parameter>content</parameter>
|
|
<type>&string;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Les données supplémentaires à envoyer après les en-têtes. Typiquement utilisées
|
|
lors des requêtes POST ou PUT.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.proxy">
|
|
<term>
|
|
<parameter>proxy</parameter>
|
|
<type>&string;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
URI de l'adresse du proxy (e.g.
|
|
<literal>tcp://proxy.example.com:5100</literal>).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.request-fulluri">
|
|
<term>
|
|
<parameter>request_fulluri</parameter>
|
|
<type>&boolean;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Lorsque défini à &true;, l'URI entière sera utilisée lors de la
|
|
construction de la requête (e.g.
|
|
<literal>GET http://www.example.com/path/to/file.html HTTP/1.0</literal>).
|
|
Bien que ce format de demande ne soit pas standard, certains serveurs de
|
|
proxy le demandent.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut &false;.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.follow-location">
|
|
<term>
|
|
<parameter>follow_location</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Suit les redirections <literal>Location</literal>.
|
|
À définir à <literal>0</literal> pour désactiver.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut <literal>1</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.max-redirects">
|
|
<term>
|
|
<parameter>max_redirects</parameter>
|
|
<type>int</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Le nombre maximal de redirections à suivre. La valeur <literal>1</literal>
|
|
ou inférieure signifie qu'aucune redirection ne sera suivie.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut <literal>20</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.protocol-version">
|
|
<term>
|
|
<parameter>protocol_version</parameter>
|
|
<type>&float;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Version du protocole HTTP.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut <literal>1.1</literal> à partir de PHP 8.0.0; antérieur
|
|
à cette version la valeur par défaut était <literal>1.0</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.timeout">
|
|
<term>
|
|
<parameter>timeout</parameter>
|
|
<type>&float;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Délai maximal d'attente pour la lecture, sous la forme d'un &float;
|
|
(e.g. <literal>10.5</literal>).
|
|
</para>
|
|
<para>
|
|
Par défaut, la valeur de l'option de configuration
|
|
<link linkend="ini.default-socket-timeout">default_socket_timeout</link>
|
|
du fichier &php.ini; sera utilisée.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="context.http.ignore-errors">
|
|
<term>
|
|
<parameter>ignore_errors</parameter>
|
|
<type>&boolean;</type>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Récupère le contenu même lors de la réception d'un code d'échec.
|
|
</para>
|
|
<para>
|
|
Par défaut, vaut &false;.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1><!-- }}} -->
|
|
|
|
<refsect1 role="examples"><!-- {{{ -->
|
|
&reftitle.examples;
|
|
<para>
|
|
<example xml:id="context.http.example-post"><!-- {{{ -->
|
|
<title>Récupération d'une page et envoi de données POST</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$postdata = http_build_query(
|
|
array(
|
|
'var1' => 'du contenu',
|
|
'var2' => 'doh'
|
|
)
|
|
);
|
|
|
|
$opts = array('http' =>
|
|
array(
|
|
'method' => 'POST',
|
|
'header' => 'Content-type: application/x-www-form-urlencoded',
|
|
'content' => $postdata
|
|
)
|
|
);
|
|
|
|
$context = stream_context_create($opts);
|
|
|
|
$result = file_get_contents('http://example.com/submit.php', false, $context);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example><!-- }}} -->
|
|
</para>
|
|
<para>
|
|
<example xml:id="context.http.example-fetch-ignore-redirect"><!-- {{{ -->
|
|
<title>Ignore les redirections mais récupère les en-têtes et le contenu</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$url = "http://www.example.org/header.php";
|
|
|
|
$opts = array('http' =>
|
|
array(
|
|
'method' => 'GET',
|
|
'max_redirects' => '0',
|
|
'ignore_errors' => '1'
|
|
)
|
|
);
|
|
|
|
$context = stream_context_create($opts);
|
|
$stream = fopen($url, 'r', false, $context);
|
|
|
|
// informations sur les en-têtes et métadonnées du flux
|
|
var_dump(stream_get_meta_data($stream));
|
|
|
|
// données actuelles de $url
|
|
var_dump(stream_get_contents($stream));
|
|
fclose($stream);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example><!-- }}} -->
|
|
</para>
|
|
</refsect1><!-- }}} -->
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<title>Options de contexte du flux sous-jacent</title>
|
|
<simpara>
|
|
Des options de contexte supplémentaires peuvent être
|
|
supportées par le
|
|
<link linkend="transports.inet">transport sous-jacent</link>.
|
|
Pour les flux <literal>http://</literal>, référez-vous aux
|
|
options de contexte du transport <literal>tcp://</literal>.
|
|
Pour les flux <literal>https://</literal>, référez-vous aux
|
|
options de contexte du transport <literal>ssl://</literal>.
|
|
</simpara>
|
|
</note>
|
|
<note>
|
|
<title>Ligne de statut HTTP</title>
|
|
<simpara>
|
|
Lorsque ce gestionnaire de flux suit une redirection,
|
|
<literal>wrapper_data</literal>, retourné par la fonction
|
|
<function>stream_get_meta_data</function> ne doit pas contenir
|
|
obligatoirement la ligne de statut HTTP qui s'applique à des
|
|
données de contenu à l'index <literal>0</literal>.
|
|
</simpara>
|
|
<screen>
|
|
<![CDATA[
|
|
array (
|
|
'wrapper_data' =>
|
|
array (
|
|
0 => 'HTTP/1.0 301 Moved Permanently',
|
|
1 => 'Cache-Control: no-cache',
|
|
2 => 'Connection: close',
|
|
3 => 'Location: http://example.com/foo.jpg',
|
|
4 => 'HTTP/1.1 200 OK',
|
|
...
|
|
]]>
|
|
</screen>
|
|
<simpara>
|
|
La première requête retourne une <literal>301</literal>
|
|
(redirection permanente), ainsi, le gestionnaire de flux
|
|
suit automatiquement la redirection pour récupérer une réponse
|
|
<literal>200</literal> (index = <literal>4</literal>).
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><xref linkend="wrappers.http" /></member>
|
|
<member><xref linkend="context.socket" /></member>
|
|
<member><xref linkend="context.ssl" /></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|