123456789101112131415161718 |
- package cn.hhj.bio.tomcat.http;
- import java.io.OutputStream;
- public class Response {
- private OutputStream out;
- public Response(OutputStream out){
- this.out = out;
- }
- public void write(String s) throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("HTTP/1.1 200 OK\n") // 状态码,表示响应成功
- .append("Content-Type: text/html;\n") // 返回值类型
- .append("\r\n") // 分隔符
- .append(s); // 返回值内容
- out.write(sb.toString().getBytes());
- }
- }
|