Skip to content

Commit

Permalink
#277 - Add support for HTTP/2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed May 29, 2019
1 parent 0e12ef7 commit 663d32e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions code/libraries/joomlatools/library/dispatcher/request/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ abstract class KDispatcherRequestAbstract extends KControllerRequest implements
*/
protected $_ranges;


/**
* Constructor
*
Expand All @@ -110,6 +109,16 @@ public function __construct(KObjectConfig $config)
//Set the base path
$this->setBasePath($config->base_path);

//Set the http version
if(isset($_SERVER['SERVER_PROTOCOL']))
{
$parts = explode('/', $_SERVER['SERVER_PROTOCOL']);

if(isset($parts[1])) {
$this->setVersion($parts[1]);
}
}

//Set document root for IIS
if(!isset($_SERVER['DOCUMENT_ROOT']))
{
Expand Down Expand Up @@ -179,10 +188,6 @@ public function __construct(KObjectConfig $config)

$this->_headers->add($headers);

//Set the version
if (isset($_SERVER['SERVER_PROTOCOL']) && strpos($_SERVER['SERVER_PROTOCOL'], '1.0') !== false) {
$this->setVersion('1.0');
}

//Set request data
if($this->getContentType() == 'application/x-www-form-urlencoded')
Expand Down
4 changes: 2 additions & 2 deletions code/libraries/joomlatools/library/http/message/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public function getHeaders()
}

/**
* Sets the HTTP protocol version (1.0 or 1.1).
* Sets the HTTP protocol version (1.0, 1.1 or 2.0).
*
* @param string $version The HTTP protocol version
* @throws InvalidArgumentException
* @return KHttpMessage
*/
public function setVersion($version)
{
if ($version != '1.1' && $version != '1.0') {
if ($version != '2.0' && $version != '1.1' && $version != '1.0') {
throw new InvalidArgumentException('Not valid or not supported HTTP version: ' . $version);
}

Expand Down

0 comments on commit 663d32e

Please sign in to comment.