Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief HTTP Response Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -42,6 +42,11 @@ class _Response
|
||||
* @brief HTTP Headers
|
||||
*/
|
||||
public $httpHeaders = NULL;
|
||||
|
||||
/**
|
||||
* @brief Cookies returned in the response
|
||||
*/
|
||||
public $cookies = array();
|
||||
|
||||
/**
|
||||
* @brief Response Content
|
||||
@@ -79,7 +84,7 @@ class _Response
|
||||
}
|
||||
|
||||
/* If we have received a 1xx response code, that means it's not the final response */
|
||||
if ( mb_substr( $this->httpResponseCode, 0, 1 ) == 1 )
|
||||
if ( mb_substr( $this->httpResponseCode, 0, 1 ) == 1 OR ( $this->httpResponseCode == 200 AND trim( $this->httpResponseText ) == 'Connection established' ) )
|
||||
{
|
||||
$content = trim( mb_substr( $content, $firstLineBreak ) );
|
||||
}
|
||||
@@ -112,6 +117,26 @@ class _Response
|
||||
if ( $line !== '' and preg_match( "/^(.+?): (.+?)$/", $line, $matches ) )
|
||||
{
|
||||
$this->httpHeaders[ $matches[1] ] = $matches[2];
|
||||
|
||||
if( mb_strtolower( $matches[1] ) == 'set-cookie' )
|
||||
{
|
||||
$cookie = array();
|
||||
$cookieDetails = explode( ';', $matches[2] );
|
||||
|
||||
$cookieInfo = array_shift( $cookieDetails );
|
||||
$cookieInfo = explode( '=', $cookieInfo );
|
||||
|
||||
$cookie[ $cookieInfo[0] ] = array( 'value' => rawurldecode( $cookieInfo[1] ) );
|
||||
|
||||
foreach( $cookieDetails as $cookieDetail )
|
||||
{
|
||||
$cookieDetail = explode( '=', $cookieDetail );
|
||||
|
||||
$cookie[ $cookieInfo[0] ][ trim( $cookieDetail[0] ) ] = ( isset( $cookieDetail[1] ) ) ? $cookieDetail[1] : true;
|
||||
}
|
||||
|
||||
$this->cookies = array_merge( $this->cookies, $cookie );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +148,7 @@ class _Response
|
||||
|
||||
if( isset( $this->httpHeaders['Transfer-Encoding'] ) and mb_strtolower( trim( $this->httpHeaders['Transfer-Encoding'] ) ) == 'chunked' )
|
||||
{
|
||||
if ( $decoded = $this->decodeChunked( $this->content ) )
|
||||
if ( ( $decoded = $this->decodeChunked( $this->content ) ) !== '' )
|
||||
{
|
||||
$this->content = $decoded;
|
||||
}
|
||||
@@ -194,11 +219,11 @@ class _Response
|
||||
*/
|
||||
public function decodeJson( $asArray=TRUE )
|
||||
{
|
||||
if ( !( $json = json_decode( $this->content, $asArray ) ) )
|
||||
$json = json_decode( $this->content, $asArray );
|
||||
if ( $json === FALSE )
|
||||
{
|
||||
throw new \RuntimeException('BAD_JSON');
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user