Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] How to turn off "chunked" encoding in http response in jetty 7?

Hi,
 
I'm currently using Jetty 7 (embedded mode) and Jersey in a demo java project to implement some REST web services.  I notice that by default Jetty uses chunked transfer-encoding for http responses. I'm just wondering if there is a way I can turn chunking OFF (besides reverting back to HTTP/1.0 instead of 1.1)?. 
 
I'm testing against a client that currently can't seem to deal with a chunked response. Long term we'll fix the client but in the interest of getting a demo up and running quick it would nice if we could force it off in Jetty for now.
 
The code we are using to setup Jetty/Jersey is shown below:
 
 // Set up to use Jersey with embedded Jetty HTTP server
  ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter(
    "com.sun.jersey.config.property.resourceConfigClass",
    "com.sun.jersey.api.core.PackagesResourceConfig");
  sh.setInitParameter(
    "com.sun.jersey.config.property.packages",
    "test.rest");
  Server server = new Server(9999);
  ServletContextHandler context = new ServletContextHandler(server, "/",
    ServletContextHandler.SESSIONS);
  context.addServlet(sh, "/*");
  server.start();
  server.join();
 
Then in our resource class we have jersey-decorated code similar to the following to handle our REST stuff.
 
  @GET @Path("/status")
  @Produces("application/json")
  public String getSystemStatus()
  {
   return "true";
  } 
 
 
Thanks in advance for your kind help.
 
-Tom

Back to the top