@Override public State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { // body arrived, flush headers if (!responseSet) { response = responseBuilder.build(); responseSet = true; headersArrived.countDown(); } output.write(bodyPart.getBodyPartBytes()); return State.CONTINUE; }
@Override public Response onCompleted() throws IOException { if (!responseSet) { response = responseBuilder.build(); responseSet = true; } // Counting down to handle error cases too. // In "normal" cases, latch is already at 0 here // But in other cases, for example when because of some error // onBodyPartReceived() is never called, the caller // of getResponse() would remain blocked infinitely. // By contract, onCompleted() is always invoked, even in case of errors headersArrived.countDown(); closeOut(); try { semaphore.acquire(); if (throwable != null) { throw new IOException(throwable); } else { // sending out current response return responseBuilder.build(); } } catch (InterruptedException e) { return null; } finally { semaphore.release(); } }
public Response onCompleted() throws IOException { if (!responseSet) { response = responseBuilder.build(); responseSet = true; } // Counting down to handle error cases too. // In "normal" cases, latch is already at 0 here // But in other cases, for example when because of some error // onBodyPartReceived() is never called, the caller // of getResponse() would remain blocked infinitely. // By contract, onCompleted() is always invoked, even in case of errors headersArrived.countDown(); closeOut(); try { semaphore.acquire(); if (throwable != null) { IOException ioe = new IOException(throwable.getMessage()); ioe.initCause(throwable); throw ioe; } else { // sending out current response return responseBuilder.build(); } } catch (InterruptedException e) { return null; } finally { semaphore.release(); } }
/** * {@inheritDoc} */ @Override public Response onCompleted() throws Exception { resumableProcessor.remove(url); resumableListener.onAllBytesReceived(); if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onCompleted(); } // Not sure return responseBuilder.build(); }
/** * {@inheritDoc} */ public final T onCompleted() throws Exception { return onCompleted(builder.build()); }
public State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { // body arrived, flush headers if (!responseSet) { response = responseBuilder.build(); responseSet = true; headersArrived.countDown(); } bodyPart.writeTo(output); return State.CONTINUE; }
/** * {@inheritDoc} */ public final T onCompleted() throws Exception { return onCompleted(builder.build()); }
/** * {@inheritDoc} */ public final T onCompleted() throws Exception { final Response response = builder.build(); return onCompleted(response.getStatusCode()); }
@Override protected ListenableFuture<Response> go(Request request) { Response response = responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST).build(); return GoHandlers.immediateFuture(response); } }
@Override public final T onCompleted() throws Exception { return onCompleted(builder.build()); }
@Override public Response onCompleted() throws Exception { resumableProcessor.remove(url); resumableListener.onAllBytesReceived(); if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onCompleted(); } // Not sure return responseBuilder.build(); }
@Override protected ListenableFuture<Response> go(Request request) { Response response = responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST).build(); return GoHandlers.immediateFuture(response); } }