Ejemplo n.º 1
0
 /**
  * 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()));
 }
Ejemplo n.º 2
0
 /**
  * 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');
 }
Ejemplo n.º 3
0
 public function prepare(HttpMessage $message)
 {
     $header = new ContentTypeHeader(Http::FORM_MULTIPART_ENCODED);
     $header->setDirective('boundary', $this->boundary);
     $message->setHeader($header);
 }
Ejemplo n.º 4
0
 public function prepare(HttpMessage $message)
 {
     if (!$message->hasHeader('Content-Type')) {
         $message->setHeader('Content-Type', 'text/plain; charset="utf-8"');
     }
 }
Ejemplo n.º 5
0
 public function prepare(HttpMessage $message)
 {
     if (!$message->hasHeader('Content-Type')) {
         $message->setHeader('Content-Type', 'application/octet-stream');
     }
 }
Ejemplo n.º 6
0
 public function prepare(HttpMessage $message)
 {
     $header = new ContentTypeHeader('application/hal+json');
     $header->setCharset('utf-8');
     $message->setHeader($header);
 }
Ejemplo n.º 7
0
 public function prepare(HttpMessage $message)
 {
     $header = new ContentTypeHeader(Http::FORM_ENCODED);
     $header->setDirective('charset', 'utf-8');
     $message->setHeader($header);
 }