Interpret HTTP transport errors as MTProto errors

This commit is contained in:
Daniil Gentili 2018-03-05 17:47:55 +01:00
parent 0f6f80c7de
commit 05f44fbea4
4 changed files with 5 additions and 5 deletions

View File

@ -2,5 +2,5 @@
require 'vendor/autoload.php';
$handler = new \danog\MadelineProto\Server(['type' => AF_INET, 'protocol' => 0, 'address' => 'localhost', 'port' => 8009]);
$handler = new \danog\MadelineProto\Server(['type' => AF_INET, 'protocol' => 0, 'address' => 'localhost', 'port' => 8000, 'transport_protocol' => 'tcp_abridged']);
$handler->start();

View File

@ -305,8 +305,8 @@ class Connection
$response = $this->read_http_payload();
if ($response['code'] !== 200) {
Logger::log($response['body']);
throw new Exception($response['description'], $response['code']);
return $this->pack_signed_int(-$response['code']);
//throw new Exception($response['description'], $response['code']);
}
$close = $response['protocol'] === 'HTTP/1.0';
if (isset($response['headers']['connection'])) {

View File

@ -63,7 +63,7 @@ class Server
} elseif ($pid) {
return $this->pids[] = $pid;
}
$handler = new \danog\MadelineProto\Server\Handler($socket, 'tcp_abridged', null, null, null, null, null);
$handler = new \danog\MadelineProto\Server\Handler($socket, $this->settings['transport_protocol'], null, null, null, null, null);
$handler->loop();
die;
}

View File

@ -89,7 +89,7 @@ class Handler extends \danog\MadelineProto\Connection
}
}
public function on_request($method, $args)
public function on_request($request_id, $method, $args)
{
if (count($method) === 0 || count($method) > 2) {
throw new \danog\MadelineProto\Exception('Invalid method called');