public static function setCurlOptionOnRequest(Request $request, $option, $value, $curlHandle = null)
    {
        switch ($option) {
            case CURLOPT_URL:
                $request->setUrl($value);
                break;
            case CURLOPT_CUSTOMREQUEST:
                $request->setCurlOption(CURLOPT_CUSTOMREQUEST, $value);
                break;
            case CURLOPT_POST:
                if ($value == true) {
                    $request->setMethod('POST');
                }
                break;
            case CURLOPT_POSTFIELDS:
                // todo: check for file @
                if (is_array($value)) {
                    foreach ($value as $name => $fieldValue) {
                        $request->setPostField($name, $fieldValue);
                    }

                    if (count($value) == 0) {
                        $request->removeHeader('Content-Type');
                    }
                } elseif (!empty($value)) {
                    // Empty values are ignored to be consistent with how requests are read out of
                    // storage using \VCR\Request::fromArray(array $request).
                    $request->setBody($value);
                }
                $request->setMethod('POST');
                break;
            case CURLOPT_HTTPHEADER:
                foreach ($value as $header) {
                    $headerParts = explode(': ', $header, 2);
                    if (!isset($headerParts[1])) {
                        $headerParts[0] = rtrim($headerParts[0], ':');
                        $headerParts[1] = null;
                    }
                    $request->setHeader($headerParts[0], $headerParts[1]);
                }
                break;
            case CURLOPT_FILE:
            case CURLOPT_HEADER:
            case CURLOPT_WRITEFUNCTION:
            case CURLOPT_HEADERFUNCTION:
            case CURLOPT_UPLOAD:
                // Ignore header, file and writer functions.
                // These options are stored and will be handled later in handleOutput().
                break;
            default:
                $request->setCurlOption($option, $value);
                break;
        }
    }