Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
androidhttppost-400错误请求_Android_Apache_Http - Fatal编程技术网

androidhttppost-400错误请求

androidhttppost-400错误请求,android,apache,http,Android,Apache,Http,我正在使用库与web服务器交互 我正在发送POST请求,并得到带有200状态码(Ok)的空响应 但在检查与Fiddler的连接后,我发现我收到了400个错误请求 如果我尝试获取请求,一切都会正常进行 UPD:我发现了问题的根源-我的base64参数(“数据”)不知怎么被更改了。我的代码生成有效的base64字符串,但在请求中添加了“0%3D%0A”,使其无法验证 我的发帖要求: POST http://example.com HTTP/1.1 Content-Length: 143 Conten

我正在使用库与web服务器交互

我正在发送POST请求,并得到带有200状态码(Ok)的空响应

但在检查与Fiddler的连接后,我发现我收到了400个错误请求

如果我尝试获取请求,一切都会正常进行

UPD:我发现了问题的根源-我的base64参数(“数据”)不知怎么被更改了。我的代码生成有效的base64字符串,但在请求中添加了“0%3D%0A”,使其无法验证

我的发帖要求:

POST http://example.com HTTP/1.1
Content-Length: 143
Content-Type: application/x-www-form-urlencoded
Host: example.com
Connection: Keep-Alive
User-Agent: android-async-http/1.4.1 (http://loopj.com/android-async-http)
Accept-Encoding: gzip

hash=123&data=123
我的答复是:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at example.com Port 80</address>
</body></html>


提前感谢您的帮助

执行实际请求的代码在哪里?在哪里处理不正确?实际请求发生在RestClient。POST您是如何以纯文本打印http请求的(如您在“我的POST请求”中所述)?
public class RestClient {
     private static final String BASE_URL = "http://example.com";

      private static AsyncHttpClient client = new AsyncHttpClient();

      public static void post(RequestParams params, AsyncHttpResponseHandler responseHandler) {
          client.post(BASE_URL, params, responseHandler);

      }


}
public static void register(String login, String email, String password,
            final RegisterProcessListener listener) {

        String base64 = Cryptography
                .credentialsToBase64(login, email, password);
        String md5 = Cryptography.Base64toMD5(base64);
        RequestParams params = new RequestParams();
        params.put(DATA, base64);
        params.put(HASH, md5);

        RestClient.post(...)