包含文件的http帖子在站点上失败并带有密码保护

时间:2013-12-20 06:29:36

标签: android http

我的Android应用程序向我的网站发出两个HTTP POSTS,一个是带有返回值的简单POST,第二个是带有附加文件的POST。

没有密码保护,它可以正常工作。 当我在我的服务器上使用密码保护添加密码保护时(使用.htaccess编辑器),第一个POST成功,但第二个POST失败,出现clientProtocolException。 这两个调用都是在同一个客户端文件夹中的php脚本。 我正在使用com.loopj.android.http.AsyncHttpClient 这是相关的代码: 第一个电话:

PersistentCookieStore myCookieStore = new PersistentCookieStore(mContext);
mClient.setCookieStore(myCookieStore);
    mClient.setBasicAuth("userId","password");
    mClient.post(url, new AsyncHttpResponseHandler() {              
                @Override
                public void onSuccess(String response) {

第二个电话:

        RequestParams mParams = new RequestParams();            
        mParams.put("trackFile", new ByteArrayInputStream(arr));
        mParams.put("fileName",logDate ); 
        mParams.put("version", VERSION);
        String url = WEB_URL + "sendFile.php";
        AsyncHttpClient mClient = new AsyncHttpClient();
        PersistentCookieStore myCookieStore = new PersistentCookieStore(mContext);
        mClient.setCookieStore(myCookieStore);
        mClient.setBasicAuth("userId","password");
        mClient.post(url, mParams, new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(String response) {

绝对不使用密码保护,第二次呼叫返回失败

org.apache.http.client.clientProtocolException

在onFailure函数中。 我的结论是问题在于附件:

mParams.put("trackFile", new ByteArrayInputStream(arr)); 

但无法继续下去。

0 个答案:

没有答案