Skip to content

Commit

Permalink
Set up user-agent for PCS stored requests
Browse files Browse the repository at this point in the history
Endpoints affected:
* summary
* mobile-html
* media-list

Top level config is not maintained when custom headers are
defined on hyper requests. Also top level config is not available
on template expansion, thus we need to redefine the user-agent in
multiple places.
  • Loading branch information
johngian committed Aug 29, 2024
1 parent 7bd5bb8 commit e38338d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion v1/pcs/stored_endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PCSEndpoint {
constructor(options) {
this._options = options;
this._disabled_storage = options.disabled_storage || false;
this.user_agent = 'RESTBase/WMF';
}

_injectCacheControl(res) {
Expand Down Expand Up @@ -110,7 +111,8 @@ class PCSEndpoint {
return hyper.get({
uri: new URI(serviceURI),
headers: {
'accept-language': req.headers['accept-language']
'accept-language': req.headers['accept-language'],
'user-agent': this.user_agent
}
}).tap(() => hyper.metrics.endTiming([
'pcs_fetch_latency',
Expand Down
1 change: 1 addition & 0 deletions v1/summary_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ paths:
method: get
headers:
accept-language: '{{accept-language}}'
user-agent: 'RESTBase/WMF'
uri: '{{options.host}}/{domain}/v1/page/summary/{title}'
response:
status: '{{extract.status}}'
Expand Down

0 comments on commit e38338d

Please sign in to comment.