org.simpleframework.http.Response.setDate()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.simpleframework.http.Response.setDate方法的一些代码示例,展示了Response.setDate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setDate方法的具体详情如下:
包路径:org.simpleframework.http.Response
类名称:Response
方法名:setDate

Response.setDate介绍

暂无

代码示例

代码示例来源:origin: mpetazzoni/ttorrent

response.setDate("Date", System.currentTimeMillis());

代码示例来源:origin: ngallagher/simpleframework

/**
* This is used as a convenience method for adding a header that
* needs to be parsed into a HTTP date string. This will convert
* the date given into a date string defined in RFC 2616 sec 3.3.1.
* This will perform a <code>remove</code> using the issued header
* name before the header value is set.       
*
* @param name the name of the HTTP message header to be added
* @param date the value constructed as an RFC 1123 date string
*/ 
public void setDate(String name, long date) {
 response.setDate(name, date);
}

代码示例来源:origin: org.simpleframework/simple

/**
* This is used as a convenience method for adding a header that
* needs to be parsed into a HTTP date string. This will convert
* the date given into a date string defined in RFC 2616 sec 3.3.1.
* This will perform a <code>remove</code> using the issued header
* name before the header value is set.       
*
* @param name the name of the HTTP message header to be added
* @param date the value constructed as an RFC 1123 date string
*/ 
public void setDate(String name, long date) {
 response.setDate(name, date);
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* This is used as a convenience method for adding a header that
* needs to be parsed into a HTTP date string. This will convert
* the date given into a date string defined in RFC 2616 sec 3.3.1.
* This will perform a <code>remove</code> using the issued header
* name before the header value is set.       
*
* @param name the name of the HTTP message header to be added
* @param date the value constructed as an RFC 1123 date string
*/ 
public void setDate(String name, long date) {
 response.setDate(name, date);
}

代码示例来源:origin: lantunes/fixd

protected void addStandardHeaders(Response response, String responseContentType) {
    
    long time = System.currentTimeMillis();
    response.setValue("Content-Type", responseContentType);
    response.setValue("Server", "Fixd/1.0 (Simple 5.1.4)");
    response.setDate("Date", time);
    response.setDate("Last-Modified", time);
  }
}

代码示例来源:origin: openpreserve/pagelyzer

response.setDate("Date", time);
response.setDate("Last-Modified", time);
String filename= config.getString("pagelyzer.run.default.comparison.path").replace("/ext", "/js") +path.getPath();

代码示例来源:origin: ngallagher/simpleframework

/**
* This is used to respond to the client with a HTTP 400 response
* indicating the WebSocket handshake failed. No response body is
* sent with the rejection message and the underlying TCP channel
* is closed to prevent further use of the connection.
*/
private void reject() throws IOException {
 long time = System.currentTimeMillis();
 
 response.setStatus(Status.BAD_REQUEST);
 response.setValue(CONNECTION, CLOSE);
 response.setDate(DATE, time);
     
 String header = response.toString();         
 byte[] message = header.getBytes("UTF-8");
 
 trace.trace(WRITE_HEADER, header);
 writer.write(message);
 writer.flush();
 writer.close();
}

代码示例来源:origin: org.simpleframework/simple-http

/**
* This is used to respond to the client with a HTTP 400 response
* indicating the WebSocket handshake failed. No response body is
* sent with the rejection message and the underlying TCP channel
* is closed to prevent further use of the connection.
*/
private void reject() throws IOException {
 long time = System.currentTimeMillis();
 
 response.setStatus(Status.BAD_REQUEST);
 response.setValue(CONNECTION, CLOSE);
 response.setDate(DATE, time);
     
 String header = response.toString();         
 byte[] message = header.getBytes("UTF-8");
 
 trace.trace(WRITE_HEADER, header);
 writer.write(message);
 writer.flush();
 writer.close();
}

代码示例来源:origin: zanata/zanata-platform

@Override
  public void handle(Request request, Response response) {
    try {
      PrintStream body = response.getPrintStream();
      long time = System.currentTimeMillis();

      response.setStatus(status);
      response.setContentType("text/plain");
      response.setDate("Date", time);
      response.setDate("Last-Modified", time);

      log.info("mock container returning: status [{}], content [{}]",
        status, responseContent);

      body.println(responseContent);
      body.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: opendedup/sdfs

rsp.setContentType("application/octet-stream");
rsp.addValue("Server", "SDFS Management Server");
rsp.setDate("Date", time);
rsp.setDate("Last-Modified", time);
rsp.setContentLength(k.length);
OutputStream out = rsp.getOutputStream();

代码示例来源:origin: ngallagher/simpleframework

/**
  * This is used to respond to the client with a HTTP 101 response
  * to indicate that the WebSocket handshake succeeeded. Once this
  * response has been sent all traffic between the client and 
  * server will be with WebSocket frames as defined by RFC 6455. 
  */
  private void accept() throws IOException {
   long time = System.currentTimeMillis();
   String accept = token.create();
   
   response.setStatus(Status.SWITCHING_PROTOCOLS);
   response.setDescription(UPGRADE);
   response.setValue(CONNECTION, UPGRADE);
   response.setDate(DATE, time);
   response.setValue(SEC_WEBSOCKET_ACCEPT, accept);
   response.setValue(UPGRADE, WEBSOCKET); 
       
   String header = response.toString();         
   byte[] message = header.getBytes("UTF-8");
   
   trace.trace(WRITE_HEADER, header);
   writer.write(message);
   writer.flush();      
  }
}

代码示例来源:origin: qos-ch/logback-extensions

response.setDate("Date", time);
response.setDate("Last-Modified", time);

代码示例来源:origin: org.simpleframework/simple-http

/**
  * This is used to respond to the client with a HTTP 101 response
  * to indicate that the WebSocket handshake succeeeded. Once this
  * response has been sent all traffic between the client and 
  * server will be with WebSocket frames as defined by RFC 6455. 
  */
  private void accept() throws IOException {
   long time = System.currentTimeMillis();
   String accept = token.create();
   
   response.setStatus(Status.SWITCHING_PROTOCOLS);
   response.setDescription(UPGRADE);
   response.setValue(CONNECTION, UPGRADE);
   response.setDate(DATE, time);
   response.setValue(SEC_WEBSOCKET_ACCEPT, accept);
   response.setValue(UPGRADE, WEBSOCKET); 
       
   String header = response.toString();         
   byte[] message = header.getBytes("UTF-8");
   
   trace.trace(WRITE_HEADER, header);
   writer.write(message);
   writer.flush();      
  }
}

代码示例来源:origin: opendedup/sdfs

response.setContentType("application/octet-stream");
    response.setValue("Server", "SDFS Management Server");
    response.setDate("Date", time);
    response.setDate("Last-Modified", time);
    response.getOutputStream().write(rslt);
    response.getOutputStream().flush();
} else if (request.getTarget().startsWith(METADATA_PATH)) {
  long time = System.currentTimeMillis();
  response.setDate("Date", time);
  response.setDate("Last-Modified", time);
  String path = Main.volume.getPath() + File.separator
      + request.getTarget().substring(METADATA_PATH.length());
    response.setContentType("application/json");
    response.setValue("Server", "SDFS Management Server");
    response.setDate("Date", time);
    response.setDate("Last-Modified", time);
    PrintStream body = response.getPrintStream();
    body.println(GetJSONAttributes.getResult(path,uuid,num));
  response.setDate("Date", time);
  response.setDate("Last-Modified", time);
  response.setContentType("application/octet-stream");
  response.setValue("Server", "SDFS Management Server");
  response.setDate("Date", time);
  response.setDate("Last-Modified", time);
  response.setContentLength(data.length);

代码示例来源:origin: zanata/zanata-platform

@Override
public void handle(Request request, Response response) {
  try {
    PrintStream body = response.getPrintStream();
    long time = System.currentTimeMillis();
    response.setValue("Content-Type", "text/plain");
    response.setContentType("application/xml;charset=utf-8");
    response.setDate("Date", time);
    response.setDate("Last-Modified", time);
    String path = request.getAddress().getPath().getPath();
    log.trace("request path is {}", path);
    StatusAndContent statusAndContent = tryMatchPath(path);
    Status status = statusAndContent.status;
    response.setStatus(status);
    String content = statusAndContent.content;
    log.trace("mock container returning: status [{}], content [{}]",
        status, content);
    body.println(content);
    body.close();
  } catch (Exception e) {
    e.printStackTrace();
    response.setStatus(Status.INTERNAL_SERVER_ERROR);
    try {
      response.close();
    } catch (IOException e1) {
      throw new RuntimeException(e1);
    }
  }
}

相关文章