You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The driver does not throw an exception when an http error is returned from selenium #57
The problem seems to be due to a missing CURLOPT_FAILONERROR option being set by default.
Without that, curl_errno and curl_error do not deliver anything, and the code will let the bad selenium response float all the way up to the upper layers of the testing application.
First noticed while testing using the SauceLabs service. See details here: Behat/MinkExtension#179
@aik099 nowhere in that page an exception is mentioned. And curl was in php before exceptions where :-), so no. Plus if you look at user comments in the manual page for curl_error(), some people mention that it will not return anything unless CURLOPT_FAILONERROR has been set. And of course I tested it on at least one platform (php 5.4 from debian 7), and that was true for both curl_error() and curl_errno()
Setting CURLOPT_FAILONERROR won't handle every 4xx code. From the curl documentation:
This method is not fail-safe and there are occasions where non-successful response codes will slip through, especially when authentication is involved (response codes 401 and 407).
You might get some amounts of headers transferred before this situation is detected, like when a "100-continue" is received as a response to a POST/PUT and a 401 or 407 is received immediately afterwards.
@aik099 interesting. I've myself never used $GLOBALS['curl_error'] as I prefer not to use global variables if I can.
In fact I just checked the networking code of the phpxmlrpc library, which I have been maintaining since forever and is definitely battle-tested, and there is no use of curl_errno() or CURLOPT_FAILONERROR either. But there I can safely declare all empty response bodies as error; whereas I am not sure if such a simple approach is good here. The other way is to check by hand the http header returned. Maybe it is worth looking at how guzzle and company do the same check?
@gggeek , sorry for misleading you. I've just checked my code again and I'm using curl_errno($ch) and curl_error($ch) before connection is closed to get error information within my wrapper around curl library.
Activity
aik099 commentedon Dec 4, 2014
@gggeek , according to http://php.net/manual/en/function.curl-setopt.php the
CURLOPT_FAILONERRORoption is disabled by default in curl and needs to be manually enabled for exception to be thrown in case if curl encounters an error.gggeek commentedon Dec 4, 2014
@aik099 nowhere in that page an exception is mentioned. And curl was in php before exceptions where :-), so no. Plus if you look at user comments in the manual page for curl_error(), some people mention that it will not return anything unless CURLOPT_FAILONERROR has been set. And of course I tested it on at least one platform (php 5.4 from debian 7), and that was true for both curl_error() and curl_errno()
aik099 commentedon Dec 4, 2014
I've never set
CURLOPT_FAILONERRORoption and had$GLOBALS['curl_error']populated. Maybe this behavior was changed in recent curl versions.robocoder commentedon Dec 4, 2014
Setting
CURLOPT_FAILONERRORwon't handle every 4xx code. From the curl documentation:gggeek commentedon Dec 5, 2014
@aik099 interesting. I've myself never used $GLOBALS['curl_error'] as I prefer not to use global variables if I can.
In fact I just checked the networking code of the phpxmlrpc library, which I have been maintaining since forever and is definitely battle-tested, and there is no use of curl_errno() or CURLOPT_FAILONERROR either. But there I can safely declare all empty response bodies as error; whereas I am not sure if such a simple approach is good here. The other way is to check by hand the http header returned. Maybe it is worth looking at how guzzle and company do the same check?
@robocoder I am not totally familiar with the webdriver protocol. is it ever supposed to use auth schemes involviung 401/407 responses? I see no mention of auth in the spec ( https://code.google.com/p/selenium/wiki/JsonWireProtocol )
aik099 commentedon Dec 7, 2014
@gggeek , sorry for misleading you. I've just checked my code again and I'm using
curl_errno($ch)andcurl_error($ch)before connection is closed to get error information within my wrapper around curl library.