Skip to content
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

Allow null/empty response body #335

Closed
opsonusi opened this issue Aug 25, 2015 · 2 comments
Closed

Allow null/empty response body #335

opsonusi opened this issue Aug 25, 2015 · 2 comments
Labels

Comments

@opsonusi
Copy link

For example:

post("/accounts", { req, res -> res.status(201) })

Currently this fails with as a 404.
INFO spark.webserver.MatcherFilter - The requested route [/accounts] has not been mapped in Spark

In MatcherFilter.java:227, bodyContent == null is not enough to indicate the request hasn't been consumed.

        boolean consumed = bodyContent != null;

        if (!consumed && hasOtherHandlers) {
            throw new NotConsumedException();
        }

        if (!consumed && !isServletContext) {
            LOG.info("The requested route [" + uri + "] has not been mapped in Spark");
            httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
            bodyContent = String.format(NOT_FOUND);
            consumed = true;
        }
@Tradunsky
Copy link

The pull request:
#352
should fix the issue

@tipsy
Copy link
Contributor

tipsy commented Mar 1, 2017

I've changed my mind here, this actually makes sense. If the route is null, nothing has been mapped, so 404 is appropriate.

@tipsy tipsy closed this as completed Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants