Beispiel #1
0
 public function testBasic()
 {
     $bag = new HeaderBag(['CONTENT_TYPE' => 'application/json', 'Accept' => 'application/json']);
     $this->assertEquals(['application/json'], $bag->get('Content-Type'));
     $this->assertEquals('application/json', $bag->first('Content-Type'));
     $bag->with('Content-Type', 'foo');
     $this->assertEquals(['application/json', 'foo'], $bag->get('Content-Type'));
 }
Beispiel #2
0
 /**
  * Prepare the response to ready to send to client.
  */
 public function prepare()
 {
     if (!$this->prepared) {
         $this->content = is_string($this->data) ? $this->data : Json::encode($this->data);
         if (!is_string($this->data)) {
             $this->headers->set('Content-Type', 'application/json');
         }
         $this->prepared = true;
     }
 }