-
Notifications
You must be signed in to change notification settings - Fork 47
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
0.9.1 downloads instead of displays #107
Comments
One big change in 0.9.1 is that the As a side note, the preferred way to add middleware to |
could you try initializing the handler as follows and see if you still get the same issue: (def app
(app-handler
[all-routes]
:session-options {:cookie-name "dd-session"
:store (cookie-store {:key (:cookie-key configs)})}
:middleware
[middleware-json/wrap-json-body
middleware-json/wrap-json-response
jsonp/wrap-json-with-padding
middleware-json/wrap-json-params
wrap-params])) |
@kanwei are you still seeing the issue, or can we close it? |
Nope, still doing the same thing.. |
I can't seem to reproduce the issue using the luminus template, could you possibly make a sample project that exhibits it to help with debugging. |
I have a very similar issue. After running I figured the added security was a good thing™ and so set about adding Having done this I have found that the forms submit, they are accepted through the anti-forgery filter and get correctly forwarded on to the API but on the return journey the browser downloads the response rather than rendering it. As though a content-disposition header has been added or maybe Content-Type header has been stripped? Rolling back to Here's my app-handler... (def app (app-handler
;; application routes
[home-routes
other-routes
;<<===== LASTLY ======>>
app-routes]
;; add custom middleware here
:middleware [middleware/log-request
middleware/template-error-page
; force SSL when we're running from production
middleware/with-force-ssl
; are we on speaking terms with this IP?
middleware/block-ip-address?]
;; add access rules here
:access-rules []
;; serialize/deserialize the following data formats. Available formats:
;; :json :json-kw :yaml :yaml-kw :edn :yaml-in-html
:formats [:json-kw :edn]
:session-options {:cookie-name "my-app"
:store (ring.middleware.session.cookie/cookie-store)})) |
The handler changed a bit to use ring-defaults to initialize the stock middleware, here's what it looks like currently. The custom middleware has now been moved to its own nsamespace as well here. Apps created using the latest template don't appear to exhibit the issue, so it does sound like the problem is with how the middleware is initialized. |
Not sure whether related to this, but after upgrading to 0.9.4 and when I return (status 200 "Hello world") (status is from noir.response) It prompts me to download the content. Shouldn't it be displaying "Hello world"? I see the content type returned is "octet-stream". I am using luminus template. What am I missing? |
It sounds like all the issues relate to content type not being set correctly. Are you using the latest version of the template. When I create a new project using |
Yes, I tested this by creating a new project |
It looks like you have to set the content type explicitly with ring-defaults: (response/content-type "text/plain; charset=utf-8" (response/status 200 "Hello world")) |
Is this an issue with ring-defaults then? Seems a bit insane to have this not working by default ;) |
I'm just looking through what it's doing, and it looks to be setting content-type wrapper to true for site-defaults here. Perhaps the behavior changed there. Have to investigate further. Note that returning a string will work as expected: (GET "/" [] "Hello world") However, when you use |
This is where the (defn content-type-response
"Adds a content-type header to response. See: wrap-content-type."
{:arglists '([response request] [response request options])
:added "1.2"}
[resp req & [opts]]
(if (get-header resp "Content-Type")
resp
(let [mime-type (ext-mime-type (:uri req) (:mime-types opts))]
(content-type resp (or mime-type "application/octet-stream"))))) |
Another issue is, I am not able to serve cache manifest file in resources/public. I see the extension "appcache" is mapped to "text/cache-manifest" in https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/mime_type.clj#L10 . I see (wrap-file-info) https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/middleware/file_info.clj#L56 is supposed to be handling content types. Currently I am using lib-noir content type setting to serve this file. Wondering anyone else had this issue? |
The {:security {:content-type-options :nosniff}
:responses {:content-types true}} The What this means is that you need to ensure that your responses have content-types, otherwise you'll run into problems. You can always turn the above options off, but it's usually better to treat problems than ignore them, and responses should really have valid content-types. Compojure will treat string responses as @devasiajoseph, your problem might be that you're using Ring 1.3.1, while the appcache extension was only added to the defaults in 1.3.2. |
I have the same problem here. What's weird is that it doesn't happen in a simple Every other page works fine, but (c/defroutes home
(c/GET "/" [] "hello world")) Curl returns this:
As you can see, no content at all. |
Ok, after talking with @weavejester, he suggested I enter [ring/ring-core "1.3.2"] explicitly in my dependencies. It worked! Apparently, one of my other deps was overriding the ring-core version. |
ah let me update ring dependency in lib-noir and make a new release |
@Frozenlock ok all the lib-noir dependencies should be at latest versions |
I've got a pretty simple setup:
However, after upgrading to 0.9.1 webpages get downloaded instead of displayed as html.
The text was updated successfully, but these errors were encountered: