Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

initialize() method start a processes without ends #203

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

"require": {
"php": ">=7.1.0",
"guzzlehttp/guzzle": "^6",
"psr/log": "~1.0"
},

Expand Down
27 changes: 16 additions & 11 deletions src/Engine/SocketIO/Version1X.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use InvalidArgumentException;
use UnexpectedValueException;
use GuzzleHttp\Client;

use ElephantIO\EngineInterface;
use ElephantIO\Payload\Encoder;
Expand Down Expand Up @@ -179,12 +180,19 @@ protected function handshake()
}

// add customer headers
$request_headers = [];
$context[$protocol]['header'] = isset($context[$protocol]['header']) ? $context[$protocol]['header'] : [];
if (isset($this->options['headers'])) {
$headers = isset($context['http']['header']) ? $context['http']['header'] : [];
$context['http']['header'] = array_merge($headers, $this->options['headers']);
$context[$protocol]['header'] = \array_merge($context[$protocol]['header'], $this->options['headers']);
}

$url = \sprintf(
foreach ($context[$protocol]['header'] as $item) {
if (\preg_match('/^([^:]*):\s*([^;]*)/i', $item, $matches)) {
$request_headers[$matches[1]] = $matches[2];
}
}

$url = \sprintf(
'%s://%s:%d/%s/?%s',
$this->url['scheme'],
$this->url['host'],
Expand All @@ -193,7 +201,10 @@ protected function handshake()
\http_build_query($query)
);

$result = @\file_get_contents($url, false, \stream_context_create($context));
$client = new Client([]);

$response = $client->request('GET', $url, ['headers' => $request_headers]);
$result = $response->getBody()->getContents();

if (false === $result) {
$message = null;
Expand All @@ -214,13 +225,7 @@ protected function handshake()
throw new UnsupportedTransportException('websocket');
}

$cookies = [];
foreach ($http_response_header as $header) {
if (\preg_match('/^Set-Cookie:\s*([^;]*)/i', $header, $matches)) {
$cookies[] = $matches[1];
}
}
$this->cookies = $cookies;
$this->cookies = $response->getHeader('Set-Cookie');

$this->session = new Session(
$decoded['sid'],
Expand Down