Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Jetty 9.4.34.v20201102: Managing 1xx Responses

Hi All,

 

I have an application offering a POST HTTP REST service implemented via JAX-RS in Jetty. Because under special circumstances the time required for this service to execute may exceed a couple of minutes, I am considering to provide interim 102 processing responses reporting the progress of the operation to the client until providing a final 200 Ok response.

I tried to follow instructions as in https://www.eclipse.org/jetty/documentation/9.4.34.v20201102/jetty-1xx-responses.html.

The code is something like

 

import import javax.servlet.http.HttpServletRequest;

import import javax.servlet.http.HttpServletResponse;

import javax.ws.rs.core.Response;

import javax.ws.rs.Consumes;

import javax.ws.rs.Produces;

import javax.ws.rs.Path;

import javax.ws.rs.POST;

 

@Path("gr")

public class GenericResource {

                             

    @POST

    @Consumes(MediaType.APPLICATION_JSON)

    @Produces(MediaType.APPLICATION_JSON)

    public Response procAlert(@Context HttpServletRequest  req,

              @Context HttpServletResponse resp) {

      

           // Some processing…

resp.setHeader("Progress", "0/2 Something on the way");

resp.sendError(102);

 

           // Some more processing…

resp.setHeader("Progress", "1/2 Almost there");

resp.sendError(102);

 

// Last processing…

return Response.ok().entity("{\"Reply\": \"Bingo!\"}").build();

         }

     }

 

I am using Java 8.

The problem is that on the client side the interim responses are not delivered. The HTTP client only receives the final 200 OK reply as if the sending of interim ones had not been attempted.

Any help on this subject would be welcomed.

Best regards,

 

Paulo Sardinha

 


Back to the top