Add support for HTTP PUT and HTTP DELETE data #1684

Closed
wants to merge 14 commits into
from

Projects

None yet

6 participants

@hedcler

$this->input->put();
AND
$this->input->delete();

hedcler and others added some commits Aug 3, 2012
@hedcler hedcler Add Support to PUT and REQUEST data in Input Class
Added support to PUT data us gin $this->input->put() and REQUEST data
using $this->input->request()
5e6fe40
@hedcler hedcler Add support to $_REQUEST data
Added support to access $_REQUEST data us gin $this->input->request()
b505f6b
@hedcler hedcler fix line comment 6ca4c02
@hedcler hedcler Revert "fix line comment"
This reverts commit 6ca4c02aa99aac6a0799a7f3506d5c12c18a85c0.
45e5ee5
@hedcler hedcler Revert "Add support to $_REQUEST data"
This reverts commit b505f6b171b9ecdc7f398a74865048fef2d71b45.
163c7fc
@hedcler hedcler Revert "Add Support to PUT and REQUEST data in Input Class"
This reverts commit 5e6fe40ea3e1307c7672270636a2e21652cb6e76.
0ef3b22
@hedcler hedcler Added support to PUT and REQUEST data
Now you can be used:
$this->input->put() or $this->input->request() to access PUT and
REQUEST data respectively.
3fb2821
@hedcler hedcler Correct comment. a1a4cb3
Hedcler Morais Add access to HTTP PUT data
Now we can be use $this->input->put() on HTTP PUT REQUESTS.
eabcef8
Hedcler Morais Adjust comment 778926e
Hedcler Morais Now support too HTTP DELETE data e44aa4b
@hedcler

Now I verify if HTTP METHOD is PUT or DELETE to access the data.

@it-can it-can and 1 other commented on an outdated diff Aug 7, 2012
system/core/Input.php
@@ -173,6 +189,72 @@ public function get($index = NULL, $xss_clean = FALSE)
return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the HTTP PUT array
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
+
+ public function put($index = NULL, $xss_clean = FALSE) {
+
+ if ( $this->server('REQUEST_METHOD') != 'PUT' ) return FALSE;
@winglian

Back-to-back calls to ->put() will fail on subsequent reads because php://input is read-once. You'll need to store the value from php://input during the first read.

@alexbilbie

This should also support PATCH

@joelcox

@hedcler, did you ever get around to the comments stated above?

@narfbg narfbg added a commit that referenced this pull request Nov 6, 2012
@narfbg narfbg Added CI_Input::input_stream()
Helps in reading php://input stream data by caching it when accessed for the first time.

(supersedes PR #1684)
303eef0
@narfbg

See the above commit.

@narfbg narfbg closed this Nov 6, 2012
@hedcler

Thanks @narfbg ! This solves my problem.

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this pull request Jun 29, 2013
@narfbg narfbg Added CI_Input::input_stream()
Helps in reading php://input stream data by caching it when accessed for the first time.

(supersedes PR #1684)
dbd5af9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment