tailrecursion / ring-proxy

HTTP proxy ring middleware for Clojure web applications.
47 stars 14 forks source link

Works for error pages, not for 200s. #2

Open alexbbrown opened 11 years ago

alexbbrown commented 11 years ago

In my toy app: http://localhost:3000/devel/store/fdfd works, but http://localhost:3000/devel/ does not, can you please help me?

(ns babyproxy.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
            [compojure.route :as route]
                        [clj-http.client :as client]
                        [tailrecursion.ring-proxy :refer [wrap-proxy]]))

(defroutes app-routes
  (GET "/" [] "Hello, world")
  #_(GET "/proxy" [] [(client/get "http://google.com")])
  (GET "/foo" [] "foo")
  #_(route/resources "/")
  (route/not-found "Not Found")
    )

(def app
 (-> app-routes (wrap-proxy "/devel" "http://www.apple.com"))
    )
alexbbrown commented 11 years ago

the error is "safari cannot open the page" "cannot decode raw data", or on chrome: "ERR_CONTENT_DECODING_FAILED"

alandipert commented 11 years ago

I haven't tested, but I suspect the apple.com address is redirecting to an SSL address. Clj-http might then be following it, but because the proxy URL isn't SSL itself, it sends a blob of encrypted stuff back to your browser.

Do you know if the URL you're trying to proxy is redirecting to SSL?