}
$req = MWHttpRequest::factory( $url, $options );
- if( isset( $options['userAgent'] ) ) {
- $req->setUserAgent( $options['userAgent'] );
- }
$status = $req->execute();
if ( $status->isOK() ) {
} else {
$this->timeout = $wgHTTPTimeout;
}
+ if( isset( $options['userAgent'] ) ) {
+ $this->setUserAgent( $options['userAgent'] );
+ }
$members = array( "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo",
"method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" );
$this->$o = $options[$o];
}
}
+
+ if ( $this->noProxy ) {
+ $this->proxy = ''; // noProxy takes precedence
+ }
}
/**
}
/**
- * Take care of setting up the proxy
- * (override in subclass)
+ * Take care of setting up the proxy (do nothing if "noProxy" is set)
*
- * @return String
+ * @return void
*/
public function proxySetup() {
global $wgHTTPProxy;
- if ( $this->proxy && !$this->noProxy ) {
+ if ( $this->proxy || !$this->noProxy ) {
return;
}
$this->setReferer( wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) );
}
- /**
- * Set up the proxy, but
- * clear the proxy when $noProxy is set (takes precedence)
- */
- $this->proxySetup();
+ $this->proxySetup(); // set up any proxy as needed
if ( !$this->callback ) {
$this->setCallback( array( $this, 'read' ) );
if ( $this->method == 'POST' ) {
// Required for HTTP 1.0 POSTs
$this->reqHeaders['Content-Length'] = strlen( $this->postData );
- $this->reqHeaders['Content-type'] = "application/x-www-form-urlencoded";
+ if( !isset( $this->reqHeaders['Content-Type'] ) ) {
+ $this->reqHeaders['Content-Type'] = "application/x-www-form-urlencoded";
+ }
}
$options = array();
- if ( $this->proxy && !$this->noProxy ) {
+ if ( $this->proxy ) {
$options['proxy'] = $this->urlToTCP( $this->proxy );
$options['request_fulluri'] = true;
}