@Override public Response prepareResponse(HttpResponseHeaders headers, List<HttpResponseBodyPart> bodyParts) { return new NettyResponse(this, headers, bodyParts); } }
@Override public Response prepareResponse(HttpResponseHeaders headers, List<HttpResponseBodyPart> bodyParts) { return new NettyResponse(this, headers, bodyParts); } }
@Override public STATE onBodyPartReceived(final HttpResponseBodyPart bodyPart) throws Exception { if (responseMaxSize > 0) { responseSizesAggregated += bodyPart.length(); if (responseSizesAggregated > responseMaxSize) { onThrowable(new RuntimeException("Response size is bigger than the limit: " + responseMaxSize)); return STATE.ABORT; } } final com.ning.http.client.Response ningResponse = new NettyResponse(status, headers, Collections.singletonList(bodyPart)); final Response response = new NingResponse<>(ningResponse, null, null); target.onNext(response); return STATE.CONTINUE; }
@Override public STATE onBodyPartReceived(final HttpResponseBodyPart bodyPart) throws Exception { if (responseMaxSize > 0) { responseSizesAggregated += bodyPart.length(); if (responseSizesAggregated > responseMaxSize) { onThrowable(new RuntimeException("Response size is bigger than the limit: " + responseMaxSize)); return STATE.ABORT; } } final com.ning.http.client.Response ningResponse = new NettyResponse(status, headers, singletonList(bodyPart)); final TypedResponse<T> response = new NingResponse<>(ningResponse, type, marshallingStrategy); try { // making sure that we can unmarshall the response response.getTypedBody(); } catch (final Exception e) { // if the unmarshall failed, no reason to continuing the stream onThrowable(e); return STATE.ABORT; } target.onNext(response); return STATE.CONTINUE; }