如何在HttpResponse类型中设置内容?

时间:2011-04-26 15:02:30

标签: java http response httpresponse

我的目标是从旧版本中构建一个新的HttpResponse。 我的尝试是这样的:

String headers = dbh.getResponseHeaders(url);
InputStream content = dbh.getResponseContent(url);
final HttpResponse cachedResponseToReturn = response;
cachedResponseToReturn.setHeaders(null);
final StringEntity sEntity = new StringEntity(content.toString());   ////these lines
cachedResponseToReturn.setEntity(sEntity);  ////these lines
final LinkedList<String[]> headersList = divideStringToAllTheHeaders(headers);
for (int i = 0; i < headersList.size(); ++i)
   cachedResponseToReturn.addHeader(headersList.get(i)[0], headersList.get(i)[1]);

顺便说一下,'response'变量是一个HttpResponse来初始化新的响应。我只用它来初始化。 换句话说,如何设置我拥有的HttpResponse类型的内容?

tnx,Itamar。

0 个答案:

没有答案