public function requestRaw($method, $url, $parameters = array())
    {
        $url = $this->url.$url;

        if (false === $curl = curl_init()) {
            throw new \RuntimeException('Unable to create a new cURL handle');
        }

        $options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER         => false,
            CURLOPT_CUSTOMREQUEST  => $method,
            CURLOPT_URL            => $url,
            CURLOPT_TIMEOUT_MS     => 3000,
            CURLOPT_TIMEOUT        => 3,
            CURLOPT_FOLLOWLOCATION => 1,
            CURLOPT_MAXREDIRS      => 5,
            CURLOPT_FAILONERROR    => true,
            CURLOPT_SSL_VERIFYPEER => false,
        );

        switch ($method) {
            case 'HEAD':
                $options[CURLOPT_NOBODY] = true;
                break;

            case 'GET':
                $options[CURLOPT_HTTPGET] = true;
                break;

            case 'POST':
            case 'PUT':
            case 'DELETE':
            case 'PATCH':
                $options[CURLOPT_POSTFIELDS] = http_build_query($parameters);

                break;
        }

        curl_setopt_array($curl, $options);

        $result = curl_exec($curl);

        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        if ($statusCode === 200 || $statusCode === 204 || ($statusCode >= 300 && $statusCode <= 303)) {
            return $result;
        }

        if (0 === $statusCode) {
            throw new \RuntimeException(sprintf('Unable to connect to "%s".', $this->url));
        }

        throw new \RuntimeException(sprintf('Unexpected status code. Expected valid code, got %s.', $statusCode));
    }
public function requestRaw($method, $url, $parameters = array())
    {
        $url = $this->url.$url;

        if (false === $curl = curl_init()) {
            throw new \RuntimeException('Unable to create a new cURL handle');
        }

        $options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER         => false,
            CURLOPT_CUSTOMREQUEST  => $method,
            CURLOPT_URL            => $url,
            CURLOPT_TIMEOUT_MS     => 3000,
            CURLOPT_TIMEOUT        => 3,
            CURLOPT_FOLLOWLOCATION => 1,
            CURLOPT_MAXREDIRS      => 5,
            CURLOPT_FAILONERROR    => true,
            CURLOPT_SSL_VERIFYPEER => false,
        );

        switch ($method) {
            case 'HEAD':
                $options[CURLOPT_NOBODY] = true;
                break;

            case 'GET':
                $options[CURLOPT_HTTPGET] = true;
                break;

            case 'POST':
            case 'PUT':
            case 'DELETE':
            case 'PATCH':
                $options[CURLOPT_POSTFIELDS] = http_build_query($parameters);

                break;
        }

        curl_setopt_array($curl, $options);

        $result = curl_exec($curl);

        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        if ($statusCode === 200 || $statusCode === 204 || ($statusCode >= 300 && $statusCode <= 303)) {
            return $result;
        }

        if (0 === $statusCode) {
            throw new \RuntimeException(sprintf('Unable to connect to "%s".', $this->url));
        }

        throw new \RuntimeException(sprintf('Unexpected status code. Expected valid code, got %s.', $statusCode));
    }
public function requestRaw ( $ method , $ url , $ parameters = array ( ) ) { $ url = $ this -> url . $ url ; if ( false === $ curl = curl_init ( ) ) { throw new \ RuntimeException ( 'Unable to create a new cURL handle' ) ; } $ options = array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADER => false , CURLOPT_CUSTOMREQUEST => $ method , CURLOPT_URL => $ url , CURLOPT_TIMEOUT_MS => 3000 , CURLOPT_TIMEOUT => 3 , CURLOPT_FOLLOWLOCATION => 1 , CURLOPT_MAXREDIRS => 5 , CURLOPT_FAILONERROR => true , CURLOPT_SSL_VERIFYPEER => false , ) ; switch ( $ method ) { case 'HEAD' : $ options [ CURLOPT_NOBODY ] = true ; break ; case 'GET' : $ options [ CURLOPT_HTTPGET ] = true ; break ; case 'POST' : case 'PUT' : case 'DELETE' : case 'PATCH' : $ options [ CURLOPT_POSTFIELDS ] = http_build_query ( $ parameters ) ; break ; } curl_setopt_array ( $ curl , $ options ) ; $ result = curl_exec ( $ curl ) ; $ statusCode = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; if ( $ statusCode === 200 || $ statusCode === 204 || ( $ statusCode >= 300 && $ statusCode <= 303 ) ) { return $ result ; } if ( 0 === $ statusCode ) { throw new \ RuntimeException ( sprintf ( 'Unable to connect to "%s".' , $ this -> url ) ) ; } throw new \ RuntimeException ( sprintf ( 'Unexpected status code. Expected valid code, got %s.' , $ statusCode ) ) ; }
Raw method to request the API of MailCatcher.

@param string $method     HTTP method
@param string $url        absolute URL on server (`/messages/132.json`)
@param array  $parameters parameters to POST

@return string response body
@throws \RuntimeException
Raw method to request the API of MailCatcher .