List of usage examples for org.apache.http.params BasicHttpParams BasicHttpParams
public BasicHttpParams()
From source file:net.instantcom.keikosniffer.http.SessionInputBufferMockup.java
public SessionInputBufferMockup(final InputStream instream, int buffersize) { this(instream, buffersize, new BasicHttpParams()); }
From source file:com.base.httpclient.HttpJsonClient.java
/** * httpClient/*from w ww. j a v a 2s . com*/ * @return */ public static DefaultHttpClient getHttpClient() { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); HttpParams httpParams = new BasicHttpParams(); cm.setMaxTotal(10);// cm.setDefaultMaxPerRoute(5);// ? HttpConnectionParams.setConnectionTimeout(httpParams, 60000);// HttpConnectionParams.setSoTimeout(httpParams, 60000);//? HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1); HttpProtocolParams.setUseExpectContinue(httpParams, false); httpParams.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); DefaultHttpClient httpClient = new DefaultHttpClient(cm, httpParams); //httpClient.setCookieStore(null); httpClient.getCookieStore().clear(); httpClient.getCookieStore().getCookies().clear(); // httpClient.setHttpRequestRetryHandler(new HttpJsonClient().new HttpRequestRetry());//? return httpClient; }
From source file:org.devtcg.five.server.AbstractHttpServer.java
public AbstractHttpServer() throws IOException { mSocket = new ServerSocket(); mParams = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(mParams, 60000); setDaemon(true);//w ww.j a va 2 s. c om setPriority(MIN_PRIORITY); }
From source file:edu.vanderbilt.android.vuparking.network.ParkingClient.java
public ParkingClient(Context context) { mContext = context;//w ww . j a v a2s. com HttpParams httpParameters = new BasicHttpParams(); // Set the timeout in milliseconds. int timeoutConnection = 3000; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); // Set the default socket timeout (SO_TIMEOUT) int timeoutSocket = 5000; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); client = new DefaultHttpClient(httpParameters); }
From source file:Main.java
public static DefaultHttpClient getThreadSafeClient() { if (httpclient != null) return (DefaultHttpClient) httpclient; HttpParams params = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(params, 100); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); // Create and initialize scheme registry SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); httpclient = new DefaultHttpClient(cm, params); return (DefaultHttpClient) httpclient; }
From source file:com.msopentech.thali.utilities.ThaliHttpClientFactory.java
@Override public HttpClient getHttpClient() { BasicHttpParams basicHttpParams = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("https", httpKeySSLSocketFactory, 443)); try {// w ww .j av a 2 s . co m return new HttpKeyHttpClient(serverPublicKey, clientKeyStore, clientKeyStorePassPhrase, proxy, basicHttpParams); } catch (UnrecoverableKeyException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (KeyStoreException e) { throw new RuntimeException(e); } catch (KeyManagementException e) { throw new RuntimeException(e); } }
From source file:playn.http.HttpAndroid.java
@Override protected void doSend(final HttpRequest request, final Callback<HttpResponse> callback) { platform.invokeAsync(new Runnable() { public void run() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setHttpElementCharset(params, HTTP.UTF_8); HttpClient httpclient = new DefaultHttpClient(params); HttpRequestBase req;/*from www . j a v a2 s. c om*/ HttpMethod method = request.getMethod(); String url = request.getUrl(); switch (method) { case GET: req = new HttpGet(url); break; case POST: req = new HttpPost(url); break; case PUT: req = new HttpPut(url); break; default: throw new UnsupportedOperationException(method.toString()); } String requestBody = request.getBody(); if (requestBody != null && req instanceof HttpEntityEnclosingRequestBase) { try { HttpEntityEnclosingRequestBase op = (HttpEntityEnclosingRequestBase) req; op.setEntity(new StringEntity(requestBody)); } catch (UnsupportedEncodingException e) { platform.notifyFailure(callback, e); } } for (Map.Entry<String, String> header : request.getHeaders()) { req.setHeader(header.getKey(), header.getValue()); } int statusCode = -1; String statusLineMessage = null; Map<String, String> responseHeaders = new HashMap<String, String>(); String responseBody = null; try { org.apache.http.HttpResponse response = httpclient.execute(req); StatusLine statusLine = response.getStatusLine(); statusCode = statusLine.getStatusCode(); statusLineMessage = statusLine.getReasonPhrase(); for (Header header : response.getAllHeaders()) { responseHeaders.put(header.getName(), header.getValue()); } responseBody = EntityUtils.toString(response.getEntity()); HttpResponse httpResponse = new HttpResponse(statusCode, statusLineMessage, responseHeaders, responseBody); platform.notifySuccess(callback, httpResponse); } catch (Throwable cause) { HttpErrorType errorType = cause instanceof ConnectTimeoutException || cause instanceof HttpHostConnectException || cause instanceof ConnectionPoolTimeoutException || cause instanceof UnknownHostException ? HttpErrorType.NETWORK_FAILURE : HttpErrorType.SERVER_ERROR; HttpException reason = new HttpException(statusCode, statusLineMessage, responseBody, cause, errorType); platform.notifyFailure(callback, reason); } } }); }
From source file:com.catchoom.api.Catchoom.java
public Catchoom() { HttpParams httpParams = new BasicHttpParams(); httpParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); mHttpClient = new DefaultHttpClient(httpParams); }
From source file:ua.at.tsvetkov.data_processor.requests.WebRequest.java
@Override public Request build() { if (httpParameters == null) httpParameters = new BasicHttpParams(); return super.build(); }
From source file:org.elegosproject.romupdater.DownloadManager.java
public static boolean sendAnonymousData() { String link = "http://www.elegosproject.org/android/upload.php"; String data;//from w w w . ja v a 2s . c om SharedData shared = SharedData.getInstance(); String romName = shared.getRepositoryROMName(); String romVersion = shared.getDownloadVersion(); String romPhone = shared.getRepositoryModel(); String romRepository = shared.getRepositoryUrl(); if (romName.equals("") || romVersion.equals("") || romPhone.equals("") || romRepository.equals("")) { Log.e(TAG, "Internal error - missing system variables."); return false; } if (!checkHttpFile(link)) return false; try { data = URLEncoder.encode("phone", "UTF-8") + "=" + URLEncoder.encode(romPhone, "UTF-8"); data += "&" + URLEncoder.encode("rom_name", "UTF-8") + "=" + URLEncoder.encode(romName, "UTF-8"); data += "&" + URLEncoder.encode("rom_version", "UTF-8") + "=" + URLEncoder.encode(romVersion, "UTF-8"); data += "&" + URLEncoder.encode("rom_repository", "UTF-8") + "=" + URLEncoder.encode(romRepository, "UTF-8"); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); URL url = new URL(link); url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("User-Agent", "ROMUpdater"); conn.setDoOutput(true); PrintWriter out = new PrintWriter(conn.getOutputStream()); out.println(data); out.close(); int status = Integer.parseInt(conn.getHeaderField("ROMUpdater-status")); if (status == 1) return true; Log.e(TAG, "It was impossible to send data to the stastistics server (" + conn.getHeaderField("ROMUpdater-error") + ")."); return false; } catch (Exception e) { Log.e(TAG, "It was impossible to send data to the stastistics server."); Log.e(TAG, "Error: " + e.toString()); return false; } }