Commit 009f70fa authored by tufengqi's avatar tufengqi

swoole http thrift

parent 6186ec96
...@@ -125,7 +125,7 @@ class SwooleHttpClient ...@@ -125,7 +125,7 @@ class SwooleHttpClient
register_shutdown_function([$this, 'closeCurlHandle']); register_shutdown_function([$this, 'closeCurlHandle']);
$full_url = $this->full_url; $full_url = $this->full_url;
$parts = parse_url($full_url); $parts = parse_url($full_url);
$this->curl_handle = new Client($parts['host'], $parts['port'], 'http' === $parts['scheme'] ? false : true); $this->curl_handle = new Client($parts['host'], ($parts['port'] ?? 80), 'http' === $parts['scheme'] ? false : true);
$full_url = $this->full_url; $full_url = $this->full_url;
$headers = []; $headers = [];
foreach ($this->headers as $key => $value) { foreach ($this->headers as $key => $value) {
......
...@@ -11,7 +11,7 @@ namespace fpf\thrift; ...@@ -11,7 +11,7 @@ namespace fpf\thrift;
use Thrift\Exception\TTransportException; use Thrift\Exception\TTransportException;
use Thrift\Factory\TStringFuncFactory; use Thrift\Factory\TStringFuncFactory;
use Swoft\HttpClient\Client; use Swoole\Coroutine\Http\Client;
class SwooleHttpClient extends \Thrift\Transport\TTransport class SwooleHttpClient extends \Thrift\Transport\TTransport
{ {
...@@ -219,7 +219,9 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport ...@@ -219,7 +219,9 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
$this->request_ = ''; $this->request_ = '';
$full_url = $this->scheme_ . "://" . $host . $this->uri_; $full_url = $this->scheme_ . "://" . $host . $this->uri_;
$parts = parse_url($full_url); $parts = parse_url($full_url);
$this->handle = new Client($parts['host'], $parts['port'], 'http' === $parts['scheme'] ? false : true); $this->handle = new Client($parts['host'], ($parts['port'] ?? 80), 'http' === $parts['scheme'] ? false : true);
$this->handle->setHeaders($options['headers']);
$this->handle->set(['timeout' => $options['timeout']]);
$this->handle->post($this->uri_, $options['body']); $this->handle->post($this->uri_, $options['body']);
$this->response_ = $this->handle->body; $this->response_ = $this->handle->body;
// Connect failed? // Connect failed?
......
...@@ -88,7 +88,7 @@ class ThriftServiceFactoryProxy ...@@ -88,7 +88,7 @@ class ThriftServiceFactoryProxy
public function __call($name, $arguments) public function __call($name, $arguments)
{ {
if (defined('IS_SWOOLE_SERVICE') && IS_SWOOLE_SERVICE === true) { if (defined('IS_SWOOLE_SERVICE') && IS_SWOOLE_SERVICE === true) {
$socket = new SwoftHttpClient( $socket = new SwooleHttpClient(
$this->request_base_params['host'], $this->request_base_params['host'],
$this->request_base_params['port'], $this->request_base_params['port'],
$this->request_base_params['uri'], $this->request_base_params['uri'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment