summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authortof <>2008-05-16 12:59:42 +0000
committertof <>2008-05-16 12:59:42 +0000
commitf313138c9545d567d411e80aead77eb03c83ae25 (patch)
treeddd5a102a0f2da51fb9ed717b50904aaedcfddd8 /framework/Web
parentaaea27e8104ffc486d19ed0d9c88405ca1fc32cd (diff)
Fixed #841
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpRequest.php8
-rw-r--r--framework/Web/THttpResponse.php8
2 files changed, 15 insertions, 1 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index aec71262..23ab26ec 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -345,6 +345,14 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * @return string the requested http procolol. Blank string if not defined.
+ */
+ public function getHttpProtocolVersion ()
+ {
+ return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:'';
+ }
+
+ /**
* @return string part of that request URL after the host info (including pathinfo and query string)
*/
public function getRequestUri()
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index af751828..64c9eaba 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -257,8 +257,11 @@ class THttpResponse extends TModule implements ITextWriter
/**
* Set the HTTP status code for the response.
+ * The code and its reason will be sent to client using the currently requested http protocol version (see {@link THttpRequest::getHttpProtocolVersion})
+ * Keep in mind that HTTP/1.0 clients might not understand all status codes from HTTP/1.1
*
* @param integer HTTP status code
+ * @param string HTTP status reason, defaults to standard HTTP reasons
*/
public function setStatusCode($status, $reason=null)
{
@@ -432,7 +435,10 @@ class THttpResponse extends TModule implements ITextWriter
*/
protected function sendHttpHeader ()
{
- header("HTTP/1.1 {$this->_status} {$this->_reason}", true, $this->_status);
+ if (($version=$this->getRequest()->getHttpProtocolVersion())==='')
+ header (' ', true, $this->_status);
+ else
+ header($version.' '.$this->_status.' '.$this->_reason, true, $this->_status);
}
/**