문서의 이전 판입니다!
HttpClient httpClient = HttpClientBuilder.create().useSystemProperties() .setMaxConnTotal([최대 커넥션 갯수]) .setMaxConnPerRoute([IP/domain name당 최대 커넥션 갯수]) ....
DefaultHttpClient httpClient = new DefaultHttpClient(); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(httpParams, connectionTimeoutMillis); HttpConnectionParams.setSoTimeout(httpParams, socketTimeoutMillis);
HttpProtocolParams.setContentCharset(httpParams, "UTF-8");
UrlEncodedFormEntity 클래스 생성자에서 문자 인코딩 지정
HttpPost post = new HttpPost("http://...."); List<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("paramName", "param value")); // params... post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
> HTTP specification permits both the client and the server to terminate a persistent (keep-alive) connection at any time without notice to the counterpart, thus rendering the connection invalid or stale. By default HttpClient performs a check, just prior to executing a request, to determine if the active connection is stale. The cost of this operation is about 15-30 ms, depending on the JRE used. Disabling stale connection check may result in slight performance improvement, especially for small payload responses, at the risk of getting an I/O error when executing a request over a connection that has been closed at the server side.
See the http.connection.stalecheck parameter documentation for more information.