Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
Because a serialized header is not length-prefixed, algorithms which parse messages from a stream may read past the end of a message for efficiency. To hold this surplus data, all stream read operations use a passed-in __DynamicBuffer__ which must be persisted between calls until the end of stream is reached or the stream object is destroyed. Each read operation may consume bytes remaining in the buffer, and leave behind new bytes. In this example we declare the buffer and a message variable, then read a complete HTTP request synchronously:由于序列化后的头部没有长度前缀,从流中解析消息的算法为了提高效率,可能会读取超过消息末尾的数据。为了保存这些多余的数据,所有流读操作都依赖一个传入的 __DynamicBuffer__,该缓冲区在两次调用之间必须保持有效,直到流结束或流对象销毁为止。每次读操作可能会消耗缓冲区中已有的字节,也可能留下新读入的字节。以下示例声明一个缓冲区和一个消息变量,然后同步读取一个完整的 HTTP 请求: