Skip to content

Commit 4411c71

Browse files
authored
Fixed header related to HTTP version
Fixed header interpretation related to HTTP version
1 parent b346587 commit 4411c71

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/NlpClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function post_call($path, $params, $retry = 0 )
172172
$context = stream_context_create($opts);
173173
$result = @file_get_contents($url, false, $context);
174174

175-
if ( empty($result) || ( isset($http_response_header) && $http_response_header[0] != 'HTTP/1.0 200 OK' ) ) // empty if server is down
175+
if (empty($result) || (isset($http_response_header) && !str_contains($http_response_header[0], '200 OK'))) // empty if server is down
176176
{
177177
$this->msg( "Host Failed: {$url}" );
178178

@@ -200,10 +200,10 @@ public function get_call($path, $params, $retry = 0)
200200
$this->msg( "NLP API [GET] $path - $url ");
201201
$result = @file_get_contents( $url, false );
202202

203-
if ( empty($http_response_header) || $http_response_header[0] == 'HTTP/1.0 404 NOT FOUND' )
203+
if (empty($http_response_header) || str_contains($http_response_header[0], '404 NOT FOUND'))
204204
return null;
205205

206-
if ( empty($result) || ( isset($http_response_header) && $http_response_header[0] != 'HTTP/1.0 200 OK' ) ) // empty if server is down
206+
if (empty($result) || (isset($http_response_header) && !str_contains($http_response_header[0], '200 OK'))) // empty if server is down
207207
{
208208
$this->msg( "Host Failed: {$url}" );
209209

0 commit comments

Comments
 (0)