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

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

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

Response.setDescription介绍

暂无

代码示例

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

@Override
public void failure(final Throwable error) {
  try {
    if (!response.isCommitted()) {
      response.setCode(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
      response.setDescription(error.getMessage());
    }
  } finally {
    logger.debugLog("failure(...) called");
    commit();
    rethrow(error);
  }
}

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

@Override
public OutputStream writeResponseStatusAndHeaders(final long contentLength,
                         final ContainerResponse context) throws ContainerException {
  final javax.ws.rs.core.Response.StatusType statusInfo = context.getStatusInfo();
  final int code = statusInfo.getStatusCode();
  final String reason = statusInfo.getReasonPhrase() == null
      ? Status.getDescription(code)
      : statusInfo.getReasonPhrase();
  response.setCode(code);
  response.setDescription(reason);
  if (contentLength != -1) {
    response.setContentLength(contentLength);
  }
  for (final Map.Entry<String, List<String>> e : context.getStringHeaders().entrySet()) {
    for (final String value : e.getValue()) {
      response.addValue(e.getKey(), value);
    }
  }
  try {
    return response.getOutputStream();
  } catch (final IOException ioe) {
    throw new ContainerException("Error during writing out the response headers.", ioe);
  }
}

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

/**
* This is used to set the text of the HTTP status line.
* This should match the status code specified by the RFC.
*
* @param text the descriptive text message of the status
*/ 
public void setDescription(String text) {
 response.setDescription(text);
}

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

/**
* This is used to set the text of the HTTP status line.
* This should match the status code specified by the RFC.
*
* @param text the descriptive text message of the status
*/ 
public void setDescription(String text) {
 response.setDescription(text);
}

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

/**
* This is used to set the text of the HTTP status line.
* This should match the status code specified by the RFC.
*
* @param text the descriptive text message of the status
*/ 
public void setDescription(String text) {
 response.setDescription(text);
}

代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http

@Override
public void failure(final Throwable error) {
  try {
    if (!response.isCommitted()) {
      response.setCode(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
      response.setDescription(error.getMessage());
    }
  } finally {
    logger.debugLog("failure(...) called");
    commit();
    rethrow(error);
  }
}

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

@Override
public OutputStream writeResponseStatusAndHeaders(final long contentLength,
                         final ContainerResponse context) throws ContainerException {
  final javax.ws.rs.core.Response.StatusType statusInfo = context.getStatusInfo();
  final int code = statusInfo.getStatusCode();
  final String reason = statusInfo.getReasonPhrase() == null
      ? Status.getDescription(code)
      : statusInfo.getReasonPhrase();
  response.setCode(code);
  response.setDescription(reason);
  if (contentLength != -1) {
    response.setContentLength(contentLength);
  }
  for (final Map.Entry<String, List<String>> e : context.getStringHeaders().entrySet()) {
    for (final String value : e.getValue()) {
      response.addValue(e.getKey(), value);
    }
  }
  try {
    return response.getOutputStream();
  } catch (final IOException ioe) {
    throw new ContainerException("Error during writing out the response headers.", ioe);
  }
}

相关文章