Permalink
Browse files

uses x-forwarded-proto-version for protocol version when available (#584

)
  • Loading branch information...
shamsimam authored and DaoWen committed Feb 8, 2019
1 parent 425c816 commit e903c0cf57a770a929c6bdb0909c3abd3409f5e2
Showing with 7 additions and 1 deletion.
  1. +4 −1 waiter/src/waiter/core.clj
  2. +3 −0 waiter/test/waiter/core_test.clj
@@ -192,7 +192,10 @@
For WebSocket requests, it returns values like WS/8, WS/13."
[{:keys [headers scheme ^ServletRequest servlet-request]}]
(if servlet-request
(.getProtocol servlet-request)
(or (some-> headers
(get "x-forwarded-proto-version")
str/upper-case)
(.getProtocol servlet-request))
(when scheme
(str/upper-case
;; currently, only websockets need this branch to determine version
@@ -1429,7 +1429,10 @@

(deftest test-request->protocol
(is (nil? (request->protocol {})))
(is (nil? (request->protocol {:headers {"x-forwarded-proto-version" "Foo/Bar"}})))
(is (= "HTTP" (request->protocol {:scheme :http})))
(is (= "FOO/BAR" (request->protocol {:headers {"x-forwarded-proto-version" "Foo/Bar"}
:servlet-request (Object.)})))
(is (= "HTTP/1.1" (request->protocol {:scheme :http
:servlet-request (reify ServletRequest
(getProtocol [_] "HTTP/1.1"))})))

0 comments on commit e903c0c

Please sign in to comment.