Как отправить HTTP запрос?

166 views
Skip to first unread message

Денис Козин

unread,
Oct 2, 2013, 12:13:14 AM10/2/13
to phpd...@googlegroups.com
Есть приложение, написанное на старой версии phpDaemon(0.9.2). Возникла необходимость обновить phpDaemon до текущей версии и соответственно внести правки в приложении. 

На данный момент столкнулся с проблемной ситуацией, не могу отправить свой HTTP-запрос, используя уже готовые методы phpDaemon.
В Examples беру пример использования HTTP-клиента и в итоге GET-запрос не выполняется.

$this->httpclient = \PHPDaemon\Clients\HTTP\Pool::getInstance();
Получаю инстанс и делаю запрос:

$this->httpclient->get(
    function ($conn) {
        Daemon::log("GET");
    }
);

Пытаюсь хотя бы что-нибудь вывести в лог, но никаких результатов. Daemon::log() также стоит в методе get() в /PHPDaemon/Clients/HTTP/Connection.php
Как быть? Может быть я не правильно использую HTTP-клиент ?

Vasily Zorin

unread,
Oct 2, 2013, 5:43:40 PM10/2/13
to phpd...@googlegroups.com
Скорее всего проблема в DNS-сервере, или DNS-клиенте.


2 октября 2013 г., 8:13 пользователь Денис Козин <kozin.aliz...@gmail.com> написал:

--
 
---
Вы получили это сообщение, поскольку подписаны на группу phpdaemon.
 
Чтобы отказаться от подписки на эту группу и перестать получать из нее сообщения, отправьте электронное письмо на адрес phpdaemon+...@googlegroups.com.
Настройки подписки и доставки писем: https://groups.google.com/groups/opt_out.

la.shch...@gmail.com

unread,
May 28, 2015, 7:18:22 AM5/28/15
to phpd...@googlegroups.com
Добрый день.

У меня та же проблема. Пытаюсь выполнить тестовый запрос, а в ответ пустой body. При этом, если судить по дампу PHPDaemon\Clients\HTTP\Connection DNS работает нормально, адрес разыменован.

class WebSocket extends \PHPDaemon\Core\AppInstance {
/**
* @var \PHPDaemon\Clients\HTTP\Pool
*/
public $httpclient;



public function onReady() {

$this->httpclient = \PHPDaemon\Clients\HTTP\Pool::getInstance();

$this->httpclient->get('http://www.rambler.ru',
function ($conn, $success) {
\PHPDaemon\Core\Daemon::log(\PHPDaemon\Core\Debug::dump('HTTP client'));
\PHPDaemon\Core\Daemon::log(\PHPDaemon\Core\Debug::dump($conn));
\PHPDaemon\Core\Daemon::log(\PHPDaemon\Core\Debug::dump($conn->body));
\PHPDaemon\Core\Daemon::log(\PHPDaemon\Core\Debug::dump($success));
// $this->finish();
}
);
}


Результат в логе:

[Thu, 28 May 2015 10:54:53.612022 +0000] string(11) "HTTP client"

[Thu, 28 May 2015 10:54:53.616486 +0000] class PHPDaemon\Clients\HTTP\Connection#137 (68) {
public $headers =>
array(2) {
'STATUS' =>
string(20) "Host: www.rambler.ru"
'HTTP_USER_AGENT' =>
string(19) "phpDaemon/1.0-beta3"
}
public $contentLength =>
int(-1)
public $body =>
string(0) ""
protected $EOL =>
string(2) "
"
public $cookie =>
array(0) {
}
public $curChunkSize =>
NULL
public $curChunk =>
NULL
public $chunked =>
bool(false)
public $protocolError =>
NULL
public $responseCode =>
int(0)
public $lastURL =>
NULL
public $rawHeaders =>
NULL
protected $busy =>
bool(true)
protected $timeout =>
int(60)
protected $noSAF =>
bool(true)
protected $onResponse =>
class PHPDaemon\Structures\StackCallbacks#139 (2) {
private $flags =>
int(6)
private $dllist =>
array(0) {
}
}
protected $maxQueue =>
int(1)
protected $path =>
NULL
protected $host =>
string(14) "www.rambler.ru"
protected $hostReal =>
string(10) "81.19.70.1"
protected $port =>
int(80)
protected $user =>
NULL
protected $password =>
NULL
protected $addr =>
string(13) "81.19.70.1:80"
protected $onConnected =>
NULL
protected $connected =>
bool(true)
protected $failed =>
bool(false)
protected $locAddr =>
NULL
protected $locPort =>
NULL
protected $keepalive =>
bool(false)
protected $type =>
string(3) "tcp"
protected $parentSocket =>
NULL
protected $dgram =>
bool(false)
protected $bevConnectEnabled =>
bool(true)
protected $uri =>
array(5) {
'scheme' =>
string(3) "tcp"
'host' =>
string(14) "www.rambler.ru"
'uri' =>
string(20) "tcp://www.rambler.ru"
'params' =>
array(0) {
}
'port' =>
int(80)
}
protected $scheme =>
string(3) "tcp"
protected $pkfile =>
NULL
protected $certfile =>
NULL
protected $passphrase =>
NULL
protected $verifypeer =>
bool(false)
protected $allowselfsigned =>
bool(true)
public $pool =>
class PHPDaemon\Clients\HTTP\Pool#67 (18) {
protected $servers =>
array(0) {
}
protected $dtags_enabled =>
bool(false)
protected $servConn =>
array(1) {
'tcp://www.rambler.ru' =>
class PHPDaemon\Structures\ObjectStorage#54 (1) {
...
}
}
protected $servConnFree =>
array(1) {
'tcp://www.rambler.ru' =>
class PHPDaemon\Structures\ObjectStorage#55 (1) {
...
}
}
protected $prefix =>
string(0) ""
protected $maxConnPerServ =>
int(32)
protected $acquireOnGet =>
bool(false)
protected $pending =>
array(0) {
}
public $connectionClass =>
string(34) "\PHPDaemon\Clients\HTTP\Connection"
public $name =>
string(0) ""
public $config =>
class PHPDaemon\Config\Section#66 (5) {
public $source =>
NULL
public $revision =>
NULL
public $port =>
class PHPDaemon\Config\Entry\Generic#68 (8) {
...
}
public $sslport =>
class PHPDaemon\Config\Entry\Generic#69 (8) {
...
}
public $expose =>
class PHPDaemon\Config\Entry\Generic#51 (8) {
...
}
}
public $maxConcurrency =>
int(0)
public $maxAllowedPacket =>
int(0)
protected $finished =>
bool(false)
protected $enabled =>
bool(true)
protected $overload =>
bool(false)
public $appInstance =>
NULL
private $storage =>
array(1) {
'000000006429d8c2000000007b7a6482' =>
array(2) {
...
}
}
}
protected $EOLS =>
int(1)
protected $bev =>
class EventBufferEvent#156 (4) {
public $priority =>
NULL
public $fd =>
int(13)
public $input =>
class EventBuffer#140 (2) {
public $length =>
int(172)
public $contiguous_space =>
int(172)
}
public $output =>
class EventBuffer#153 (2) {
public $length =>
int(0)
public $contiguous_space =>
int(0)
}
}
protected $fd =>
NULL
protected $finished =>
bool(true)
protected $ready =>
bool(true)
protected $writing =>
bool(false)
protected $lowMark =>
int(1)
protected $highMark =>
int(0)
protected $priority =>
NULL
protected $inited =>
bool(true)
protected $state =>
int(2)
protected $onWriteOnce =>
class PHPDaemon\Structures\StackCallbacks#138 (2) {
private $flags =>
int(6)
private $dllist =>
array(0) {
}
}
protected $url =>
string(20) "tcp://www.rambler.ru"
protected $alive =>
bool(true)
protected $bevConnect =>
bool(true)
protected $wRead =>
bool(false)
protected $freed =>
bool(false)
protected $ctx =>
NULL
protected $ctxname =>
NULL
protected $ctxMode =>
NULL
protected $ssl =>
bool(false)
protected $timeoutRead =>
int(60)
protected $timeoutWrite =>
int(60)
protected $eventHandlers =>
array(0) {
}
protected $addThisToEvents =>
bool(true)
protected $lastEventName =>
NULL
}

[Thu, 28 May 2015 10:54:53.616725 +0000] string(0) ""

[Thu, 28 May 2015 10:54:53.616904 +0000] bool(true)

Vasily Zorin

unread,
May 28, 2015, 1:11:49 PM5/28/15
to phpd...@googlegroups.com
В таком случае дело в HTTP-клиенте, а именно — в обработке ответа. Сейчас выясню в чем дело при обращении к Рамблеру.

--

---
Вы получили это сообщение, поскольку подписаны на группу phpdaemon.

Чтобы отменить подписку на эту группу и больше не получать от нее сообщения, отправьте письмо на электронный адрес phpdaemon+...@googlegroups.com.
Настройки подписки и доставки писем: https://groups.google.com/d/optout.

Vasily Zorin

unread,
May 28, 2015, 1:49:55 PM5/28/15
to phpd...@googlegroups.com
А, ну понятно, в общем надо http://www.rambler.ru/ запрашивать делать, а не http://www.rambler.ruhttp://www.rambler.ru это не URL. Но эту ситуацию сейчас сделаю обрабатываемой.

Vasily Zorin

unread,
May 28, 2015, 1:56:00 PM5/28/15
to phpd...@googlegroups.com
Готово, теперь оба варианта работают, спасибо за сигнал.

la.shch...@gmail.com

unread,
Jun 3, 2015, 4:02:59 AM6/3/15
to phpd...@googlegroups.com
Вроде бы заработало. Буду копать дальше
Reply all
Reply to author
Forward
0 new messages