Browse Source

Return cURL errors on HTTP response codes >= 400.

By default the cURL extension does not trigger any error when fetching a
response with an HTTP code >= 400. Changing this behaviour is also useful to
intercept the 403 error generated when executing Redis commands disallowed
on Webdis by using ACLs.
Daniele Alessandri 14 năm trước cách đây
mục cha
commit
fc51f23ca7

+ 1 - 0
lib/Predis/Network/WebdisConnection.php

@@ -61,6 +61,7 @@ class WebdisConnection implements IConnectionSingle {
 
 
     private function initializeCurl(IConnectionParameters $parameters) {
     private function initializeCurl(IConnectionParameters $parameters) {
         $options = array(
         $options = array(
+            CURLOPT_FAILONERROR => true,
             CURLOPT_CONNECTTIMEOUT_MS => $parameters->connection_timeout * 1000,
             CURLOPT_CONNECTTIMEOUT_MS => $parameters->connection_timeout * 1000,
             CURLOPT_URL => "{$parameters->scheme}://{$parameters->host}:{$parameters->port}",
             CURLOPT_URL => "{$parameters->scheme}://{$parameters->host}:{$parameters->port}",
             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,