mirror of
https://github.com/php/doc-ru.git
synced 2026-03-23 23:32:16 +01:00
* Update pattern.matching.xml to en * Update createstopped.xml to en * Update construct.xml to en * Update createstopped.xml исправил формулировку * Update createstopped.xml to en * Update construct.xml to en * Update createstopped.xml to en * Update construct.xml to en * Update construct.xml Добавил кавычки к названию страницы * Update createstopped.xml to en * Update construct.xml to en * Update createstopped.xml to en * Update createstopped.xml исправил ошибку * Update construct.xml to en * Update createstopped.xml to en * Update construct.xml to en * Update createstopped.xml to en * Update prev.xml to en * Update stat.xml to en * Update construct.xml to en * Update createstopped.xml to en * Update set.xml to en * Update clear.xml to en * Update feed.xml to en * Update invoke.xml to en * Update setcallback.xml to en * Update book.xml to en * Update event.callbacks.xml to en * Update event.constructing.signal.events.xml to en * Update event.flags.xml to en * Update event.constructing.signal.events.xml исправил формулировку * Update event.persistence.xml to en * Update event.xml to en * Update eventbase.xml to en * Update eventbuffer.xml to en * Update eventbufferevent.about.callbacks.xml to en * Update eventbufferevent.xml to en * Update eventconfig.xml to en * Update eventsslcontext.xml to en * Update eventutil.xml to en * Update setup.xml to en * Update construct.xml to en * Update free.xml to en * Update pending.xml to en * Update event.callbacks.xml исправил формулировку * Update set.xml to en * Update set.xml формулировка * Update settimer.xml to en * Update signal.xml to en * Update timer.xml to en * Update free.xml to en * Update getfeatures.xml to en * Update gotexit.xml to en * Update gotstop.xml to en * Update loop.xml to en * Update addbuffer.xml to en * Update copyout.xml to en * Update drain.xml to en * Update prependbuffer.xml to en * Update readline.xml to en * Update search.xml to en * Update searcheol.xml to en * Update search.xml исправил формулировку * Update unlock.xml to en * Update connecthost.xml to en * Update construct.xml to en * Update createpair.xml to en * Update disable.xml to en * Update enable.xml to en * Update free.xml to en * Update getdnserrorstring.xml to en * Update readbuffer.xml to en * Update setcallbacks.xml to en * Update setwatermark.xml to en * Update setwatermark.xml Исправил ошибку * Update sslfilter.xml to en * Update sslsocket.xml to en * Update avoidmethod.xml to en * Update setmaxdispatchinterval.xml to en * Update loadhosts.xml to en * Update parseresolvconf.xml to en * Update setoption.xml to en * Update accept.xml to en * Update setallowedmethods.xml to en * Update setcallback.xml to en * Update setdefaultcallback.xml to en * Update makerequest.xml to en * Update addheader.xml to en * Update findheader.xml to en * Update getconnection.xml to en * Update sendreplystart.xml to en * Update construct.xml to en * Update construct.xml to en * Update setsocketoption.xml to en * Update pattern.matching.xml to en
169 lines
4.4 KiB
XML
169 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 23ea6be076881a34e1d454e9680968ece085f7f6 Maintainer: lex Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="eventhttpconnection.makerequest" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>EventHttpConnection::makeRequest</refname>
|
||
<refpurpose>Выполняет HTTP-запрос через соединение</refpurpose>
|
||
</refnamediv>
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<modifier>public</modifier>
|
||
<type>bool</type>
|
||
<methodname>EventHttpConnection::makeRequest</methodname>
|
||
<methodparam>
|
||
<type>EventHttpRequest</type>
|
||
<parameter>req</parameter>
|
||
</methodparam>
|
||
<methodparam>
|
||
<type>int</type>
|
||
<parameter>type</parameter>
|
||
</methodparam>
|
||
<methodparam>
|
||
<type>string</type>
|
||
<parameter>uri</parameter>
|
||
</methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Метод выполняет HTTP-запрос через заданное соединение.
|
||
HTTP-метод устанавливают через параметр <parameter>type</parameter>,
|
||
который принимает константы семейства
|
||
<literal>EventHttpRequest::CMD_*</literal>.
|
||
</para>
|
||
</refsect1>
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>req</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Объект подключения, через который отправляется запрос.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>type</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
<link linkend="eventhttprequest.constants">Константа семейства <literal>EventHttpRequest::CMD_*</literal></link>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>uri</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
URI-идентификатор, связанный с запросом.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</refsect1>
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
&return.success;
|
||
</para>
|
||
</refsect1>
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<example>
|
||
<title>
|
||
Пример HTTP-запроса методом <function>EventHttpConnection::makeRequest</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
|
||
function _request_handler($req, $base)
|
||
{
|
||
echo __FUNCTION__, PHP_EOL;
|
||
|
||
if (is_null($req)) {
|
||
echo "Время вышло\n";
|
||
} else {
|
||
$response_code = $req->getResponseCode();
|
||
|
||
if ($response_code == 0) {
|
||
echo "Соединение разорвано\n";
|
||
} elseif ($response_code != 200) {
|
||
echo "Неожиданный ответ: $response_code\n";
|
||
} else {
|
||
echo "Успешно: $response_code\n";
|
||
$buf = $req->getInputBuffer();
|
||
echo "Тело ответа:\n";
|
||
while ($s = $buf->readLine(EventBuffer::EOL_ANY)) {
|
||
echo $s, PHP_EOL;
|
||
}
|
||
}
|
||
}
|
||
|
||
$base->exit(NULL);
|
||
}
|
||
|
||
$address = "127.0.0.1";
|
||
$port = 80;
|
||
|
||
$base = new EventBase();
|
||
$conn = new EventHttpConnection($base, NULL, $address, $port);
|
||
$conn->setTimeout(5);
|
||
$req = new EventHttpRequest("_request_handler", $base);
|
||
|
||
$req->addHeader("Host", $address, EventHttpRequest::OUTPUT_HEADER);
|
||
$req->addHeader("Content-Length", "0", EventHttpRequest::OUTPUT_HEADER);
|
||
$conn->makeRequest($req, EventHttpRequest::CMD_GET, "/index.cphp");
|
||
|
||
$base->loop();
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs.similar;
|
||
<screen>
|
||
<![CDATA[
|
||
_request_handler
|
||
Success: 200
|
||
Body:
|
||
PHP, date:
|
||
2013-03-13T20:27:52+05:00
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</refsect1>
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<simplelist>
|
||
<member>
|
||
<methodname>EventHttpRequest::addHeader</methodname>
|
||
</member>
|
||
</simplelist>
|
||
</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
|
||
-->
|