Go to the documentation of this file.
50 $this->requestTime = microtime(
true );
52 if ( is_array(
$data ) ) {
55 throw new MWException(
"FauxRequest() got bogus data" );
58 if ( $session instanceof
MediaWiki\Session\Session ) {
59 $this->sessionId = $session->getSessionId();
60 } elseif ( is_array( $session ) ) {
61 $mwsession = SessionManager::singleton()->getEmptySession( $this );
62 $this->sessionId = $mwsession->getSessionId();
63 foreach ( $session as $key => $value ) {
64 $mwsession->set( $key, $value );
66 } elseif ( $session !==
null ) {
67 throw new MWException(
"FauxRequest() got bogus session" );
84 public function getText( $name, $default =
'' ) {
85 # Override; don't recode since we're using internal data
86 return (
string)$this->
getVal( $name, $default );
101 return $this->
wasPosted ?
'POST' :
'GET';
111 public function getCookie( $key, $prefix =
null, $default =
null ) {
112 if ( $prefix ===
null ) {
116 $name = $prefix . $key;
117 return $this->cookies[$name] ?? $default;
126 public function setCookie( $key, $value, $prefix =
null ) {
127 $this->
setCookies( [ $key => $value ], $prefix );
136 if ( $prefix ===
null ) {
140 foreach (
$cookies as $key => $value ) {
141 $name = $prefix . $key;
142 $this->cookies[$name] = $value;
151 $this->requestUrl = $url;
160 if ( $this->requestUrl ===
null ) {
183 foreach (
$headers as $name => $val ) {
184 $name = strtoupper( $name );
185 $this->headers[$name] = $val;
193 if ( $this->sessionId !==
null ) {
194 return iterator_to_array( $this->
getSession() );
initHeaders()
Initialise the header list.
WebRequest clone which takes values from a provided array.
array $headers
Lazy-initialized request headers indexed by upper-case header name.
getRawQueryString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
getRawPostString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
array $data
The parameters from $_GET, $_POST and the path router.
getRawInput()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
string $protocol
Cached URL protocol.
getProtocol()
Get the current URL protocol (http or https)
setCookie( $key, $value, $prefix=null)
getText( $name, $default='')
getSession()
Return the session for this request.
__construct( $data=[], $wasPosted=false, $session=null, $protocol='http')
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getMethod()
Get the HTTP method used for this request.
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
setCookies( $cookies, $prefix=null)
checkUrlExtension( $extWhitelist=[])
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.