public/phpmyadmin/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php
/**
     * Performs an HTTP request to the Selenium 2 server.
     *
     * @param string $method      'GET'|'POST'|'DELETE'|...
     * @param string $url
     * @param array $params       JSON parameters for POST requests
     */
Performs an HTTP request to the Selenium 2 server.
Performs an HTTP request to the Selenium 2 server .
public function curl($http_method,
                         PHPUnit_Extensions_Selenium2TestCase_URL $url,
                         $params = NULL)
    {
        $curl = curl_init($url->getValue());
        curl_setopt($curl, CURLOPT_TIMEOUT, $this->seleniumServerRequestsTimeout);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($curl,
                    CURLOPT_HTTPHEADER,
                    array(
                        'Content-type: application/json;charset=UTF-8',
                        'Accept: application/json;charset=UTF-8'
                     ));
        if ($http_method === 'POST') {
            curl_setopt($curl, CURLOPT_POST, TRUE);
            if ($params && is_array($params)) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
            } else {
                curl_setopt($curl, CURLOPT_POSTFIELDS, '');
            }
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
        } else if ($http_method == 'DELETE') {
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
        }
        $rawResponse = trim(curl_exec($curl));
        if (curl_errno($curl)) {
            throw new PHPUnit_Extensions_Selenium2TestCase_NoSeleniumException(
                'Error connection[' . curl_errno($curl) . '] to ' .
                $url->getValue()  . ': ' . curl_error($curl)
            );
        }
        $info = curl_getinfo($curl);
        if ($info['http_code'] == 0) {
            throw new PHPUnit_Extensions_Selenium2TestCase_NoSeleniumException();
        }
        if ($info['http_code'] == 404) {
            throw new BadMethodCallException("The command $url is not recognized by the server.");
        }
        curl_close($curl);
        $content = json_decode($rawResponse, TRUE);
        if ($info['http_code'] == 500) {
            $message = '';
            if (isset($content['value']['message'])) {
                $message .= $content['value']['message'];
            } else {
                $message .= "Internal server error while executing $http_method request at $url. Response: " . var_export($content, TRUE);
            }
            if (isset($content['value']['class'])) {
                $message .= PHP_EOL . $content['value']['class'];
            }
            throw new PHPUnit_Extensions_Selenium2TestCase_WebDriverException($message, isset($content['status']) ? $content['status'] : 13);
        }
        return new PHPUnit_Extensions_Selenium2TestCase_Response($content, $info);
    }
public function curl ( $ http_method , PHPUnit_Extensions_Selenium2TestCase_URL $ url , $ params = NULL ) { $ curl = curl_init ( $ url -> getValue ( ) ) ; curl_setopt ( $ curl , CURLOPT_TIMEOUT , $ this -> seleniumServerRequestsTimeout ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ curl , CURLOPT_HTTPHEADER , array ( 'Content-type: application/json;charset=UTF-8' , 'Accept: application/json;charset=UTF-8' ) ) ; if ( $ http_method === 'POST' ) { curl_setopt ( $ curl , CURLOPT_POST , TRUE ) ; if ( $ params && is_array ( $ params ) ) { curl_setopt ( $ curl , CURLOPT_POSTFIELDS , json_encode ( $ params ) ) ; } else { curl_setopt ( $ curl , CURLOPT_POSTFIELDS , '' ) ; } curl_setopt ( $ curl , CURLOPT_FOLLOWLOCATION , TRUE ) ; } else if ( $ http_method == 'DELETE' ) { curl_setopt ( $ curl , CURLOPT_CUSTOMREQUEST , 'DELETE' ) ; } $ rawResponse = trim ( curl_exec ( $ curl ) ) ; if ( curl_errno ( $ curl ) ) { throw new PHPUnit_Extensions_Selenium2TestCase_NoSeleniumException ( 'Error connection[' . curl_errno ( $ curl ) . '] to ' . $ url -> getValue ( ) . ': ' . curl_error ( $ curl ) ) ; } $ info = curl_getinfo ( $ curl ) ; if ( $ info [ 'http_code' ] == 0 ) { throw new PHPUnit_Extensions_Selenium2TestCase_NoSeleniumException ( ) ; } if ( $ info [ 'http_code' ] == 404 ) { throw new BadMethodCallException ( " The command  $ url  is not recognized by the server. " ) ; } curl_close ( $ curl ) ; $ content = json_decode ( $ rawResponse , TRUE ) ; if ( $ info [ 'http_code' ] == 500 ) { $ message = '' ; if ( isset ( $ content [ 'value' ] [ 'message' ] ) ) { $ message .= $ content [ 'value' ] [ 'message' ] ; } else { $ message .= " Internal server error while executing  $ http_method  request at  $ url . Response:  " . var_export ( $ content , TRUE ) ; } if ( isset ( $ content [ 'value' ] [ 'class' ] ) ) { $ message .= PHP_EOL . $ content [ 'value' ] [ 'class' ] ; } throw new PHPUnit_Extensions_Selenium2TestCase_WebDriverException ( $ message , isset ( $ content [ 'status' ] ) ? $ content [ 'status' ] : 13 ) ; } return new PHPUnit_Extensions_Selenium2TestCase_Response ( $ content , $ info ) ; }
Performs an HTTP request to the Selenium 2 server.
Performs an HTTP request to the Selenium 2 server .