In android, I try to send to the web server in a json structure. It works fine with http. But with https, $_POST values pairs are gone. In PHP, var_dump $_POST returns array(0) However,HttpGet works well with both http and https.
MyHttpClient httpClient = new MyHttpClient(context);
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
Try to catch raw post data in php.
It sounds like you're sending your request to an
http://
URL and counting on a redirection (possibly viamod_rewrite
or something similar such as a redirection in the PHP code itself) to turn your page intohttps
.This mode of operation first makes the plain HTTP request to the server, which then tells the client that the resource has moved to the
https://
address. In turn, if the automatic redirection is activated, the client makes a second request.According to the HTTP specification, for status codes 301 or 302 (which are used for the redirection),
Most browsers interpret this as "if the first request was a POST, don't re-send the data for the redirected request, but make the second request a GET anyway." This would explain why you lose any POSTed body for the second attempt.
Note that, for the reasons explained in this answer, over-reliance on rewrite/redirects to turn an
http://
request into anhttps://
request should be considered bad practice.