Example #1
0
 // header,body 和 file
 public static Response msgBodyFile(String header, String body, String filePath) {
   Response responseMessage = new Response();
   responseMessage.setHeader(header);
   responseMessage.setBody(body);
   responseMessage.setFilePath(filePath);
   return responseMessage;
 }
Example #2
0
  public void process(Client sockector) {
    Response msg = sockector.getResponseMsgsNotCode().poll();
    while (msg != null) {
      createHeader(msg); // 创建响应头部信息
      msg.bufferedContent(); // 缓存内容
      sockector.getResponseMsgs().add(msg);

      msg = sockector.getResponseMsgsNotCode().poll();
    }
  }
Example #3
0
 // body 和 file
 public static Response msgHeaderBody(String header, String body) {
   Response responseMessage = new Response();
   responseMessage.setBody(body);
   responseMessage.setHeader(header);
   return responseMessage;
 }
Example #4
0
 // header
 public static Response msgOnlyHeader(String header) {
   Response responseMessage = new Response();
   responseMessage.setHeader(header);
   return responseMessage;
 }
Example #5
0
 // 只有file
 public static Response msgOnlyFile(String filePath) {
   Response responseMessage = new Response();
   responseMessage.setFilePath(filePath);
   return responseMessage;
 }
Example #6
0
 // 只有body
 public static Response msgOnlyBody(String body) {
   Response responseMessage = new Response();
   responseMessage.setBody(body);
   return responseMessage;
 }
Example #7
0
  /**
   *
   * <li>方法名:createHeader
   * <li>
   * <li>返回类型:void
   * <li>说明:
   * <li>创建人:陈嗣洪
   * <li>创建日期:2011-11-19
   * <li>修改人:
   * <li>修改日期:
   */
  private void createHeader(Response msg) {
    StringBuilder sb = new StringBuilder();
    sb.append("HTTP/1.0 200 OK \r\n").append("\r\n");

    msg.setHeader(sb.toString()); // 设置头部信息
  }