The code I use originally as following. And now I want to make a new method
using HttpClient to do the same thing.

 

----

 

//connect for output support

        public boolean connect(String url, String requestMethod, String
output){

                try {

                        HostnameVerifier hv = initSSL();

                        URL u = new URL(url);

                        URLConnection uc = u.openConnection();

                        HttpsURLConnection httpc = (HttpsURLConnection) uc;

                        httpc.setDoOutput(true);

                        httpc.setHostnameVerifier(hv);

                        httpc.setRequestMethod(requestMethod);

                        

                        httpc.setConnectTimeout(CONNECT_TIMEOUT);

                        httpc.connect();

                        

                        // I don't know how to replace the following by
HttpClient

                        OutputStream raw = httpc.getOutputStream();

                        OutputStream buffered = new
BufferedOutputStream(raw);

                        OutputStreamWriter out = new
OutputStreamWriter(buffered, "UTF-8");

                        out.write(output);

                        out.flush();

                        out.close();

                } catch (MalformedURLException e) {

                        return false;

                } catch (IOException e) {

                        return false;

                }

                return true;

        }

 

----

 

Please tell me where to set HttpEntity/HttpContext or not. And how to do?!

 

 

Thanks in advance.

 

Sincerely,

Micky

 

Reply via email to