/** * Create a new HTTP response. * * @param integer $status HTTP status code. * @param string $reason * @param string $protocol */ public function __construct($status = Http::CODE_OK, $reason = '', $protocol = 'HTTP/1.1') { parent::__construct($protocol); $this->setStatus($status); $this->setReason($reason); if ($this->reason == '') { $this->reason = Http::getReason($this->status, $this->reason); } $this->setHeader('Date', gmdate(Http::DATE_FORMAT_RFC1123, time())); }
/** * Create a new HTTP request. * * @param mixed $uri The absolute URI that has been requested. * @param string $method The HTTP request method being used. * @param string $protocol The HTTP protocol version being used. */ public function __construct($uri, $method = Http::METHOD_GET, $protocol = 'HTTP/1.1') { parent::__construct($protocol); $this->uri = new Uri($uri); $this->rawUri = '/' . (string) $this->uri->getPath(); if (count($this->uri->getQuery())) { $this->rawUri .= '?' . $this->uri->getQueryString(); } $this->setMethod($method); $this->setHeader('Host', $uri->getHost(true)); $this->setHeader('Connection', 'close'); }
public function prepare(HttpMessage $message) { $header = new ContentTypeHeader(Http::FORM_MULTIPART_ENCODED); $header->setDirective('boundary', $this->boundary); $message->setHeader($header); }
public function prepare(HttpMessage $message) { if (!$message->hasHeader('Content-Type')) { $message->setHeader('Content-Type', 'text/plain; charset="utf-8"'); } }
public function prepare(HttpMessage $message) { if (!$message->hasHeader('Content-Type')) { $message->setHeader('Content-Type', 'application/octet-stream'); } }
public function prepare(HttpMessage $message) { $header = new ContentTypeHeader('application/hal+json'); $header->setCharset('utf-8'); $message->setHeader($header); }
public function prepare(HttpMessage $message) { $header = new ContentTypeHeader(Http::FORM_ENCODED); $header->setDirective('charset', 'utf-8'); $message->setHeader($header); }