/** * @param Request $request * @return array */ protected function prepareHeaders(Request $request) { $headers = $request->getHeaders(); if (null !== $request->getContent() && !isset($headers['Content-Type'])) { $headers['Content-Type'] = 'application/x-www-form-urlencoded'; } return $headers; }
/** * @param Request $request * @return Response */ public function request(Request $request) { $headers = new Headers(); $headers->addHeaders($request->getHeaders()); $zendRequest = new ZendRequest(); $zendRequest->setVersion($request->getProtocolVersion()); $zendRequest->setMethod($request->getMethod()); $zendRequest->setUri((string) $request->getUrl()); $zendRequest->setHeaders($headers); $zendRequest->setContent($request->getContent()); /** @var ZendResponse $zendResponse */ $zendResponse = $this->client->send($zendRequest); return new Response((string) $zendResponse->getVersion(), $zendResponse->getStatusCode(), $zendResponse->getReasonPhrase(), $zendResponse->getHeaders()->toArray(), $zendResponse->getContent()); }