protected $maxConnsPerHost = 50;
/** @var string|null proxy */
protected $proxy;
+ /** @var string */
+ protected $userAgent = 'MW-MultiHttpClient';
/**
* @param array $options
* - proxy : HTTP proxy to use
* - usePipelining : whether to use HTTP pipelining if possible (for all hosts)
* - maxConnsPerHost : maximum number of concurrent connections (per host)
+ * - userAgent : The User-Agent header value to send
* @throws Exception
*/
public function __construct( array $options ) {
}
}
static $opts = array(
- 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy'
+ 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy', 'userAgent'
);
foreach ( $opts as $key ) {
if ( isset( $options[$key] ) ) {
$req['headers']['content-length'] = 0;
}
+ if ( !isset( $req['headers']['user-agent'] ) ) {
+ $req['headers']['user-agent'] = $this->userAgent;
+ }
+
$headers = array();
foreach ( $req['headers'] as $name => $value ) {
if ( strpos( $name, ': ' ) ) {
}
/**
- * @return Title|null Title object (pagename+fragment) for the section, null if none or not supported
+ * @return Title|null Title object (pagename+fragment) for the section,
+ * null if none or not supported
*/
function getSectionTitle() {
return null;
<ruleset name="MediaWiki">
<rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<!-- Disable failing rules -->
- <exclude name="Generic.Files.LineLength"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment"/>