List of usage examples for org.apache.http.params HttpConnectionParams setSoTimeout
public static void setSoTimeout(HttpParams httpParams, int i)
From source file:com.todotxt.todotxttouch.util.Util.java
public static HttpParams getTimeoutHttpParams() { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_TIMEOUT); return params; }
From source file:org.droidparts.http.wrapper.DefaultHttpClientWrapper.java
public DefaultHttpClientWrapper(String userAgent) { super(userAgent); httpClient = new DefaultHttpClient(); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, SOCKET_OPERATION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_OPERATION_TIMEOUT); HttpConnectionParams.setSocketBufferSize(params, BUFFER_SIZE); if (userAgent != null) { HttpProtocolParams.setUserAgent(params, userAgent); }//from w w w. ja va 2s.com }
From source file:com.microsoft.applicationinsights.internal.channel.common.ApacheSender42.java
public ApacheSender42() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS); cm.setDefaultMaxPerRoute(DEFAULT_MAX_CONNECTIONS_PER_ROUTE); httpClient = new DefaultHttpClient(cm); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, REQUEST_TIMEOUT_IN_MILLIS); HttpConnectionParams.setSoTimeout(params, REQUEST_TIMEOUT_IN_MILLIS); InternalLogger.INSTANCE.info("Using Apache HttpClient 4.2"); }
From source file:net.a2bsoft.buss.http.SendQuery.java
public static String sendQuery(String query) { try {/*from ww w.ja v a 2 s . co m*/ query = URLEncoder.encode(query, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return e.getMessage(); } URL url = null; try { url = new URL( "http://www.atb.no/xmlhttprequest.php?service=routeplannerOracle.getOracleAnswer&question=" + query); } catch (MalformedURLException e) { e.printStackTrace(); } String result = null; HttpParams my_httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(my_httpParams, 30000); HttpConnectionParams.setSoTimeout(my_httpParams, 30000); HttpClient client = new DefaultHttpClient(my_httpParams); HttpGet get = new HttpGet(url.toString()); HttpResponse resp; try { resp = client.execute(get); InputStream data = resp.getEntity().getContent(); result = new BufferedReader(new InputStreamReader(data)).readLine(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); return sendQueryBusstuc(query); // return e.getMessage(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return sendQueryBusstuc(query); // return e.getMessage(); } return result; }
From source file:com.dimasdanz.kendalipintu.util.JSONParser.java
public JSONObject makeHttpRequest(String url, String method, List<NameValuePair> params) { try {//w w w . ja v a2 s . co m HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(httpParameters, so_timeout); HttpConnectionParams.setConnectionTimeout(httpParameters, co_timeout); if (method == "POST") { DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } else if (method == "GET") { DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (SocketTimeoutException e) { Log.e("SocketTimeoutException", "SocketTimeoutException"); e.printStackTrace(); return null; } catch (UnsupportedEncodingException e) { Log.e("UnsupportedEncodingException", "UnsupportedEncodingException"); e.printStackTrace(); return null; } catch (ClientProtocolException e) { Log.e("ClientProtocolException", "ClientProtocolException"); e.printStackTrace(); return null; } catch (IOException e) { Log.e("IOException", "IOException"); e.printStackTrace(); return null; } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Buffer Error : " + e.toString()); return null; } try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); return null; } return jObj; }
From source file:ua.at.tsvetkov.data_processor.requests.DeleteRequest.java
@Override public InputStream getInputStream() throws IOException { if (!isBuild()) throw new IllegalArgumentException(REQUEST_IS_NOT_BUILDED); startTime = System.currentTimeMillis(); HttpConnectionParams.setConnectionTimeout(httpParameters, configuration.getTimeout()); HttpConnectionParams.setSoTimeout(httpParameters, configuration.getTimeout()); HttpDelete httpPost = new HttpDelete(toString()); httpPost.setParams(httpParameters);//from w ww.ja v a 2 s. co m printToLogUrl(); return getResponce(httpPost); }
From source file:gov.nist.appvet.tool.sigverifier.util.ReportUtil.java
/** This method should be used for sending files back to AppVet. */ public static boolean sendInNewHttpRequest(String appId, String reportFilePath, ToolStatus reportStatus) { HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 30000); HttpConnectionParams.setSoTimeout(httpParameters, 1200000); HttpClient httpClient = new DefaultHttpClient(httpParameters); httpClient = SSLWrapper.wrapClient(httpClient); try {/* ww w .ja v a2s. c o m*/ /* * To send reports back to AppVet, the following parameters must be * sent: - command: SUBMIT_REPORT - username: AppVet username - * password: AppVet password - appid: The app ID - toolid: The ID of * this tool - toolrisk: The risk assessment (LOW, MODERATE, HIGH, * ERROR) - report: The report file. */ MultipartEntity entity = new MultipartEntity(); entity.addPart("command", new StringBody("SUBMIT_REPORT", Charset.forName("UTF-8"))); entity.addPart("username", new StringBody(Properties.appvetUsername, Charset.forName("UTF-8"))); entity.addPart("password", new StringBody(Properties.appvetPassword, Charset.forName("UTF-8"))); entity.addPart("appid", new StringBody(appId, Charset.forName("UTF-8"))); entity.addPart("toolid", new StringBody(Properties.toolId, Charset.forName("UTF-8"))); entity.addPart("toolrisk", new StringBody(reportStatus.name(), Charset.forName("UTF-8"))); File report = new File(reportFilePath); FileBody fileBody = new FileBody(report); entity.addPart("file", fileBody); HttpPost httpPost = new HttpPost(Properties.appvetUrl); httpPost.setEntity(entity); // Send the report to AppVet log.debug("Sending report file to AppVet"); final HttpResponse response = httpClient.execute(httpPost); log.debug("Received from AppVet: " + response.getStatusLine()); HttpEntity httpEntity = response.getEntity(); InputStream is = httpEntity.getContent(); String result = IOUtils.toString(is, "UTF-8"); log.info(result); // Clean up httpPost = null; return true; } catch (Exception e) { log.error(e.toString()); return false; } }
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);//from ww w .j a va 2s .c o m setPriority(MIN_PRIORITY); }
From source file:de.ecclesia.kipeto.repository.HttpRepositoryStrategy.java
public HttpRepositoryStrategy(String repository) { this.repository = repository; HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, (int) TimeUnit.SECONDS.toMillis(5)); HttpConnectionParams.setSoTimeout(httpParams, (int) TimeUnit.SECONDS.toMillis(10)); client = new DefaultHttpClient(httpParams); }