org.apache.coyote.Response.getBytesWritten()方法的使用及代码示例

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

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

Response.getBytesWritten介绍

[英]Bytes written to socket - i.e. after compression, chunking, etc.
[中]写入套接字的字节-即在压缩、分块等之后。

代码示例

代码示例来源:origin: line/armeria

private static HttpHeaders convertResponse(Response coyoteRes) {
  final HttpHeaders headers = HttpHeaders.of(HttpStatus.valueOf(coyoteRes.getStatus()));
  final String contentType = coyoteRes.getContentType();
  if (contentType != null && !contentType.isEmpty()) {
    headers.set(HttpHeaderNames.CONTENT_TYPE, contentType);
  }
  final long contentLength = coyoteRes.getBytesWritten(true); // 'true' will trigger flush.
  final String method = coyoteRes.getRequest().method().toString();
  if (!"HEAD".equals(method)) {
    headers.setLong(HttpHeaderNames.CONTENT_LENGTH, contentLength);
  }
  final MimeHeaders cHeaders = coyoteRes.getMimeHeaders();
  final int numHeaders = cHeaders.size();
  for (int i = 0; i < numHeaders; i++) {
    final AsciiString name = toHeaderName(cHeaders.getName(i));
    if (name == null) {
      continue;
    }
    final String value = toHeaderValue(cHeaders.getValue(i));
    if (value == null) {
      continue;
    }
    headers.add(name.toLowerCase(), value);
  }
  return headers;
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource

public long getRequestBytesSent() {
  return req.getResponse().getBytesWritten();
}

代码示例来源:origin: org.jboss.web/jbossweb

public long getRequestBytesSent() {
  return req.getResponse().getBytesWritten();
}

代码示例来源:origin: jboss.web/jbossweb

public long getRequestBytesSent() {
  return req.getResponse().getBytesWritten();
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return coyoteResponse.getBytesWritten(flush);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * @return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 * @param flush if <code>true</code> will perform a buffer flush first
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return getCoyoteResponse().getBytesWritten(flush);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * @return the number of bytes the actually written to the socket. This
 * includes chunking, compression, etc. but excludes headers.
 * @param flush if <code>true</code> will perform a buffer flush first
 */
public long getBytesWritten(boolean flush) {
  if (flush) {
    try {
      outputBuffer.flush();
    } catch (IOException ioe) {
      // Ignore - the client has probably closed the connection
    }
  }
  return getCoyoteResponse().getBytesWritten(flush);
}

代码示例来源:origin: jboss.web/jbossweb

/** Called by the processor before recycling the request. It'll collect
 * statistic information.
 */
void updateCounters() {
  bytesReceived+=req.getBytesRead();
  bytesSent+=req.getResponse().getBytesWritten();
  requestCount++;
  if( req.getResponse().getStatus() >=400 )
    errorCount++;
  long t0=req.getStartTime();
  long t1=System.currentTimeMillis();
  long time=t1-t0;
  this.lastRequestProcessingTime = time;
  processingTime+=time;
  if( maxTime < time ) {
    maxTime=time;
    maxRequestUri=req.requestURI().toString();
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

/** Called by the processor before recycling the request. It'll collect
 * statistic information.
 */
void updateCounters() {
  bytesReceived+=req.getBytesRead();
  bytesSent+=req.getResponse().getBytesWritten();
  requestCount++;
  if( req.getResponse().getStatus() >=400 )
    errorCount++;
  long t0=req.getStartTime();
  long t1=System.currentTimeMillis();
  long time=t1-t0;
  this.lastRequestProcessingTime = time;
  processingTime+=time;
  if( maxTime < time ) {
    maxTime=time;
    maxRequestUri=req.requestURI().toString();
  }
}

代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource

/** Called by the processor before recycling the request. It'll collect
 * statistic information.
 */
void updateCounters() {
  bytesReceived+=req.getBytesRead();
  bytesSent+=req.getResponse().getBytesWritten();
  requestCount++;
  if( req.getResponse().getStatus() >=400 )
    errorCount++;
  long t0=req.getStartTime();
  long t1=System.currentTimeMillis();
  long time=t1-t0;
  this.lastRequestProcessingTime = time;
  processingTime+=time;
  if( maxTime < time ) {
    maxTime=time;
    maxRequestUri=req.requestURI().toString();
  }
}

相关文章

微信公众号

最新文章

更多