开发者

How to set the content in an HttpResponse type?

开发者 https://www.devze.com 2023-02-28 15:48 出处:网络
My goal is to build a new HttpResponse out of an old one. My attempt is this: String headers = dbh.getResponseHeaders(url);

My goal is to build a new HttpResponse out of an old one. My attempt is this:

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[]> h开发者_高级运维eadersList = divideStringToAllTheHeaders(headers);
for (int i = 0; i < headersList.size(); ++i)
   cachedResponseToReturn.addHeader(headersList.get(i)[0], headersList.get(i)[1]);

By the way, the 'response' variable is an HttpResponse to initialize the new response. I only use it to initialization. In other words, how do I set the content of the HttpResponse type that I have?

tnx, Itamar.

0

精彩评论

暂无评论...
验证码 换一张
取 消