javahttp-status-codesjavalin

Javalin hangs when asked to give 1XX HTTP status


I have a Javalin server, the relevant code called by the endpoint looks like this:

...
if(!someFuture.isDone()){
    ctx.status(102);
    return;
}

Javalin hangs and does not return anything* when the HTTP status is set to anything in the 1XX range. 2XX, 3XX and 4XX are returned without any problems. I haven't been able to find anything in Javalin's documentation about this, but are 1XX status codes not allowed by Javalin? If not, why is 102 causing this problem?

*eventually Postman registers a socket hang up


Solution

  • The meaning of the 1XX range is:

    The server has received the request and is continuing the process

    So when you respond with it, the client will await data.

    From the documentation (Javalin builded on Jetty):

    102 Processing RFC 2518 defined the 102 Processing status code that can be sent:

    when the server has a reasonable expectation that the request will take significant time to complete. As guidance, if a method is taking longer than 20 seconds (a reasonable, but arbitrary value) to process the server SHOULD return a 102 Processing response. — RFC 2518 section 10.1 However, a later update of RFC 2518, RFC 4918, removed the 102 Processing status code for "lack of implementation".

    Jetty supports the 102 Processing status code. If a request is received with the Expect: 102-processing header, then a filter/servlet may send a 102 Processing response (without terminating further processing) by calling response.sendError(102).