我没有收到Android应用发送的POST变量(与SSL https相关)

啤酒灯笼

在将startSSL.com的证书添加到我的服务器之前,该应用程序运行良好。POST阵列在服务器上为空。而且我没有任何错误,我从服务器获得了响应。

这是我用于在AsyncTasks中进行服务器调用的代码。

    // Making HTTP request
    try {

        // check for request method
        if(method == "POST"){
            // request method is POST

            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(params));

            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();

        }else if(method == "GET"){
            // request method is GET
            DefaultHttpClient httpClient = new DefaultHttpClient();
            //String paramString = URLEncodedUtils.format(params, "utf-8");
           // url += "?" + paramString;

            for (NameValuePair nameValuePair : params) { // modificado para usar URIS
                url += "/" + nameValuePair.getValue();
            }
            Log.d("Intentando conectar con el servidor: ", url);
            HttpGet httpGet = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();
        }           

任何的想法?

啤酒灯笼

这是一个服务器问题。从网址中删除“ www”部分即可解决该问题。我没有使用www配置服务器,但是我没有想到它会以这种方式让我汗流sweat背。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章