瀏覽代碼

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 年之前
父節點
當前提交
f04292987a
共有 1 個文件被更改,包括 1 次插入1 次删除
  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;
             }