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

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

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

Request.getByteChannel介绍

[英]This is used to read the content body. The specifics of the data that is read from this ReadableByteChannel can be determined by the getContentLength method. If the data sent by the client is chunked then it is decoded, see RFC 2616 section 3.6. This stream will never provide empty reads as the content is internally buffered, so this can do a full read.
[中]这用于阅读内容正文。从ReadableByteChannel读取的数据的细节可以通过getContentLength方法确定。如果对客户端发送的数据进行分块,则对其进行解码,请参阅RFC 2616第3.6节。这个流永远不会提供空读,因为内容是内部缓冲的,所以它可以进行完全读取。

代码示例

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

/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>ReadableByteChannel</code> can be 
* determined by the <code>getContentLength</code> method. If the 
* data sent by the client is chunked then it is decoded, see RFC 
* 2616 section 3.6. This stream will never provide empty reads as
* the content is internally buffered, so this can do a full read.
* 
* @return this returns the byte channel used to read the content
*/
public ReadableByteChannel getByteChannel() throws IOException {
 return request.getByteChannel();
}

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

/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>ReadableByteChannel</code> can be 
* determined by the <code>getContentLength</code> method. If the 
* data sent by the client is chunked then it is decoded, see RFC 
* 2616 section 3.6. This stream will never provide empty reads as
* the content is internally buffered, so this can do a full read.
* 
* @return this returns the byte channel used to read the content
*/
public ReadableByteChannel getByteChannel() throws IOException {
 return request.getByteChannel();
}

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

/**
* This is used to read the content body. The specifics of the data
* that is read from this <code>ReadableByteChannel</code> can be 
* determined by the <code>getContentLength</code> method. If the 
* data sent by the client is chunked then it is decoded, see RFC 
* 2616 section 3.6. This stream will never provide empty reads as
* the content is internally buffered, so this can do a full read.
* 
* @return this returns the byte channel used to read the content
*/
public ReadableByteChannel getByteChannel() throws IOException {
 return request.getByteChannel();
}

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

void handlePut(Request req, Response rsp, String[] path) {
  long fh = Long.parseLong(path[1]);
  long start = Long.parseLong(path[2]);
  int len = Integer.parseInt(path[3]);
  try {
    ByteBuffer buf = ByteBuffer.allocate(len);
    req.getByteChannel().read(buf);
    if (buf.position() != len) {
      SDFSLogger.getLog().warn("length is " + len + " buffer size " + buf.position());
      throw new FuseException().initErrno(Errno.EIO);
    }
    buf.position(0);
    this.write(fh, buf, start);
    rsp.setCode(200);
    rsp.close();
  } catch (FuseException e) {
    SDFSLogger.getLog().error("error during write", e);
    this.printError(req, rsp, e.getErrno(), e);
  } catch (Exception e) {
    SDFSLogger.getLog().error("error during write", e);
    this.printError(req, rsp, -1, e);
  }
}

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

int len = request.getByteChannel().read(buf);
int count = numRequests.incrementAndGet();

相关文章