Permalink
Please sign in to comment.
Showing
with
0 additions
and 43 deletions.
- +0 −1 README.md
- +0 −19 ring-core/src/ring/util/request.clj
- +0 −23 ring-core/test/ring/util/request_test.clj
1
README.md
19
ring-core/src/ring/util/request.clj
| @@ -1,19 +0,0 @@ | ||
| -(ns ring.util.request) | ||
| - | ||
| -(defn ssl? | ||
| - "Returns true iff the request was submitted over SSL." | ||
| - [req] | ||
| - (= :https (:scheme req))) | ||
| - | ||
| -(defn server-host | ||
| - "Returns a String for the full hostname." | ||
| - [req] | ||
| - (let [hdrs (:headers req)] | ||
| - (or (get hdrs "x-forwarded-host") | ||
| - (get hdrs "host") | ||
| - (:server-name req)))) | ||
| - | ||
| -(defn full-uri | ||
| - "Returns a String for the full request URI, including the protocol and host." | ||
| - [req] | ||
| - (str (name (:scheme req)) "://" (server-host req) (:uri req))) |
23
ring-core/test/ring/util/request_test.clj
| @@ -1,23 +0,0 @@ | ||
| -(ns ring.util.request-test | ||
| - (:use clojure.test | ||
| - ring.util.request)) | ||
| - | ||
| -(deftest test-ssl? | ||
| - (is (ssl? {:scheme :https})) | ||
| - (is (not (ssl? {:scheme :http})))) | ||
| - | ||
| -(deftest test-server-host | ||
| - (is (= "google.com" | ||
| - (server-host {:server-name "ask.com" :server-port 80 | ||
| - :headers {"x-forwarded-host" "google.com" | ||
| - "host" "yahoo.com"}}))) | ||
| - (is (= "yahoo.com" | ||
| - (server-host {:server-name "ask.com" :server-port 80 | ||
| - :headers {"host" "yahoo.com"}}))) | ||
| - (is (= "ask.com" | ||
| - (server-host {:server-name "ask.com" :server-port 80})))) | ||
| - | ||
| -(deftest test-full-uri | ||
| - (is (= "https://google.com/foo/bar" | ||
| - (full-uri {:uri "/foo/bar" :scheme :https | ||
| - :headers {"host" "google.com"}})))) |
0 comments on commit
5d9f873