This commit is contained in:
thinkphp
2016-12-29 12:05:58 +08:00
parent c4686695bc
commit dd384422a7

View File

@@ -688,7 +688,7 @@ class Request
{ {
if (empty($this->post)) { if (empty($this->post)) {
$content = $this->input; $content = $this->input;
if (empty($_POST) && 'json' == $this->type()) { if (empty($_POST) && 'application/json' == $this->contentType()) {
$this->post = (array) json_decode($content, true); $this->post = (array) json_decode($content, true);
} else { } else {
$this->post = $_POST; $this->post = $_POST;
@@ -713,7 +713,7 @@ class Request
{ {
if (is_null($this->put)) { if (is_null($this->put)) {
$content = $this->input; $content = $this->input;
if ('json' == $this->type()) { if ('application/json' == $this->contentType()) {
$this->put = (array) json_decode($content, true); $this->put = (array) json_decode($content, true);
} else { } else {
parse_str($content, $this->put); parse_str($content, $this->put);
@@ -1348,6 +1348,21 @@ class Request
return $this->server('REMOTE_PORT'); return $this->server('REMOTE_PORT');
} }
/**
* 当前请求 HTTP_CONTENT_TYPE
* @access public
* @return string
*/
public function contentType()
{
$contentType = $this->server('HTTP_CONTENT_TYPE');
if ($contentType) {
list($type) = explode(';', $contentType);
return trim($type);
}
return '';
}
/** /**
* 获取当前请求的路由信息 * 获取当前请求的路由信息
* @access public * @access public