src/Request.php
public static function fromRequest(
		$method = null,
		$url = null,
		array $params = null
	) {
		$scheme = ( !isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] != 'on' ) ?
			'http' : 'https';
		$url = ( $url ?: $scheme ) .
			'://' . $_SERVER['SERVER_NAME'] .
			':' .
			$_SERVER['SERVER_PORT'] .
			$_SERVER['REQUEST_URI'];
		$method = $method ?: $_SERVER['REQUEST_METHOD'];

		// We weren't handed any params, so let's find the ones relevant
		// to this request. If you run XML-RPC or similar you should use this
		// to provide your own parsed parameter-list
		if ( !$params ) {
			// Find request headers
			$headers = Util::getHeaders();

			// Parse the query-string to find GET params
			$params = Util::parseParameters( $_SERVER['QUERY_STRING'] );

			// It's a POST request of the proper content-type, so parse POST
			// params and add those overriding any duplicates from GET
			if ( $method === 'POST' &&
				isset( $headers['Content-Type'] ) &&
				strstr( $headers['Content-Type'],
					'application/x-www-form-urlencoded'
				)
			) {
				$post_data = Util::parseParameters(
					file_get_contents( self::$POST_INPUT )
				);
				$params = array_merge( $params, $post_data );
			}

			// We have a Authorization-header with OAuth data. Parse the header
			// and add those overriding any duplicates from GET or POST
			if ( isset( $headers['Authorization'] ) &&
				substr( $headers['Authorization'], 0, 6 ) === 'OAuth '
			) {
				$header_params = Util::splitHeader( $headers['Authorization'] );
				$params = array_merge( $params, $header_params );
			}
		}

		return new Request( $method, $url, $params );
	}
public static function fromRequest(
		$method = null,
		$url = null,
		array $params = null
	) {
		$scheme = ( !isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] != 'on' ) ?
			'http' : 'https';
		$url = ( $url ?: $scheme ) .
			'://' . $_SERVER['SERVER_NAME'] .
			':' .
			$_SERVER['SERVER_PORT'] .
			$_SERVER['REQUEST_URI'];
		$method = $method ?: $_SERVER['REQUEST_METHOD'];

		// We weren't handed any params, so let's find the ones relevant
		// to this request. If you run XML-RPC or similar you should use this
		// to provide your own parsed parameter-list
		if ( !$params ) {
			// Find request headers
			$headers = Util::getHeaders();

			// Parse the query-string to find GET params
			$params = Util::parseParameters( $_SERVER['QUERY_STRING'] );

			// It's a POST request of the proper content-type, so parse POST
			// params and add those overriding any duplicates from GET
			if ( $method === 'POST' &&
				isset( $headers['Content-Type'] ) &&
				strstr( $headers['Content-Type'],
					'application/x-www-form-urlencoded'
				)
			) {
				$post_data = Util::parseParameters(
					file_get_contents( self::$POST_INPUT )
				);
				$params = array_merge( $params, $post_data );
			}

			// We have a Authorization-header with OAuth data. Parse the header
			// and add those overriding any duplicates from GET or POST
			if ( isset( $headers['Authorization'] ) &&
				substr( $headers['Authorization'], 0, 6 ) === 'OAuth '
			) {
				$header_params = Util::splitHeader( $headers['Authorization'] );
				$params = array_merge( $params, $header_params );
			}
		}

		return new Request( $method, $url, $params );
	}
public static function fromRequest ( $ method = null , $ url = null , array $ params = null ) { $ scheme = ( ! isset ( $ _SERVER [ 'HTTPS' ] ) || $ _SERVER [ 'HTTPS' ] != 'on' ) ? 'http' : 'https' ; $ url = ( $ url ? : $ scheme ) . '://' . $ _SERVER [ 'SERVER_NAME' ] . ':' . $ _SERVER [ 'SERVER_PORT' ] . $ _SERVER [ 'REQUEST_URI' ] ; $ method = $ method ? : $ _SERVER [ 'REQUEST_METHOD' ] ; // We weren't handed any params, so let's find the ones relevant // to this request. If you run XML-RPC or similar you should use this // to provide your own parsed parameter-list if ( ! $ params ) { // Find request headers $ headers = Util :: getHeaders ( ) ; // Parse the query-string to find GET params $ params = Util :: parseParameters ( $ _SERVER [ 'QUERY_STRING' ] ) ; // It's a POST request of the proper content-type, so parse POST // params and add those overriding any duplicates from GET if ( $ method === 'POST' && isset ( $ headers [ 'Content-Type' ] ) && strstr ( $ headers [ 'Content-Type' ] , 'application/x-www-form-urlencoded' ) ) { $ post_data = Util :: parseParameters ( file_get_contents ( self :: $ POST_INPUT ) ) ; $ params = array_merge ( $ params , $ post_data ) ; } // We have a Authorization-header with OAuth data. Parse the header // and add those overriding any duplicates from GET or POST if ( isset ( $ headers [ 'Authorization' ] ) && substr ( $ headers [ 'Authorization' ] , 0 , 6 ) === 'OAuth ' ) { $ header_params = Util :: splitHeader ( $ headers [ 'Authorization' ] ) ; $ params = array_merge ( $ params , $ header_params ) ; } } return new Request ( $ method , $ url , $ params ) ; }
Attempt to build up a request from what was passed to the server

@param string|null $method
@param string|null $url
@param array|null $params
@return Request
Attempt to build up a request from what was passed to the server