1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 09:31:10 +01:00

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'; 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(); $handler->start();

View File

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

View File

@ -63,7 +63,7 @@ class Server
} elseif ($pid) { } elseif ($pid) {
return $this->pids[] = $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(); $handler->loop();
die; 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) { if (count($method) === 0 || count($method) > 2) {
throw new \danog\MadelineProto\Exception('Invalid method called'); throw new \danog\MadelineProto\Exception('Invalid method called');