summaryrefslogtreecommitdiff
path: root/framework/Web/THttpRequest.php
diff options
context:
space:
mode:
authorrojaro <>2010-05-18 09:10:39 +0000
committerrojaro <>2010-05-18 09:10:39 +0000
commit0e53d6ec7b706d71b83230aa0165ec19a2cc10b7 (patch)
tree5c28a48df3d1a6f4317a8f59ff0e07e5bdf4a2fa /framework/Web/THttpRequest.php
parenta121c33a35e2f729d6f7633515ea78073f381039 (diff)
By default getContentType() now only returns the mimetype
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r--framework/Web/THttpRequest.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index ed981c90..fbceef38 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -319,11 +319,18 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
- * @return string content type (e.g. 'application/json') or null if not specified
+ * @param boolean $mimetypeOnly whether to return only the mimetype (default: true)
+ * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified
*/
- public function getContentType()
+ public function getContentType($mimetypeOnly = true)
{
- return isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : null;
+ if(!isset($_SERVER['CONTENT_TYPE']))
+ return null;
+
+ if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false)
+ return substr($_SERVER['CONTENT_TYPE'], 0, $_pos);
+
+ return $_SERVER['CONTENT_TYPE'];
}
/**