mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
fix the source to get content type (#1622)
This commit is contained in:
parent
9910a9cddc
commit
91ae56484d
@ -351,6 +351,19 @@ class Request
|
||||
return ($this->pathInfo = '/' . ltrim(urldecode($pathInfo), '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求的内容类型
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentType(): ?string
|
||||
{
|
||||
return $this->getServer(
|
||||
'CONTENT_TYPE',
|
||||
$this->getServer('HTTP_CONTENT_TYPE')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取环境变量
|
||||
*
|
||||
@ -492,7 +505,10 @@ class Request
|
||||
*/
|
||||
public function isJson(): bool
|
||||
{
|
||||
return !!preg_match("/^\s*application\/json(;|$)/i", $this->getHeader('Content-Type', ''));
|
||||
return !!preg_match(
|
||||
"/^\s*application\/json(;|$)/i",
|
||||
$this->getContentType() ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,6 +213,16 @@ class Request
|
||||
return $this->request->makeUriByRequest($parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求的内容类型
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentType(): ?string
|
||||
{
|
||||
return $this->request->getContentType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取环境变量
|
||||
*
|
||||
@ -317,6 +327,16 @@ class Request
|
||||
return $this->request->isAjax();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为json
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isJson(): bool
|
||||
{
|
||||
return $this->request->isJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断输入是否满足要求
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user