View difference between Paste ID: RwxMDTYW and ZEP2HW6T
SHOW: | | - or go back to the newest paste.
1-
/* @author Nesswit, Heewon Lee
1+
2-
 * [email protected]
2+
 * HTTP POST 전송
3-
 * 이 소스 코드는 현재 사용중인 다른 프로젝트의 일부분을 가져온 것입니다.
3+
4-
 * 따라서 이 코드만으로는 완전히 동작하지 않습니다.
4+
5
 * 
6-
 
6+
7
 */
8-
 * HTTP GET 전송
8+
private String httpRequestPost(final String url, final ArrayList<BasicNameValuePair> params) {
9
	//타임아웃 설정
10
	final int timeoutSeconds = 15;
11
	
12
	//Callable 선언
13
	final Callable<String> postCallable = new Callable<String>() {
14-
public String httpRequestGet(final String url, final ArrayList<BasicNameValuePair> params) {
14+
15-
	//반환할 Response String
15+
16-
	String result = null;
16+
			final HttpClient client = new DefaultHttpClient();
17
			final UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params, HTTP.UTF_8);
18-
	/*
18+
			final HttpResponse responsePost = client.execute(new HttpPost(url).post.setEntity(ent));
19-
	 * Callable을 통해 비동기적으로 처리
19+
			final HttpEntity resEntity = responsePost.getEntity();
20-
	 */
20+
			return EntityUtils.toString(resEntity);
21
		}
22-
	Callable<String> getCallable = new Callable<String>() {
22+
23
24
	try {
25-
			String ent = URLEncodedUtils.format(params, HTTP.UTF_8);
25+
		//callable 시작
26-
			HttpGet get = new HttpGet(url + "?" + ent);
26+
		final Future<String> postFuture = es.submit(postCallable);
27-
			HttpResponse response = null;
27+
28
		//결과값 반환
29-
			try {
29+
		return postFuture.get(timeoutSeconds, TimeUnit.SECONDS);
30-
				response = getClient().execute(get);
30+
31-
			} catch (Exception e) {}
31+
	return null;
32
}