use of org.apache.http.params.BasicHttpParams in project undertow by undertow-io.
the class AbstractHttpContinueServletTestCase method testHttpContinueIgnored.
@Test
public void testHttpContinueIgnored() throws IOException {
accept = true;
String message = "My HTTP Request!";
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("http.protocol.wait-for-continue", Integer.MAX_VALUE);
TestHttpClient client = getClient();
client.setParams(httpParams);
try {
HttpPost post = new HttpPost(getServerAddress() + "/servletContext/ignore");
post.addHeader("Expect", "100-continue");
post.setEntity(new StringEntity(message));
HttpResponse result = client.execute(post);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
Assert.assertEquals("", HttpClientUtils.readResponse(result));
} finally {
client.getConnectionManager().shutdown();
}
}
use of org.apache.http.params.BasicHttpParams in project undertow by undertow-io.
the class AbstractHttpContinueServletTestCase method testHttpContinueAccepted.
@Test
public void testHttpContinueAccepted() throws IOException {
accept = true;
String message = "My HTTP Request!";
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("http.protocol.wait-for-continue", Integer.MAX_VALUE);
TestHttpClient client = getClient();
client.setParams(httpParams);
try {
HttpPost post = new HttpPost(getServerAddress() + "/servletContext/path");
post.addHeader("Expect", "100-continue");
post.setEntity(new StringEntity(message));
HttpResponse result = client.execute(post);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
Assert.assertEquals(message, HttpClientUtils.readResponse(result));
} finally {
client.getConnectionManager().shutdown();
}
}
use of org.apache.http.params.BasicHttpParams 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.BasicHttpParams in project musicbrainz-android by jdamcd.
the class HttpClient method setupParams.
private static HttpParams setupParams() {
HttpParams params = new BasicHttpParams();
ConnManagerParams.setTimeout(params, TIMEOUT);
ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(MAX_CONNECTIONS));
ConnManagerParams.setMaxTotalConnections(params, MAX_CONNECTIONS);
HttpConnectionParams.setSoTimeout(params, TIMEOUT);
HttpConnectionParams.setTcpNoDelay(params, true);
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
return params;
}
use of org.apache.http.params.BasicHttpParams in project ignition by mttkay.
the class IgnitedHttp method setupHttpClient.
protected void setupHttpClient() {
BasicHttpParams httpParams = new BasicHttpParams();
ConnManagerParams.setTimeout(httpParams, DEFAULT_WAIT_FOR_CONNECTION_TIMEOUT);
ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(DEFAULT_MAX_CONNECTIONS));
ConnManagerParams.setMaxTotalConnections(httpParams, DEFAULT_MAX_CONNECTIONS);
HttpConnectionParams.setSoTimeout(httpParams, DEFAULT_SOCKET_TIMEOUT);
HttpConnectionParams.setTcpNoDelay(httpParams, true);
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setUserAgent(httpParams, DEFAULT_HTTP_USER_AGENT);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
if (IgnitedDiagnostics.ANDROID_API_LEVEL >= 7) {
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
} else {
// used to work around a bug in Android 1.6:
// http://code.google.com/p/android/issues/detail?id=1946
// TODO: is there a less rigorous workaround for this?
schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
}
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
httpClient = new DefaultHttpClient(cm, httpParams);
}
Aggregations