public function parseBody($content) { $headers = $this->request->getHeaders(); if (array_key_exists('Content-Type', $headers)) { if (strpos($headers['Content-Type'], 'multipart/') === 0) { //TODO :: parse the content while it is streaming preg_match("/boundary=\"?(.*)\"?\$/", $headers['Content-Type'], $matches); $boundary = $matches[1]; $parser = new MultipartParser($content, $boundary); $parser->parse(); $this->request->setPost($parser->getPost()); $this->request->setFiles($parser->getFiles()); return; } if (strtolower($headers['Content-Type']) == 'application/x-www-form-urlencoded') { parse_str($content, $result); $this->request->setPost($result); return; } if (strtolower($headers['Content-Type']) == 'application/json') { $result = json_decode($content); $this->request->setBody($result); return; } } $this->request->setBody($content); }