[英]sending httpResponse using printWriter
I am trying to send an httpresponse using the printWriter, but all i get in the result is the status line without the entity. 我正在尝试使用printWriter发送一个httpresponse,但是我得到的结果是没有该实体的状态行。 How can I send the whole response?
如何发送整个回复?
OutputStream out = socket.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));
writer.println(httpResponse.getStatusLine());
writer.println(httpResponse.getAllHeaders());
writer.println(httpResponse.getEntity());
writer.flush();
writer.close();
socket.close();
对我来说,答案是在响应的实体行开始处用新的空行逐行打印响应的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.