package com.eactive.eai.adapter.http; 
//import org.apache.commons.httpclient.params.HttpClientParams;


public class HttpClientTest 
{ 
//    public static void main(String args[]) throws Exception {
//       MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
//        
//        
//        cm.setConnectionStaleCheckingEnabled(false);
//        cm.setMaxConnectionsPerHost(10);
//        cm.setMaxTotalConnections(1);
//        
//        // 2.0
//        HttpClient client = new HttpClient(cm); 
//        
//        //---------------------------------------------
//        // 3.1
//        //---------------------------------------------
//        /*
//        HttpClientParams params = new HttpClientParams();
//        params.setSoTimeout(10 * 1000);
//        HttpClient client = new HttpClient(params, cm); 
//        */
//        //---------------------------------------------
//        
//        // Client Timeout 2.0
//        //client.setTimeout(1000);
//        String url = "http://172.29.65.69:7001/servlets/knova/svc/servlet/KBServlet";
//        //String url = "http://search.empas.com/error.html";
//        //String url = "http://172.17.33.237:7001/servlets/knova/svc/servlet/KBServlet";
//        
//        PostMethod method = new PostMethod(url);
//        DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
//        retryhandler.setRequestSentRetryEnabled(false);
//        retryhandler.setRetryCount(3);
//        method.setMethodRetryHandler(retryhandler);
//        
//        method.getParams().setSoTimeout(5000);
//        
//        System.out.println("HttpClientAdapter] getContentCharset("+client.getParams().getContentCharset()+") ");
//        //client.getParams().setContentCharset("KSC5601");
//        System.out.println("HttpClientAdapter] getContentCharset("+client.getParams().getContentCharset()+") ");
//        
//        String encode = "ISO8859_1";
//        byte[]  data = "000924KCO.11YE#0803249920000026                        0200NOV01500001    20080324175117  HOSTDOM     NOVDOM                  BB2B                    YE#0803249920000026                        4001                     000306604151345551013205062155211 이기옥　　　　　　　　　　　　              EL08022500020000000000000000056020080324200902261                                                                                                                                                                                ？                                                                                   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000                                                                                                                                                                                                            "  
//        .getBytes();
//        String sendData = null;
//        if(encode != null && encode.length() > 0) {
//            System.out.println("HttpClientAdapter] ENCODE("+encode+") ");
//        
//            try {
//                sendData = new String(data,encode);                    
//            } catch(Exception e) {
//                System.out.println("HttpClientAdapter] ENCODE("+encode+") ERROR : "+ e.toString());
//                System.out.println("HttpClientAdapter] ENCODE("+encode+") SKIP ");
//                sendData = new String(data); 
//            }
//        }
//        else {
//            sendData = java.net.URLEncoder.encode(new String(data));
//        }
//        
//        method.addParameter("_ELD_", sendData);
//            
//        int status = -1;
//        try {
//            status = client.executeMethod(method);
//            //String responseMessage = method.getResponseBodyAsString();
//            byte[] responseBytes = method.getResponseBody();
//            System.out.println("method.getRequestCharSet() [" + method.getRequestCharSet() +"]");
//            System.out.println("method.getResponseCharSet() [" + method.getResponseCharSet() +"]");
//            System.out.println("responseMessage [" +new String(responseBytes) +"]");
//            System.out.println("ISO8859_1       [" + new String(responseBytes, "ISO8859_1")  +"]");
//            System.out.println("EUC-KR          [" + new String(responseBytes, "EUC-KR") +"]");
//        } catch(ConnectException ce) {
//            System.out.println("Connection Exception : " + ce.toString() );
//        } catch(HttpRecoverableException hre) { // HttpClient 2.0일 경우에 발생
//            System.out.println("HttpRecoverableException : " + hre.toString() );
//        } catch(SocketTimeoutException ste) { // HttpClient 3.1일 경우에 발생
//            System.out.println("SocketTimeoutException : " + ste.toString() );
//        } catch(Exception e) {
//            e.printStackTrace();
//            throw e;
//        } finally {
//            method.releaseConnection();
//            if(status != HttpStatus.SC_OK) {
//                System.out.println("HttpStatus ["+status+"]");
//            }
//        }
//    }
    
} 
