Pārlūkot izejas kodu

Don't check for html to see if the server returned an error, check content type

If the server didn't return JSON it's some sort of error, but we should not
assume that it's HTML. Sauce Labs just returns a simple text message. The code
as it was previously would look for <html>, not find it, and then blow up when
it tried to treat the text message as JSON.
Dave Rolsky 12 gadi atpakaļ
vecāks
revīzija
f04292987a
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      lib/Selenium/Remote/RemoteConnection.pm

+ 1 - 1
lib/Selenium/Remote/RemoteConnection.pm

@@ -92,7 +92,7 @@ sub _process_response {
         my $decoded_json = undef;
         print "RES: ".$response->decoded_content."\n\n" if $self->{debug};
         if (($response->message ne 'No Content') && ($response->content ne '')) {
-            if ($response->content =~ m/^<html>/i) {
+            if ($response->content_type !~ m/json/i) {
                 $data->{'cmd_return'} = 'Server returned error message '.$response->content.' instead of data';
                 return $data;
             }