Exemplo n.º 1
0
 void chunk(HttpChunk chunk) throws Exception {
   Preconditions.checkState(
       bodyConsumer != null, "Received chunked content without BodyConsumer.");
   if (chunk.isLast()) {
     bodyConsumer.finished(responder);
     bodyConsumer = null;
   } else {
     try {
       bodyConsumer.chunk(chunk.getContent(), responder);
     } catch (Throwable t) {
       bodyConsumer.handleError(t);
       bodyConsumer = null;
       throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR, "", t);
     }
   }
 }
Exemplo n.º 2
0
 /** Calls the httpHandler method. */
 void invoke() throws Exception {
   if (isStreaming) {
     // Casting guarantee to be succeeded.
     bodyConsumer = (BodyConsumer) method.invoke(handler, args);
     if (requestContent.readable()) {
       try {
         bodyConsumer.chunk(requestContent, responder);
       } catch (Throwable t) {
         bodyConsumer.handleError(t);
         bodyConsumer = null;
         throw new HandlerException(HttpResponseStatus.INTERNAL_SERVER_ERROR, "", t);
       }
     }
     if (!isChunkedRequest) {
       bodyConsumer.finished(responder);
       bodyConsumer = null;
     }
   } else {
     // Actually <T> would be void
     method.invoke(handler, args);
     bodyConsumer = null;
   }
 }