Skip to content

Commit d615761

Browse files
committed
optimize code
1 parent 4381186 commit d615761

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Transport/Http.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function __construct($host, $port, $username, $password, $authMethod = nu
122122
$this->_settings = new Settings();
123123

124124
$this->setCurler();
125+
$this->setHandle();
125126
}
126127

127128

@@ -241,7 +242,7 @@ private function getUrl($params = []): string
241242
*/
242243
private function newRequest($extendinfo): CurlerRequest
243244
{
244-
$new = new CurlerRequest(false, $this->getHandle());
245+
$new = new CurlerRequest(false, $this->handle);
245246

246247
switch ($this->_authMethod) {
247248
case self::AUTH_METHOD_QUERY_STRING:
@@ -576,7 +577,7 @@ public function getRequestWrite(Query $query): CurlerRequest
576577
*/
577578
public function ping(): bool
578579
{
579-
$request = new CurlerRequest(false, $this->getHandle());
580+
$request = new CurlerRequest(false, $this->handle);
580581
$request->url($this->getUri())->verbose(false)->GET()->connectTimeOut($this->getConnectTimeOut());
581582
$this->_curler->execOne($request);
582583

@@ -818,13 +819,9 @@ public function __destruct()
818819
}
819820

820821

821-
public function getHandle()
822+
public function setHandle()
822823
{
823-
if (!$this->handle) {
824-
$this->handle = curl_init();
825-
}
826-
827-
return $this->handle;
824+
$this->handle = curl_init();
828825
}
829826

830827
}

0 commit comments

Comments
 (0)