Fork me on GitHub
#liberator
<
2016-02-11
>
rickmoynihan11:02:37

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

ordnungswidrig12:02:31

Thanks, that’s correct.

ordnungswidrig12:02:57

@rickmoynihan: woud you mind file a quick issue at github?

rickmoynihan14:02:30

I'm trying to debug this liberator resource:

rickmoynihan14:02:33

Basically it does some content neg on a file on the filesystem and presents the file for download

rickmoynihan14:02:47

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-typebeing 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

rickmoynihan14:02:23

If I call the resource at the repl or in my tests it looks like too works

rickmoynihan14:02:32

I'm using ring.server.standale... so maybe something in jetty is stomping on it

ordnungswidrig15:02:41

You can always call your resource as a ring handler function:

ordnungswidrig15:02:56

((download-file „dir“ „file“) {:request-method :get :uri „/„ :headers {„Accept“ „*/*“}}

rickmoynihan16:02:44

@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

rickmoynihan16:02:57

just about to drill into ring to see where it happens

rickmoynihan16:02:40

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

rickmoynihan16:02:51

I get the same behaviour on both http-kit and jetty

ordnungswidrig16:02:22

Which middleware do you use?

rickmoynihan16:02:01

I don't think its the middleware pipeline... I've ran a debugger over them and it's what I've set

ordnungswidrig16:02:22

So the routes are directly run with the jetty adapter? Weird

rickmoynihan16:02:41

not actually tried that... but the middlewares I have set up are returning what I want

rickmoynihan16:02:40

just gonna try that to be sure though

rickmoynihan16:02:42

ok you're right this does work: (run-server (fn [req] {:status 200 :headers {"Content-Type" "text/csv"} :body ( "/tmp/foo.nt")}) {:port 12345} )

rickmoynihan16:02:55

must be one of the middlewares

ordnungswidrig18:02:03

looks like a bug in one of them...

rickmoynihan22:02:32

I was accidentally including the deprecated wrap-file-info middleware - my mistake