protected function createOptions(RequestInterface $request, ResponseBuilder $response)
	{
		$options = $this->options;

		// These options default to false and cannot be changed on set up.
		// The options should be provided with the request instead.
		$options[CURLOPT_FOLLOWLOCATION] = false;
		$options[CURLOPT_HEADER]         = false;
		$options[CURLOPT_RETURNTRANSFER] = false;

		try {
			$options[CURLOPT_HTTP_VERSION] = $this->getProtocolVersion($request->getProtocolVersion());
		}
		catch (UnexpectedValueException $e) {
			throw new RequestException($e->getMessage(), $request);
		}

		$options[CURLOPT_URL] = (string)$request->getUri();

		$options = $this->addRequestBodyOptions($request, $options);

		$options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options);

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

		$options[CURLOPT_HEADERFUNCTION] = function ($ch, $data) use ($response) {
			$clean_data = trim($data);

			if ($clean_data !== '') {
				if (strpos(strtoupper($clean_data), 'HTTP/') === 0) {
					$response->setStatus($clean_data)->getResponse();
				}
				else {
					$response->addHeader($clean_data);
				}
			}

			return strlen($data);
		};

		$options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($response) {
			return $response->getResponse()->getBody()->write($data);
		};

		return $options;
	}