XMLHttpRequest does not allow overriding the "User-Agent" header. To
allow such clients to make effective use of the api-feature-usage log,
let's give them a different header they can use.
Change-Id: Ia1e4f52f35f8d9a8e9f5590a00854d14c11f7cc9
' "' . wfUrlencode( str_replace( ' ', '_', $this->getUser()->getName() ) ) . '"' .
' "' . $request->getIP() . '"' .
' "' . addslashes( $request->getHeader( 'Referer' ) ) . '"' .
- ' "' . addslashes( $request->getHeader( 'User-agent' ) ) . '"';
+ ' "' . addslashes( $this->getMain()->getUserAgent() ) . '"';
wfDebugLog( 'api-feature-usage', $s, 'private' );
}
return $this->mModuleMgr;
}
+ /**
+ * Fetches the user agent used for this request
+ *
+ * The value will be the combination of the 'Api-User-Agent' header (if
+ * any) and the standard User-Agent header (if any).
+ *
+ * @return string
+ */
+ public function getUserAgent() {
+ return trim(
+ $this->getRequest()->getHeader( 'Api-user-agent' ) . ' ' .
+ $this->getRequest()->getHeader( 'User-agent' )
+ );
+ }
+
/************************************************************************//**
* @name Deprecated
* @{