File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,8 +111,7 @@ export function prepareRequestOptions(request_options, options) {
111111 }
112112
113113 request_options . headers = request_options . headers || { } ;
114- request_options . headers [ 'User-Agent' ] = options ?. user_agent || CONFIG . USER_AGENT ;
115-
114+
116115 if ( CONFIG . PROXY || options ?. proxy ) {
117116
118117 var proxy = options ?. proxy || getCustomProxyForUri ( uri , options ) ;
@@ -155,6 +154,14 @@ export function prepareRequestOptions(request_options, options) {
155154 }
156155 }
157156
157+ if ( options ?. user_agent ) {
158+ // Let `options.user_agent` be prioritized over `proxy.user_agent`.
159+ request_options . headers [ 'User-Agent' ] = options ?. user_agent ;
160+ } else if ( ! request_options . headers [ 'User-Agent' ] ) {
161+ // ...otherwise use default user agent.
162+ request_options . headers [ 'User-Agent' ] = CONFIG . USER_AGENT ;
163+ }
164+
158165 // Add user agent extension to default agent if avaliable.
159166 if ( options ?. getProviderOptions
160167 && ( options . getProviderOptions ( 'app.name' ) || options . getProviderOptions ( 'app.ua_extension' ) )
You can’t perform that action at this time.
0 commit comments