开发者

How to request a secured connection (https)?

开发者 https://www.devze.com 2023-03-15 11:54 出处:网络
Generally, we use http connection like this: try{ HttpClient httpclient = new DefaultHttpClient(); //final HttpParams params = httpclient.getParams();

Generally, we use http connection like this:

try{

            HttpClient httpclient = new DefaultHttpClient();
//              final HttpParams params = httpclient.getParams();
//              HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);
//              HttpConnectionParams.setSoTimeout(params, WAIT_TIMEOUT);
//              ConnManagerParams.setTimeout(params, WAIT_TIMEOUT);

                HttpPost httppost = new HttpPost(url);
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();

        }catch(开发者_如何学编程Exception e){
              // Log.e("log_tag", "Error in http connection "+e.toString());
        }

This code snippet is used for http.

How can I request a secured connection (https) ?


If you are after Android 2.2, you can simply use class AndroidHttpClient.
It will be work through https, if url scheme is https.

Otherwise, you can look to its source and make similar, and may be even easier.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号