Example #1
0
 public function setResponse(Response $response, $queued = false)
 {
     $response->setEffectiveUrl((string) $this->url);
     if ($queued) {
         $ed = $this->getEventDispatcher();
         $ed->addListener('request.before_send', $f = function ($e) use($response, &$f, $ed) {
             $e['request']->setResponse($response);
             $ed->removeListener('request.before_send', $f);
         }, -9999);
     } else {
         $this->response = $response;
         // If a specific response body is specified, then use it instead of the response's body
         if ($this->responseBody && !$this->responseBody->getCustomData('default') && !$response->isRedirect()) {
             $this->getResponseBody()->write((string) $this->response->getBody());
         } else {
             $this->responseBody = $this->response->getBody();
         }
         $this->setState(self::STATE_COMPLETE);
     }
     return $this;
 }