serveFile shouldn't reset HTTP response code #122

afcowie opened this Issue Mar 3, 2012 · 2 comments


None yet
2 participants

afcowie commented Mar 3, 2012


serveNotFound :: Snap ()
serveNotFound = do
    modifyResponse $ setResponseStatus 404 "Not Found"
    serveFile "content/404.html"

really ought to result in an HTTP response status code of 404, but serveFile seems to force the response to 200. As you can see from the above use case, I'm not sure it should do that.



afcowie commented Mar 4, 2012

This would seem to be a bug against 'snap-server', but that project doesn't have an "Issues" tab so I filed it here. Sorry if that wasn't the right thing to do (it was just suggested that I should note that here).



gregorycollins commented Mar 4, 2012

It's not a bug against snap-server, this code lives in snap-core.

The "serveFile" function does a lot of checking for range requests and last-modified headers, etc, none of which you care about when you are trying to serve a 404 response. The function you are looking for is "sendFile".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment