Adds two new options (username and password) to the
MWHttpRequest (and HTTP helper class) to enable
support for HTTP Basic Authentication on outgoing HTTP
connections.
Change-Id: If83f025bbe63769ba7bb4a824c5f12d5f1ec640a
* - userAgent A user agent, if you want to override the default
* MediaWiki/$wgVersion
* - logger A \Psr\Logger\LoggerInterface instance for debug logging
+ * - username Username for HTTP Basic Authentication
+ * - password Password for HTTP Basic Authentication
* @param string $caller The method making this request, for profiling
* @return string|bool (bool)false on failure or a string on success
*/
if ( isset( $options['userAgent'] ) ) {
$this->setUserAgent( $options['userAgent'] );
}
+ if ( isset( $options['username'] ) && isset( $options['password'] ) ) {
+ $this->setHeader(
+ 'Authorization',
+ 'Basic ' . base64_encode( $options['username'] . ':' . $options['password'] )
+ );
+ }
$members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo",
"method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ];