List of usage examples for org.apache.http.params HttpParams setParameter
HttpParams setParameter(String str, Object obj);
From source file:com.akop.bach.util.IgnorantHttpClient.java
@Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30)); params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); return new ThreadSafeClientConnManager(params, registry); }
From source file:com.devbliss.doctest.httpfactory.DeleteWithoutRedirectImpl.java
public HttpDelete createDeleteRequest(URI uri) throws IOException { HttpDelete httpDelete = new HttpDelete(uri); HttpParams params = new BasicHttpParams(); params.setParameter(HANDLE_REDIRECTS, false); httpDelete.setParams(params);//from w ww .java 2s . c o m return httpDelete; }
From source file:com.flowzr.http.HttpClientWrapper.java
public String getAsStringIfOk(String url) throws Exception { HttpGet get = new HttpGet(url); HttpParams params = new BasicHttpParams(); params.setParameter("http.protocol.handle-redirects", false); get.setParams(params);//from www. j a v a2 s. co m HttpResponse r = httpClient.execute(get); String s = EntityUtils.toString(r.getEntity()); if (r.getStatusLine().getStatusCode() == 200) { return s; } else { throw new RuntimeException(s); } }
From source file:com.devbliss.doctest.httpfactory.DeleteWithoutRedirectImpl.java
public HttpDeleteWithBody createDeleteRequest(URI uri, Object payload) throws IOException { HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(uri); HttpParams params = new BasicHttpParams(); params.setParameter(HANDLE_REDIRECTS, false); httpDelete.setParams(params);/*from w ww.j a v a 2 s .co m*/ if (payload != null) { httpDelete.setEntity(entityBuilder.buildEntity(payload)); } return httpDelete; }
From source file:edu.syr.bytecast.githubcampfire.CampfirePost.java
public CampfirePostReply post(String message) { //see: http://stackoverflow.com/questions/2603691/android-httpclient-and-https try {/*from www . j a v a 2s . c o m*/ String xml_message = "<message><type>TextMessage</type><body>" + message + "</body></message>"; SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); BasicSchemeFactory factory = new BasicSchemeFactory(); HttpParams params = new BasicHttpParams(); params.setParameter("realm", "https://trifort.campfirenow.com/"); SingleClientConnManager mgr = new SingleClientConnManager(params, schemeRegistry); DefaultHttpClient client = new DefaultHttpClient(mgr, params); String url = "https://trifort.campfirenow.com/room/" + m_room + "/speak.xml"; HttpPost post = new HttpPost(url); post.setHeader("Content-type", "application/xml"); AuthScheme scheme = factory.newInstance(params); Header header = scheme.authenticate(new UsernamePasswordCredentials(m_apiKey), post); HttpEntity entity = new StringEntity(xml_message); post.setEntity(entity); post.setHeader(header); HttpResponse response = client.execute(post); return new CampfirePostReply(response); } catch (Exception ex) {//post.setEntity; ex.printStackTrace(); return null; } }
From source file:org.eclipse.jetty.rhttp.client.ApacheClientTest.java
protected RHTTPClient createClient(int port, String targetId) throws Exception { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), port)); connectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry); HttpParams httpParams = new BasicHttpParams(); httpParams.setParameter("http.default-host", new HttpHost("localhost", port)); DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpParams); httpClient.setHttpRequestRetryHandler(new NoRetryHandler()); return new ApacheClient(httpClient, "", targetId); }
From source file:org.jvoicexml.documentserver.schemestrategy.HttpClientSessionIdentifierFactory.java
/** * {@inheritDoc}//from w ww . j a va 2s . c o m */ @Override public HttpClient createSessionIdentifier(final String sessionId) { final HttpClient client = new DefaultHttpClient(); if (PROXY_HOST != null) { HttpHost proxy = new HttpHost(PROXY_HOST, PROXY_PORT); HttpParams params = client.getParams(); params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } return client; }
From source file:com.mpower.daktar.android.utilities.WebUtils.java
public static final HttpClient createHttpClient(final int timeout) { // configure connection final HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpConnectionParams.setSoTimeout(params, timeout); // support redirecting to handle http: => https: transition HttpClientParams.setRedirecting(params, true); // support authenticating HttpClientParams.setAuthenticating(params, true); // if possible, bias toward digest auth (may not be in 4.0 beta 2) final List<String> authPref = new ArrayList<String>(); authPref.add(AuthPolicy.DIGEST);/*from w w w.ja va 2 s . c o m*/ authPref.add(AuthPolicy.BASIC); // does this work in Google's 4.0 beta 2 snapshot? params.setParameter("http.auth-target.scheme-pref", authPref); // setup client final HttpClient httpclient = new DefaultHttpClient(params); httpclient.getParams().setParameter(ClientPNames.MAX_REDIRECTS, 1); httpclient.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); return httpclient; }
From source file:net.vexelon.mobileops.MTLClient.java
/** * Initialize Http Client/*w ww . j av a2 s.c om*/ */ private void initHttpClient() { HttpParams params = new BasicHttpParams(); params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); params.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.TRUE); params.setParameter(CoreProtocolPNames.USER_AGENT, HTTP_USER_AGENT); //params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8); httpClient = new DefaultHttpClient(params); httpCookieStore = new BasicCookieStore(); httpClient.setCookieStore(httpCookieStore); }
From source file:org.sonatype.nexus.test.utils.hc4client.Hc4ClientHelper.java
@Override public void start() throws Exception { super.start(); HttpParams params = new SyncBasicHttpParams(); params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, getConnectTimeout()); params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, getReadTimeout()); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); final PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(); connManager.setMaxTotal(getMaxTotalConnections()); connManager.setDefaultMaxPerRoute(getMaxConnectionsPerHost()); httpClient = new DefaultHttpClient(connManager, params); getLogger().info("Starting the HTTP client"); }