web64 / php-nlp-client

PHP Client for NLP Server
MIT License
73 stars 13 forks source link

incorrect detection of http_response_header version #6

Open shopapps opened 1 year ago

shopapps commented 1 year ago

in NlpClient.php line 175 you have:

if ( empty($result) || ( isset($http_response_header) && $http_response_header[0] != 'HTTP/1.0 200 OK' ) ) // empty if server is down

can you please move the check for the HTTP version to config?

if ( empty($result) || ( isset($http_response_header) && $http_response_header[0] != 'HTTP/' . config('nlp.http.version') . ' 200 OK' ) ) // empty if server is down

or even better:

if ( empty($result) || ( isset($http_response_header) && !stristr($http_response_header[0],  '200 OK' ))) // empty if server is down

currently, my local build returns: "HTTP/1.1 200 OK" (so HTTP/1.1 not HTTP/1.0 ) so all my attempts to use your laravel wrapper package are failing :-(

the output of my $http_response_header

"Web64\Nlp\NlpClient::post_call Line: 173" // vendor/web64/php-nlp-client/src/NlpClient.php:173
array:6 [ // vendor/web64/php-nlp-client/src/NlpClient.php:173
  0 => "HTTP/1.1 200 OK"
  1 => "Server: Werkzeug/2.3.4 Python/3.11.3"
  2 => "Date: Thu, 18 May 2023 10:19:01 GMT"
  3 => "Content-Type: application/json"
  4 => "Content-Length: 434"
  5 => "Connection: close"
]
shopapps commented 1 year ago

I have created a PR for it if that helps?