Java Code Examples for com.ning.http.client.Request#getStringData()
The following examples show how to use
com.ning.http.client.Request#getStringData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NingEntityExtractorV1.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public String getEntity(Request request) { final String stringData = request.getStringData(); if (stringData != null) { return stringData; } final byte[] byteData = request.getByteData(); if (byteData != null) { return "BYTE_DATA"; } final InputStream streamData = request.getStreamData(); if (streamData != null) { return "STREAM_DATA"; } return null; }
Example 2
Source File: Zendesk.java From scava with Eclipse Public License 2.0 | 5 votes |
private <T> ListenableFuture<T> submit(Request request, AsyncCompletionHandler<T> handler) { try { if (request.getStringData() != null) { logger.debug("Request {} {}\n{}", request.getMethod(), request.getUrl(), request.getStringData()); } else if (request.getByteData() != null) { logger.debug("Request {} {} {} {} bytes", request.getMethod(), request.getUrl(), // request.getHeaders().getFirstValue("Content-type"), request.getByteData().length); } else { logger.debug("Request {} {}", request.getMethod(), request.getUrl()); } return client.executeRequest(request, handler); } catch (IOException e) { throw new ZendeskException(e.getMessage(), e); } }
Example 3
Source File: NingRequestBuilder.java From ob1k with Apache License 2.0 | 4 votes |
private ComposableFuture<com.ning.http.client.Response> executeAndTransformRequest() { try { prepareRequestBody(); } catch (final IOException e) { return fromError(e); } final Request ningRequest = ningRequestBuilder.build(); if (log.isTraceEnabled()) { final String body = ningRequest.getByteData() == null ? ningRequest.getStringData() : new String(ningRequest.getByteData(), Charset.forName(charset)); log.trace("Sending HTTP call to {}: headers=[{}], body=[{}]", ningRequest.getUrl(), ningRequest.getHeaders(), body); } final Provider<com.ning.http.client.Response> provider = new Provider<com.ning.http.client.Response>() { private boolean aborted = false; private long size; @Override public ListenableFuture<com.ning.http.client.Response> provide() { return asyncHttpClient.executeRequest(ningRequest, new AsyncCompletionHandler<com.ning.http.client.Response>() { @Override public com.ning.http.client.Response onCompleted(final com.ning.http.client.Response response) throws Exception { if (aborted) { throw new RuntimeException("Response size is bigger than the limit: " + responseMaxSize); } return response; } @Override public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception { if (responseMaxSize > 0) { size += content.length(); if (size > responseMaxSize) { aborted = true; return STATE.ABORT; } } return super.onBodyPartReceived(content); } }); } }; return fromListenableFuture(provider); }