Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-986

Netty4 async not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.6.Final
    • 3.0.4.Final
    • jaxrs
    • None
    • Hide

      Use this in any netty instance:

      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.container.AsyncResponse;
      import javax.ws.rs.container.Suspended;
      import javax.ws.rs.core.MediaType;
      import javax.ws.rs.core.Response;
      
      @Path("/")
      public class ResteasyRestImpl {
          @GET
          public void sendAsync(
                  @Suspended final AsyncResponse response
              ) {
      
              Thread t = new Thread() {
                  @Override
                  public void run() {
                      response.resume(Response
                              .status(200)
                              .entity("I have no head\n")
                              .type(MediaType.TEXT_PLAIN)
                              .build()
                              );
                  }
              };
              t.start();
          }
      }
      

      The response will have the HTTP status line followed by the body... skipping any HTTP header.

      $ curl -D /dev/stderr 'http://localhost:8910/'
      HTTP/1.1 200 OK
      
      I have no head!
      
      Show
      Use this in any netty instance: import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.container.AsyncResponse; import javax.ws.rs.container.Suspended; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path( "/" ) public class ResteasyRestImpl { @GET public void sendAsync( @Suspended final AsyncResponse response ) { Thread t = new Thread () { @Override public void run() { response.resume(Response .status(200) .entity( "I have no head\n" ) .type(MediaType.TEXT_PLAIN) .build() ); } }; t.start(); } } The response will have the HTTP status line followed by the body... skipping any HTTP header. $ curl -D /dev/stderr 'http://localhost:8910/' HTTP/1.1 200 OK I have no head!

      Using AsyncResponse in Netty 4 fails to output the HTTP headers with the response. Not even the Content-Type.

            patriot1burke@gmail.com Bill Burke (Inactive)
            redhat@jitjat.com Valued Customer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: