Skip to content

Commit

Permalink
支持ws模式
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed May 24, 2019
1 parent e7e5fa9 commit bd92ca6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ public function exec(?float $timeout = null):Response
$this->setTimeout($timeout);
}
$client = $this->createClient();
if(!empty($this->cookies)){
$client->setCookies($this->cookies);
}
if($this->isPost){
foreach ($this->postFiles as $file){
$client->addFile(...$file);
Expand All @@ -185,6 +182,17 @@ public function exec(?float $timeout = null):Response
return $response;
}

public function upgrade():bool
{
$client = $this->createClient();
return $client->upgrade($this->getUri($this->url->getPath(),$this->url->getQuery()));
}

public function getClient():Client
{
return $this->swooleHttpClient;
}

private function createClient():Client
{
if($this->url instanceof Url){
Expand All @@ -196,6 +204,9 @@ private function createClient():Client
$cli = new Client($this->url->getHost(), $port, $ssl);
$cli->set($this->clientSetting);
$cli->setHeaders($this->header);
if(!empty($this->cookies)){
$cli->setCookies($this->cookies);
}
$this->swooleHttpClient = $cli;
return $this->swooleHttpClient;
}else{
Expand Down

0 comments on commit bd92ca6

Please sign in to comment.