为什么 android 没有使用 HttpURLConnection 和 POST 方法在服务器上发布完整的电子邮件?

Why android is not posting full email on the server using HttpURLConnection and POST method?

我正在尝试使用 android 中的 HttpURLConnection 和 POST 方法在我的服务器上 post 数据。这是我的 android 代码

String urlParameters  = URLEncoder.encode("email", "UTF-8") + "=" +
                                    URLEncoder.encode(email, "UTF-8");
            byte[] postData       = urlParameters.getBytes( "UTF-8" );
            int    postDataLength = postData.length;

//System.out.println(email);           

            HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
            urlConnection.setDoOutput(true);
            urlConnection.setDoInput(true);
            urlConnection.setRequestMethod("POST");
            urlConnection.setChunkedStreamingMode(0);
            urlConnection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
            urlConnection.setRequestProperty( "charset", "utf-8");
            urlConnection.setRequestProperty( "Content-Length", Integer.toString( postDataLength ));
            urlConnection.setUseCaches( false );


            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
            wr.write( postData );
            wr.close();

            InputStream in = new BufferedInputStream(urlConnection.getInputStream());

在我正在打印的这段代码中 email 它向我显示了正确的完整电子邮件 abc@xyz.com 但是当我在我的服务器上收到它时它不是完整的电子邮件。

我正在为我的网站使用 pyhton 和 django。当我在服务器上打印我的 post 数据时,它给了我这个结果,

<QueryDict: {'1e\r\nemail': ['abc@xyz']}>

如果您注意到,我在密钥中收到 1e,有时 1c,而不仅仅是 email。那么谁能告诉我我的代码有什么问题?或者为什么我会收到这些数据?

您的 Android 代码看起来没问题。但是在没有分块流模式的情况下尝试一下并设置缓存行。