|
|
@@ -93,6 +93,13 @@ class Request implements Stringable
|
|
|
protected bool $isSafe = true;
|
|
|
|
|
|
/**
|
|
|
+ * Is dirty.
|
|
|
+ *
|
|
|
+ * @var bool
|
|
|
+ */
|
|
|
+ protected bool $isDirty = false;
|
|
|
+
|
|
|
+ /**
|
|
|
* Enable cache.
|
|
|
*
|
|
|
* @var bool
|
|
|
@@ -131,6 +138,19 @@ class Request implements Stringable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set get.
|
|
|
+ *
|
|
|
+ * @param array $get
|
|
|
+ * @return Request
|
|
|
+ */
|
|
|
+ public function setGet(array $get): Request
|
|
|
+ {
|
|
|
+ $this->isDirty = true;
|
|
|
+ $this->data['get'] = $get;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Get post.
|
|
|
*
|
|
|
* @param string|null $name
|
|
|
@@ -149,6 +169,19 @@ class Request implements Stringable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set post.
|
|
|
+ *
|
|
|
+ * @param array $post
|
|
|
+ * @return Request
|
|
|
+ */
|
|
|
+ public function setPost(array $post): Request
|
|
|
+ {
|
|
|
+ $this->isDirty = true;
|
|
|
+ $this->data['post'] = $post;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Get header item by name.
|
|
|
*
|
|
|
* @param string|null $name
|
|
|
@@ -168,6 +201,18 @@ class Request implements Stringable
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set headers.
|
|
|
+ * @param array $headers
|
|
|
+ * @return $this
|
|
|
+ */
|
|
|
+ public function setHeaders(array $headers): Request
|
|
|
+ {
|
|
|
+ $this->isDirty = true;
|
|
|
+ $this->data['headers'] = $headers;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Get cookie item by name.
|
|
|
*
|
|
|
* @param string|null $name
|
|
|
@@ -747,4 +792,15 @@ class Request implements Stringable
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __clone()
|
|
|
+ {
|
|
|
+ if ($this->isDirty) {
|
|
|
+ unset($this->data['get'], $this->data['post'], $this->data['headers']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|