/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
/** * @param bodyPart * a body part (possibly empty, but will be filtered out) * @return this */ public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) { if (bodyPart.length() > 0) bodyParts.add(bodyPart); return this; }
@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; }