Go to the documentation of this file.
54 $this->requestTime = microtime(
true );
56 if ( is_array(
$data ) ) {
59 throw new MWException(
"FauxRequest() got bogus data" );
62 if ( $session instanceof
MediaWiki\Session\Session ) {
63 $this->sessionId = $session->getSessionId();
64 } elseif ( is_array( $session ) ) {
65 $mwsession = SessionManager::singleton()->getEmptySession( $this );
66 $this->sessionId = $mwsession->getSessionId();
67 foreach ( $session as $key => $value ) {
68 $mwsession->set( $key, $value );
70 } elseif ( $session !==
null ) {
71 throw new MWException(
"FauxRequest() got bogus session" );
88 public function getText( $name, $default =
'' ) {
89 # Override; don't recode since we're using internal data
90 return (
string)$this->
getVal( $name, $default );
105 return $this->
wasPosted ?
'POST' :
'GET';
115 public function getCookie( $key, $prefix =
null, $default =
null ) {
116 if ( $prefix ===
null ) {
120 $name = $prefix . $key;
121 return $this->cookies[$name] ?? $default;
130 public function setCookie( $key, $value, $prefix =
null ) {
131 $this->
setCookies( [ $key => $value ], $prefix );
140 if ( $prefix ===
null ) {
144 foreach (
$cookies as $key => $value ) {
145 $name = $prefix . $key;
146 $this->cookies[$name] = $value;
155 $this->requestUrl = $url;
164 if ( $this->requestUrl ===
null ) {
187 foreach (
$headers as $name => $val ) {
188 $name = strtoupper( $name );
189 $this->headers[$name] = $val;
197 if ( $this->sessionId !==
null ) {
198 return iterator_to_array( $this->
getSession() );
204 return $this->
wasPosted ? $this->data : [];
initHeaders()
Initialise the header list.
string[] $headers
Lazy-initialized request headers indexed by upper-case header name.
WebRequest clone which takes values from a provided array.
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')
Stable to call.
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.
getPostValues()
Get the values passed via POST.
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
setCookies( $cookies, $prefix=null)
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.