hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "micky" <micky_...@cyberpowersystems.com.tw>
Subject Re: [help] how to set an OutputStream to a POST request?
Date Tue, 26 Feb 2008 09:52:18 GMT
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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message