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

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

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

Response.setValue介绍

暂无

代码示例

代码示例来源:origin: restx/restx

@Override
public void doSetHeader(String headerName, String header) {
  response.setValue(headerName, header);
}

代码示例来源:origin: io.restx/restx-server-simple

@Override
public void doSetHeader(String headerName, String header) {
  response.setValue(headerName, header);
}

代码示例来源:origin: CodeStory/fluent-http

@Override
public void setHeader(String name, String value) {
 response.setValue(name, value);
}

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

/**
* This can be used to set a HTTP message header to this object.
* The name and value of the HTTP message header will be used to
* create a HTTP message header object which can be retrieved using
* the <code>getValue</code> in combination with the get methods.
* 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 value the value the HTTP message header will have
*/    
public void setValue(String name, String value) {
 response.setValue(name, value);
}

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

/**
* This can be used to set a HTTP message header to this object.
* The name and value of the HTTP message header will be used to
* create a HTTP message header object which can be retrieved using
* the <code>getValue</code> in combination with the get methods.
* 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 value the value the HTTP message header will have
*/    
public void setValue(String name, String value) {
 response.setValue(name, value);
}

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

/**
* This can be used to set a HTTP message header to this object.
* The name and value of the HTTP message header will be used to
* create a HTTP message header object which can be retrieved using
* the <code>getValue</code> in combination with the get methods.
* 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 value the value the HTTP message header will have
*/    
public void setValue(String name, String value) {
 response.setValue(name, value);
}

代码示例来源: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: org.simpleframework/simple-http

response.setValue(SEC_WEBSOCKET_VERSION, version);
response.setValue(SEC_WEBSOCKET_PROTOCOL, protocol);

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

response.setValue(SEC_WEBSOCKET_VERSION, version);
response.setValue(SEC_WEBSOCKET_PROTOCOL, protocol);

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

response.setValue(SEC_WEBSOCKET_VERSION, version);
 response.setValue(SEC_WEBSOCKET_PROTOCOL, protocol);
 return service;

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

response.setValue(SEC_WEBSOCKET_VERSION, version);
 response.setValue(SEC_WEBSOCKET_PROTOCOL, protocol);
 return service;

代码示例来源: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: 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: 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: ngallagher/simpleframework

response.setValue(SEC_WEBSOCKET_VERSION, version);
 response.setValue(SEC_WEBSOCKET_PROTOCOL, protocol);

代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server

public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse cResponse) throws IOException {
  int code = cResponse.getStatus();
  String text = Status.getDescription(code);
  String method = request.getMethod();
  response.setCode(code);
  response.setDescription(text);
  if (!method.equalsIgnoreCase("HEAD") && contentLength != -1 && contentLength < Integer.MAX_VALUE) {
    response.setContentLength((int) contentLength);
  }
  for (Map.Entry<String, List<Object>> e : cResponse.getHttpHeaders().entrySet()) {
    for (Object value : e.getValue()) {
      response.setValue(e.getKey(), ContainerResponse.getHeaderValue(value));
    }
  }
  return response.getOutputStream();
}

代码示例来源:origin: org.kie.remote/kie-remote-client

String address = req.getAddress().toString();
if( address.equals(REDIRECT_PATH) ) {
  resp.setValue(HttpHeaders.LOCATION, REAL_ENDPOINT_PATH);
  resp.setCode(HttpURLConnection.HTTP_MOVED_PERM);
} else if( address.equals(REDIRECT_URL) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REAL_ENDPOINT_PATH);
  resp.setCode(HttpURLConnection.HTTP_MOVED_TEMP);
} else if( address.equals(REDIRECT_DOUBLE) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REDIRECT_URL);
  resp.setCode(HttpURLConnection.HTTP_SEE_OTHER);
} else if( address.equals(REDIRECT_ENDLESS) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REDIRECT_ENDLESS);
  resp.setCode(HttpURLConnection.HTTP_SEE_OTHER);
} else if( address.equals(REDIRECT_LOOP) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REDIRECT_LOOP_2);
  resp.setCode(HttpURLConnection.HTTP_MOVED_PERM);
} else if( address.equals(REDIRECT_LOOP_2) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REDIRECT_LOOP);
  resp.setCode(HttpURLConnection.HTTP_MOVED_PERM);
} else if( address.equals(DEFAULT_ENPOINT) ) {
  resp.setValue(HttpHeaders.LOCATION, "http://localhost:" + port + REDIRECT_URL);
  resp.setCode(HttpURLConnection.HTTP_MOVED_PERM);
} else if( address.equals("/real/endpoint") ) {
  resp.setValue(HttpHeaders.CONTENT_TYPE, "text/plain");

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

long time = System.currentTimeMillis();
response.setValue("Content-Type", "text/html");
response.setValue("Server", "HttpTestServer/1.0 (Simple 4.0)");
response.setDate("Date", time);
response.setDate("Last-Modified", time);

代码示例来源: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);
    }
  }
}

相关文章