use of org.apache.http.params.HttpParams in project undertow by undertow-io.
the class HttpContinueAcceptingHandlerTestCase method testHttpContinueRejected.
@Test
public void testHttpContinueRejected() throws IOException {
accept = false;
String message = "My HTTP Request!";
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("http.protocol.wait-for-continue", Integer.MAX_VALUE);
TestHttpClient client = new TestHttpClient();
client.setParams(httpParams);
try {
HttpPost post = new HttpPost(DefaultServer.getDefaultServerURL() + "/path");
post.addHeader("Expect", "100-continue");
post.setEntity(new StringEntity(message));
HttpResponse result = client.execute(post);
Assert.assertEquals(StatusCodes.EXPECTATION_FAILED, result.getStatusLine().getStatusCode());
} finally {
client.getConnectionManager().shutdown();
}
}
use of org.apache.http.params.HttpParams in project undertow by undertow-io.
the class TestHttpClient method createHttpParams.
@Override
protected HttpParams createHttpParams() {
HttpParams params = super.createHttpParams();
HttpConnectionParams.setSoTimeout(params, 30000);
return params;
}
use of org.apache.http.params.HttpParams in project ThinkAndroid by white-cat.
the class AsyncHttpClient method setTimeout.
/**
* Sets the connection time oout. By default, 10 seconds
*
* @param timeout
* the connect/socket timeout in milliseconds
*/
public void setTimeout(int timeout) {
final HttpParams httpParams = this.httpClient.getParams();
ConnManagerParams.setTimeout(httpParams, timeout);
HttpConnectionParams.setSoTimeout(httpParams, timeout);
HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
}
use of org.apache.http.params.HttpParams in project voldemort by voldemort.
the class HttpClientBench method createClient.
private static HttpClient createClient() {
ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(), DEFAULT_CONNECTION_MANAGER_TIMEOUT, TimeUnit.MILLISECONDS);
DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);
HttpParams clientParams = httpClient.getParams();
HttpConnectionParams.setSocketBufferSize(clientParams, 60000);
HttpConnectionParams.setTcpNoDelay(clientParams, false);
HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
// HostConfiguration hostConfig = new HostConfiguration();
// hostConfig.setHost("localhost");
HttpConnectionParams.setConnectionTimeout(clientParams, DEFAULT_CONNECTION_MANAGER_TIMEOUT);
HttpConnectionParams.setSoTimeout(clientParams, 500);
httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
connectionManager.setMaxTotal(DEFAULT_MAX_CONNECTIONS);
connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_HOST_CONNECTIONS);
HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);
return httpClient;
}
use of org.apache.http.params.HttpParams in project voldemort by voldemort.
the class HttpStoreTest method testBadUrlOrPort.
public <T extends Exception> void testBadUrlOrPort(String url, int port, Class<T> expected) {
ByteArray key = new ByteArray("test".getBytes());
RequestFormat requestFormat = new RequestFormatFactory().getRequestFormat(RequestFormatType.VOLDEMORT_V1);
HttpParams clientParams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(clientParams, 5000);
HttpStore badUrlHttpStore = new HttpStore("test", url, port, httpClient, requestFormat, false);
try {
badUrlHttpStore.put(key, new Versioned<byte[]>("value".getBytes(), new VectorClock()), null);
} catch (Exception e) {
assertTrue(e.getClass().equals(expected));
}
try {
badUrlHttpStore.get(key, null);
} catch (Exception e) {
assertTrue(e.getClass().equals(expected));
}
try {
badUrlHttpStore.delete(key, new VectorClock());
} catch (Exception e) {
assertTrue(e.getClass().equals(expected));
}
}
Aggregations