0

你能帮我解决这个问题吗:

对于 http 响应,我得到 200(成功)而不是 302(重定向),我得到 2 而不是 3 cookie 标头作为响应。如何允许重定向?任何输入都会很好。

我的代码是:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try {
    httppost.setParams(new BasicHttpParams().setParameter("A", "B"));
    httppost.setParams(new BasicHttpParams().setParameter("C", "D"));
    httppost.setParams(new BasicHttpParams().setParameter("E", "F"));
    httppost.setParams(new BasicHttpParams().setParameter("G", "H"));
    httppost.setParams(new BasicHttpParams().setParameter("I", "J"));
    httppost.setParams(new BasicHttpParams().setParameter("K", "L"));
    httppost.setParams(new BasicHttpParams().setParameter("M", bundle.getString("responsedata")));

    UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
    httppost.setEntity(formEntity);
    HttpResponse sessionresp = httpclient.execute(httppost);

    Header[] headers = sessionresp.getAllHeaders();
    for (int i=0; i < headers.length; i++) {
        Header h = headers[i];
        Log.i(TAG, "Header names: "+h.getName());
        Log.i(TAG, "Header Value: "+h.getValue());
    }
    Log.i("sucess: ", sessionresp.getStatusLine().getStatusCode()+"");
4

0 回答 0