Explorar el Código

Update Response.php

Add withoutHeader getHeader rawBody method for response
walkor hace 5 años
padre
commit
3279230d09
Se han modificado 1 ficheros con 51 adiciones y 0 borrados
  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