@Override public String getReasonPhrase() { return status.getStatusText(); } }, requestContext);
@Override public void close() { grizzlyClient.close(); }
@Override public int getStatusCode() { return status.getStatusCode(); }
@Override public Integer onCompleted(Response response) throws Exception { if (response.getStatusCode() != HttpURLConnection.HTTP_OK) { Loggers.RAFT.warn("[RAFT] failed to publish data to peer, datumId={}, peer={}, http code={}", datum.key, server, response.getStatusCode()); return 1; } return 0; }
private static AsyncHttpClient client = new AsyncHttpClient();
final int DEFAULT_TIMEOUT = 20 * 1000; AsyncHttpClient aClient = new AsyncHttpClient(); aClient.setTimeout(DEFAULT_TIMEOUT); //... continue as normal
public WrappedRequestBuilder setBody(List<byte[]> data) { _delegate.setBody(data); return this; }
public WrappedRequestBuilder setBodyEncoding(String charset) { _delegate.setBodyEncoding(charset); return this; }
public WrappedRequestBuilder addQueryParam(String name, String value) { _delegate.addQueryParam(name, value); return this; }
/** * Submits the response processing on Grizzly client's application thread pool. * * @param responseTask task to be processed on application thread pool. */ private void processResponse(Runnable responseTask) { this.grizzlyClient.getConfig().executorService().submit(responseTask); }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { entityStream.put(bodyPart.getBodyByteBuffer()); return STATE.CONTINUE; }
public WrappedRequestBuilder setHeaders(Map<String, Collection<String>> headers) { _delegate.setHeaders(headers); return this; }
public WrappedRequestBuilder addCookie(Cookie cookie) { _delegate.addCookie(cookie); return this; }
public WrappedRequestBuilder addFormParam(String key, String value) { _delegate.addFormParam(key, value); return this; }
public WrappedRequestBuilder setSignatureCalculator(SignatureCalculator signatureCalculator) { _delegate.setSignatureCalculator(signatureCalculator); return this; }
@Override public Integer onCompleted(Response response) throws Exception { if (response.getStatusCode() != HttpURLConnection.HTTP_OK) { Loggers.SRV_LOG.warn("[STATUS-SYNCHRONIZE] failed to request serverStatus, remote server: {}", serverIP); return 1; } return 0; } });
public WrappedRequestBuilder setBody(InputStream stream) { _delegate.setBody(stream); return this; }
@Override public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception { entityStream.put(bodyPart.getBodyByteBuffer()); return STATE.CONTINUE; }
@Override public Integer onCompleted(Response response) throws Exception { if (response.getStatusCode() != HttpURLConnection.HTTP_OK) { Loggers.SRV_LOG.warn("[STATUS-SYNCHRONIZE] failed to request domStatus, remote server: {}", serverIP); return 1; } return 0; } });
public WrappedRequestBuilder setBody(File file) { _delegate.setBody(file); return this; }