/** * @param string $body * @param string $headers * @param Request $request */ public function __construct($body, $headers, Request $request) { $this->request = $request; $this->raw_headers = $headers; $this->raw_body = $body; $this->code = $this->_parseCode($headers); $this->headers = Response\Headers::fromString($headers); $this->_interpretHeaders(); $this->body = $this->_parse($body); }
/** * @param string $body * @param string $headers * @param Request $request * @param array $meta_data */ public function __construct($body, $headers, Request $request, array $meta_data = array()) { $this->request = $request; $this->raw_headers = $headers; $this->raw_body = $body; $this->meta_data = $meta_data; $this->code = $this->_parseCode($headers); $this->headers = Response\Headers::fromString($headers); $this->_interpretHeaders(); if ($this->hasErrors()) { $this->body = $body; } else { $this->body = $this->_parse($body); } }
/** * Parse text headers from response into * array of key value pairs * @param string $headers raw headers * @return array parse headers */ public function _parseHeaders($headers) { return Response\Headers::fromString($headers)->toArray(); }