protected function createCurlOptions(RequestInterface $request, ResponseBuilder $responseBuilder)
	{
		$options = array_diff_key($this->options, array_flip([CURLOPT_INFILE, CURLOPT_INFILESIZE]));
		$options[CURLOPT_HTTP_VERSION] = $this->getCurlHttpVersion($request->getProtocolVersion());
		$options[CURLOPT_HEADERFUNCTION] = function ($ch, $data) use ($responseBuilder) {
			$str = trim($data);

			if ('' !== $str)
			{
				if (strpos(strtolower($str), 'http/') === 0)
				{
					$responseBuilder->setStatus($str)->getResponse();
				}
				else
				{
					$responseBuilder->addHeader($str);
				}
			}

			return strlen($data);
		};

		$options[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
		$options[CURLOPT_URL] = (string) $request->getUri();
		$options[CURLOPT_HEADER] = false;

		if (in_array($request->getMethod(), ['GET', 'HEAD', 'TRACE', 'CONNECT']))
		{
			if ($request->getMethod() == 'HEAD')
			{
				$options[CURLOPT_NOBODY] = true;

				unset($options[CURLOPT_READFUNCTION], $options[CURLOPT_WRITEFUNCTION]);
			}
		}
		else
		{
			$options = $this->createCurlBody($request, $options);
		}

		$options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($responseBuilder) {
			return $responseBuilder->getResponse()->getBody()->write($data);
		};
		
		$options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options);

		if ($request->getUri()->getUserInfo())
		{
			$options[CURLOPT_USERPWD] = $request->getUri()->getUserInfo();
		}

		$options[CURLOPT_FOLLOWLOCATION] = false;

		return $options;
	}
protected function createCurlOptions(RequestInterface $request, ResponseBuilder $responseBuilder)
	{
		$options = array_diff_key($this->options, array_flip([CURLOPT_INFILE, CURLOPT_INFILESIZE]));
		$options[CURLOPT_HTTP_VERSION] = $this->getCurlHttpVersion($request->getProtocolVersion());
		$options[CURLOPT_HEADERFUNCTION] = function ($ch, $data) use ($responseBuilder) {
			$str = trim($data);

			if ('' !== $str)
			{
				if (strpos(strtolower($str), 'http/') === 0)
				{
					$responseBuilder->setStatus($str)->getResponse();
				}
				else
				{
					$responseBuilder->addHeader($str);
				}
			}

			return strlen($data);
		};

		$options[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
		$options[CURLOPT_URL] = (string) $request->getUri();
		$options[CURLOPT_HEADER] = false;

		if (in_array($request->getMethod(), ['GET', 'HEAD', 'TRACE', 'CONNECT']))
		{
			if ($request->getMethod() == 'HEAD')
			{
				$options[CURLOPT_NOBODY] = true;

				unset($options[CURLOPT_READFUNCTION], $options[CURLOPT_WRITEFUNCTION]);
			}
		}
		else
		{
			$options = $this->createCurlBody($request, $options);
		}

		$options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($responseBuilder) {
			return $responseBuilder->getResponse()->getBody()->write($data);
		};
		
		$options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options);

		if ($request->getUri()->getUserInfo())
		{
			$options[CURLOPT_USERPWD] = $request->getUri()->getUserInfo();
		}

		$options[CURLOPT_FOLLOWLOCATION] = false;

		return $options;
	}
protected function createCurlOptions ( RequestInterface $ request , ResponseBuilder $ responseBuilder ) { $ options = array_diff_key ( $ this -> options , array_flip ( [ CURLOPT_INFILE , CURLOPT_INFILESIZE ] ) ) ; $ options [ CURLOPT_HTTP_VERSION ] = $ this -> getCurlHttpVersion ( $ request -> getProtocolVersion ( ) ) ; $ options [ CURLOPT_HEADERFUNCTION ] = function ( $ ch , $ data ) use ( $ responseBuilder ) { $ str = trim ( $ data ) ; if ( '' !== $ str ) { if ( strpos ( strtolower ( $ str ) , 'http/' ) === 0 ) { $ responseBuilder -> setStatus ( $ str ) -> getResponse ( ) ; } else { $ responseBuilder -> addHeader ( $ str ) ; } } return strlen ( $ data ) ; } ; $ options [ CURLOPT_CUSTOMREQUEST ] = $ request -> getMethod ( ) ; $ options [ CURLOPT_URL ] = ( string ) $ request -> getUri ( ) ; $ options [ CURLOPT_HEADER ] = false ; if ( in_array ( $ request -> getMethod ( ) , [ 'GET' , 'HEAD' , 'TRACE' , 'CONNECT' ] ) ) { if ( $ request -> getMethod ( ) == 'HEAD' ) { $ options [ CURLOPT_NOBODY ] = true ; unset ( $ options [ CURLOPT_READFUNCTION ] , $ options [ CURLOPT_WRITEFUNCTION ] ) ; } } else { $ options = $ this -> createCurlBody ( $ request , $ options ) ; } $ options [ CURLOPT_WRITEFUNCTION ] = function ( $ ch , $ data ) use ( $ responseBuilder ) { return $ responseBuilder -> getResponse ( ) -> getBody ( ) -> write ( $ data ) ; } ; $ options [ CURLOPT_HTTPHEADER ] = $ this -> createHeaders ( $ request , $ options ) ; if ( $ request -> getUri ( ) -> getUserInfo ( ) ) { $ options [ CURLOPT_USERPWD ] = $ request -> getUri ( ) -> getUserInfo ( ) ; } $ options [ CURLOPT_FOLLOWLOCATION ] = false ; return $ options ; }
Generates cURL options

@param RequestInterface $request
@param ResponseBuilder  $responseBuilder

@throws \UnexpectedValueException if unsupported HTTP version requested
@throws \RuntimeException if can not read body

@return array
Generates cURL options