我正在尝试使用标头从 Java Web 应用程序向 Android 发送响应。我无法读取标题值。
我将标题传递为:
response.setHeader("response", "ok");
response.setHeader("url", androidResponseBean.getUrl());
我尝试使用:
Header[] header = (Header[]) httpResponse.getAllHeaders();
我无法迭代以检索标头值。
这是我向 Web 应用程序发送请求的代码:
DefaultHttpClient httpClient = new DefaultHttpClient();
//HttpGet httpGet = new HttpGet(params[0]);
HttpPost httpPost = new HttpPost(params[2]);
ArrayList<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("ssn", params[0]));
nameValuePair.add(new BasicNameValuePair("dob",params[1]));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair, "UTF-8"));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);