Kaynağa Gözat

Update Response.php

Add withoutHeader getHeader rawBody method for response
walkor 5 yıl önce
ebeveyn
işleme
3279230d09
1 değiştirilmiş dosya ile 51 ekleme ve 0 silme
  1. 51 0
      Protocols/Http/Response.php

+ 51 - 0
Protocols/Http/Response.php

@@ -165,6 +165,17 @@ class Response
     }
 
     /**
+     * Set header.
+     *
+     * @param $name
+     * @param $value
+     * @return Response
+     */
+    public function withHeader($name, $value) {
+        return $this->header($name, $value);
+    }
+
+    /**
      * Set headers.
      *
      * @param $headers
@@ -174,6 +185,39 @@ class Response
         $this->_header = \array_merge($this->_header, $headers);
         return $this;
     }
+    
+    /**
+     * Remove headers.
+     *
+     * @param $name
+     * @return $this
+     */
+    public function withoutHeader($name) {
+        unset($this->_header[$name]);
+        return $this;
+    }
+
+    /**
+     * Get header.
+     *
+     * @param $name
+     * @return null|array|string
+     */
+    public function getHeader($name) {
+        if (!isset($this->_header[$name])) {
+            return null;
+        }
+        return $this->_header[$name];
+    }
+
+    /**
+     * Get header.
+     *
+     * @return array
+     */
+    public function getHeaders() {
+        return $this->_header;
+    }
 
     /**
      * Set status.
@@ -211,6 +255,13 @@ class Response
     }
 
     /**
+     * Get http raw body.
+     */
+    public function rawBody() {
+        return $this->_body;
+    }
+
+    /**
      * Send file.
      *
      * @param $file