Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow proxying of multi packet data. #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(defproject tailrecursion/ring-proxy "2.0.0-SNAPSHOT"
(defproject tailrecursion/ring-proxy "4.0.2-FINAL"
:description "HTTP proxy ring middleware for Clojure web applications."
:url "https://github.com/tailrecursion/ring-proxy"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]
[ring/ring-core "1.1.8"]
[clj-http "0.6.5"]])
[clj-http "0.6.5"]]
:repositories [["releases" {:url "http://nexus-dev.snc1/content/repositories/releases/" :sign-releases false}]])
7 changes: 2 additions & 5 deletions src/tailrecursion/ring_proxy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
(defn slurp-binary
"Reads len bytes from InputStream is and returns a byte array."
[^java.io.InputStream is len]
(with-open [rdr is]
(let [buf (byte-array len)]
(.read rdr buf)
buf)))
(slurp is))

(defn wrap-proxy
"Proxies requests to proxied-path, a local URI, to the remote URI at
Expand All @@ -35,7 +32,7 @@
(subs (:uri req) (.length proxied-path)))
nil
nil)]
(-> (merge {:method (:request-method req)
(-> (merge-with merge {:method (:request-method req)
:url (str remote-uri "?" (:query-string req))
:headers (dissoc (:headers req) "host" "content-length")
:body (if-let [len (get-in req [:headers "content-length"])]
Expand Down