Index: trunk/phase3/includes/Setup.php |
— | — | @@ -364,14 +364,16 @@ |
365 | 365 | $wgLocalTZoffset = date( 'Z' ) / 60; |
366 | 366 | } |
367 | 367 | |
368 | | -# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor |
369 | | -$wgRequest = new WebRequest; |
370 | | - |
371 | 368 | # Useful debug output |
372 | 369 | global $wgCommandLineMode; |
373 | 370 | if ( $wgCommandLineMode ) { |
| 371 | + $wgRequest = new FauxRequest( array() ); |
| 372 | + |
374 | 373 | wfDebug( "\n\nStart command line script $self\n" ); |
375 | 374 | } else { |
| 375 | + # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor |
| 376 | + $wgRequest = new WebRequest; |
| 377 | + |
376 | 378 | $debug = "Start request\n\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}"; |
377 | 379 | |
378 | 380 | if ( $wgDebugPrintHttpHeaders ) { |
Index: trunk/phase3/includes/WebResponse.php |
— | — | @@ -77,6 +77,7 @@ |
78 | 78 | class FauxResponse extends WebResponse { |
79 | 79 | private $headers; |
80 | 80 | private $cookies; |
| 81 | + private $code; |
81 | 82 | |
82 | 83 | /** |
83 | 84 | * Stores a HTTP header |
— | — | @@ -85,11 +86,20 @@ |
86 | 87 | * @param $http_response_code null|int Forces the HTTP response code to the specified value. |
87 | 88 | */ |
88 | 89 | public function header( $string, $replace = true, $http_response_code = null ) { |
89 | | - list( $key, $val ) = explode( ":", $string, 2 ); |
| 90 | + $match = array(); |
| 91 | + if ( preg_match( '~^HTTP/1.\d (\d+)\D*$~', $string, $match ) ) { |
| 92 | + $this->code = intval( $match[1] ); |
| 93 | + } else { |
| 94 | + list( $key, $val ) = explode( ":", $string, 2 ); |
90 | 95 | |
91 | | - if( $replace || !isset( $this->headers[$key] ) ) { |
92 | | - $this->headers[$key] = $val; |
| 96 | + if( $replace || !isset( $this->headers[$key] ) ) { |
| 97 | + $this->headers[$key] = $val; |
| 98 | + } |
93 | 99 | } |
| 100 | + |
| 101 | + if ( $http_response_code !== null ) { |
| 102 | + $this->code = intval( $http_response_code ); |
| 103 | + } |
94 | 104 | } |
95 | 105 | |
96 | 106 | /** |
— | — | @@ -101,6 +111,15 @@ |
102 | 112 | } |
103 | 113 | |
104 | 114 | /** |
| 115 | + * Get the HTTP response code, null if not set |
| 116 | + * |
| 117 | + * @return Int or null |
| 118 | + */ |
| 119 | + public function getStatusCode() { |
| 120 | + return $this->code; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
105 | 124 | * @param $name String: name of cookie |
106 | 125 | * @param $value String: value to give cookie |
107 | 126 | * @param $expire Int: number of seconds til cookie expires |