File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
lib/travis/api/app/middleware Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ class UserAgentTracker < Middleware
25
25
before ( agent : /^.+$/ ) do
26
26
agent = UserAgent . parse ( request . user_agent )
27
27
case agent . browser
28
- when *WEB_BROWSERS then mark_browser ( agent )
28
+ when *WEB_BROWSERS
29
+ # if X-User-Agent header is set, honor that instead
30
+ mark :browser , UserAgent . parse ( env [ 'HTTP_X_USER_AGENT' ] || request . user_agent ) . browser
29
31
when "curl" , "Wget" then mark ( :console , agent . browser )
30
32
when "travis-api-wrapper" then mark ( :script , :node_js , agent . browser )
31
33
when "TravisPy" then mark ( :script , :python , agent . browser )
@@ -36,15 +38,6 @@ class UserAgentTracker < Middleware
36
38
end
37
39
end
38
40
39
- def mark_browser ( agent )
40
- # allows a JavaScript Client to set X-User-Agent, for instance to "travis-web" in travis-web
41
- if env [ 'HTTP_X_USER_AGENT' ]
42
- mark :browser , UserAgent . parse ( env [ 'HTTP_X_USER_AGENT' ] ) . browser
43
- else
44
- mark :browser , agent . browser
45
- end
46
- end
47
-
48
41
def mark_travis ( agent )
49
42
command = agent . application . comment . detect { |c | c . start_with? "command " } if agent . application . comment
50
43
You can’t perform that action at this time.
0 commit comments