* - followRedirects Whether to follow redirects (defaults to false).
* Note: this should only be used when the target URL is trusted,
* to avoid attacks on intranet services accessible by HTTP.
+ * - userAgent A user agent, if you want to override the default
+ * MediaWiki/$wgVersion
* @return Mixed: (bool)false on failure or a string on success
*/
public static function request( $method, $url, $options = array() ) {
}
$req = MWHttpRequest::factory( $url, $options );
+ if( isset( $options['userAgent'] ) ) {
+ $req->setUserAgent( $options['userAgent'] );
+ }
$status = $req->execute();
if ( $status->isOK() ) {
* Relative values of the "Location" header are incorrect as stated in RFC, however they do happen and modern browsers support them.
* This function loops backwards through all locations in order to build the proper absolute URI - Marooned at wikia-inc.com
*
+ * Note that the multiple Location: headers are an artifact of CURL -- they
+ * shouldn't actually get returned this way. Rewrite this when bug 29232 is
+ * taken care of (high-level redirect handling rewrite).
+ *
* @return string
*/
public function getFinalUrl() {
# Check security of URL
$url = $this->getResponseHeader( "Location" );
- if ( !HTTP::isValidURI( $url ) ) {
+ if ( !Http::isValidURI( $url ) ) {
wfDebug( __METHOD__ . ": insecure redirection\n" );
break;
}