public static function currentRequest()
    {
        if (php_sapi_name() == 'cli') {
            throw new common_exception_Error('Cannot call ' . __FUNCTION__ . ' from command line');
        }

        $https = self::isHttps();

        $scheme = $https ? 'https' : 'http';
        $port = empty($_SERVER['HTTP_X_FORWARDED_PORT']) ? $_SERVER['SERVER_PORT'] : $_SERVER['HTTP_X_FORWARDED_PORT'];
        $url = $scheme . '://' . $_SERVER['SERVER_NAME'] . ':' . $port . $_SERVER['REQUEST_URI'];
        
        $method = $_SERVER['REQUEST_METHOD'];
        
        if($_SERVER['REQUEST_METHOD'] == self::METHOD_GET){
            $params = $_GET;
        } else { 
            $params = $_POST;
        }
        if (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
        } else {
            $headers = array();
            if (isset($_SERVER['CONTENT_TYPE'])) {
                $headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
            }
            if (isset($_ENV['CONTENT_TYPE'])) {
                $headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
            }
            foreach ($_SERVER as $key => $value) {
                if (substr($key, 0, 5) == "HTTP_") {
                    // this is chaos, basically it is just there to capitalize the first
                    // letter of every word that is not an initial HTTP and strip HTTP
                    // code from przemek
                    $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
                    $headers[$key] = $value;
                }
            }
        }
        return new self($url, $method, $params, $headers);
    }
public static function currentRequest()
    {
        if (php_sapi_name() == 'cli') {
            throw new common_exception_Error('Cannot call ' . __FUNCTION__ . ' from command line');
        }

        $https = self::isHttps();

        $scheme = $https ? 'https' : 'http';
        $port = empty($_SERVER['HTTP_X_FORWARDED_PORT']) ? $_SERVER['SERVER_PORT'] : $_SERVER['HTTP_X_FORWARDED_PORT'];
        $url = $scheme . '://' . $_SERVER['SERVER_NAME'] . ':' . $port . $_SERVER['REQUEST_URI'];
        
        $method = $_SERVER['REQUEST_METHOD'];
        
        if($_SERVER['REQUEST_METHOD'] == self::METHOD_GET){
            $params = $_GET;
        } else { 
            $params = $_POST;
        }
        if (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
        } else {
            $headers = array();
            if (isset($_SERVER['CONTENT_TYPE'])) {
                $headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
            }
            if (isset($_ENV['CONTENT_TYPE'])) {
                $headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
            }
            foreach ($_SERVER as $key => $value) {
                if (substr($key, 0, 5) == "HTTP_") {
                    // this is chaos, basically it is just there to capitalize the first
                    // letter of every word that is not an initial HTTP and strip HTTP
                    // code from przemek
                    $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
                    $headers[$key] = $value;
                }
            }
        }
        return new self($url, $method, $params, $headers);
    }
public static function currentRequest ( ) { if ( php_sapi_name ( ) == 'cli' ) { throw new common_exception_Error ( 'Cannot call ' . __FUNCTION__ . ' from command line' ) ; } $ https = self :: isHttps ( ) ; $ scheme = $ https ? 'https' : 'http' ; $ port = empty ( $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ) ? $ _SERVER [ 'SERVER_PORT' ] : $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ; $ url = $ scheme . '://' . $ _SERVER [ 'SERVER_NAME' ] . ':' . $ port . $ _SERVER [ 'REQUEST_URI' ] ; $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; if ( $ _SERVER [ 'REQUEST_METHOD' ] == self :: METHOD_GET ) { $ params = $ _GET ; } else { $ params = $ _POST ; } if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } else { $ headers = array ( ) ; if ( isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) ) { $ headers [ 'Content-Type' ] = $ _SERVER [ 'CONTENT_TYPE' ] ; } if ( isset ( $ _ENV [ 'CONTENT_TYPE' ] ) ) { $ headers [ 'Content-Type' ] = $ _ENV [ 'CONTENT_TYPE' ] ; } foreach ( $ _SERVER as $ key => $ value ) { if ( substr ( $ key , 0 , 5 ) == "HTTP_" ) { // this is chaos, basically it is just there to capitalize the first // letter of every word that is not an initial HTTP and strip HTTP // code from przemek $ key = str_replace ( " " , "-" , ucwords ( strtolower ( str_replace ( "_" , " " , substr ( $ key , 5 ) ) ) ) ) ; $ headers [ $ key ] = $ value ; } } } return new self ( $ url , $ method , $ params , $ headers ) ; }
Creates an request from the current call

The scheme in used (http|https) will be derived from

* $_SERVER['HTTPS'] in case of a standard deployment
* $_SERVER['HTTP_X_FORWARDED_PROTO'] or $_SERVER['HTTP_X_FORWARDED_SSL'] in case of being deployed behing a load balancer/proxy.

If no clues about whether HTTPS is in use are found, HTTP will be the scheme of the current request.

@return common_http_Request A request corresponding to the current HTTP(S) context.
@throws common_exception_Error In case of a CLI execution context.
Creates an request from the current call