From a8f50e2f4b6dc2d7a10947757d8fd8b13b108b5d Mon Sep 17 00:00:00 2001 From: Cuonic Date: Thu, 26 Jun 2014 10:39:38 +0200 Subject: [PATCH 2/3] Fixed problem with Request Json array Fixed content type for browsers that also send character encoding, and now send the JSON data through the Collection system. --- flight/net/Request.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flight/net/Request.php b/flight/net/Request.php index 8c784d2..4b485f2 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -185,9 +185,11 @@ class Request { $this->query->setData($_GET); } - if ($this->type == 'application/json' && $this->body != '') { + if (strpos($this->type, 'application/json') === 0 && $this->body != '') { $this->json = json_decode($this->body, true); + $this->json = new Collection($this->json); } + } /** From d097c21dcbaaefe2dfb293a3468cdac83918daed Mon Sep 17 00:00:00 2001 From: Cuonic Date: Thu, 26 Jun 2014 11:06:38 +0200 Subject: [PATCH 3/3] Fixed code to work when body is empty Now passes empty JSON data through the collection system to remove errors about unknown keys when posting via other methods --- flight/net/Request.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flight/net/Request.php b/flight/net/Request.php index 4b485f2..d66a5a7 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -187,9 +187,12 @@ class Request { if (strpos($this->type, 'application/json') === 0 && $this->body != '') { $this->json = json_decode($this->body, true); - $this->json = new Collection($this->json); + } else { + $this->json = array(); } + $this->json = new Collection($this->json); + } /**