The project dependency coordinate on the docs page is out of date: http://clojure-liberator.github.io/liberator/
It should be 0.14.0
now
Thanks, that’s correct.
@rickmoynihan: woud you mind file a quick issue at github?
thanks
no worries
I'm trying to debug this liberator resource:
Basically it does some content neg on a file on the filesystem and presents the file for download
Now in my tests the file (if it exists) always comes out with the set content type... But when I call the route for real something seems to be setting the content-type to application/octet-stream
... I'm guessing its a middleware somewhere; but I've been through pretty much every middleware and they all seem to be doing whats expected.
At first I thought it was wrap-content-type
being included via wrap-defaults
doing the wrong thing... but when I debugged it in cider it returns the correct content type...
I'm not sure where else to look
If I call the resource at the repl or in my tests it looks like too works
I'm using ring.server.standale... so maybe something in jetty is stomping on it
You can always call your resource as a ring handler function:
((download-file „dir“ „file“) {:request-method :get :uri „/„ :headers {„Accept“ „*/*“}}
@ordnungswidrig: yeah I've tried that and it works... I think there's a bug in ring....
When you return a :body
with a File
in it, it stomps on your content-type and sets it to application/octet-stream
just about to drill into ring to see where it happens
e.g. This ring handler:
(ANY "/fooo" req
{:status 200 :headers {"Content-Type" "application/csv"} :body (io/file "/tmp/foo.csv")})
will be octet-stream
I get the same behaviour on both http-kit and jetty
Which middleware do you use?
I don't think its the middleware pipeline... I've ran a debugger over them and it's what I've set
So the routes are directly run with the jetty adapter? Weird
not actually tried that... but the middlewares I have set up are returning what I want
just gonna try that to be sure though
ok you're right this does work: (run-server (fn [req] {:status 200 :headers {"Content-Type" "text/csv"} :body (<http://clojure.java.io/file|clojure.java.io/file> "/tmp/foo.nt")}) {:port 12345} )
must be one of the middlewares
looks like a bug in one of them...
I was accidentally including the deprecated wrap-file-info
middleware - my mistake