Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
uses x-forwarded-proto-version for protocol version when available (#584
Browse files Browse the repository at this point in the history
)
  • Loading branch information
shamsimam authored and DaoWen committed Feb 8, 2019
1 parent 425c816 commit e903c0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion waiter/src/waiter/core.clj
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions waiter/test/waiter/core_test.clj
Expand Up @@ -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"))})))
Expand Down

0 comments on commit e903c0c

Please sign in to comment.