Implement new_chunked_reader
TODO: Implement chunked_read too
This commit is contained in:
parent
e7f4a73aab
commit
047472da93
|
@ -15,8 +15,6 @@ use types;
|
||||||
// and encode the message body appropriately.
|
// and encode the message body appropriately.
|
||||||
//
|
//
|
||||||
// Most users will want this to be set to auto.
|
// Most users will want this to be set to auto.
|
||||||
//
|
|
||||||
// TODO: Document server behavior
|
|
||||||
export type transport_mode = enum {
|
export type transport_mode = enum {
|
||||||
AUTO = 0,
|
AUTO = 0,
|
||||||
NONE,
|
NONE,
|
||||||
|
@ -31,8 +29,6 @@ export type transport_mode = enum {
|
||||||
// the message body appropriately.
|
// the message body appropriately.
|
||||||
//
|
//
|
||||||
// Most users will want this to be set to AUTO.
|
// Most users will want this to be set to AUTO.
|
||||||
//
|
|
||||||
// TODO: Document server behavior
|
|
||||||
export type content_mode = enum {
|
export type content_mode = enum {
|
||||||
AUTO = 0,
|
AUTO = 0,
|
||||||
NONE,
|
NONE,
|
||||||
|
@ -185,14 +181,24 @@ type chunked_reader = struct {
|
||||||
vtable: io::stream,
|
vtable: io::stream,
|
||||||
conn: io::handle,
|
conn: io::handle,
|
||||||
buffer: [os::BUFSIZ]u8,
|
buffer: [os::BUFSIZ]u8,
|
||||||
|
// Amount of read-ahead data in buffer
|
||||||
pending: size,
|
pending: size,
|
||||||
|
// Length of current chunk, or zero
|
||||||
|
length: size,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn new_chunked_reader(
|
fn new_chunked_reader(
|
||||||
conn: io::handle,
|
conn: io::handle,
|
||||||
buffer: []u8,
|
buffer: []u8,
|
||||||
) *io::stream = {
|
) *io::stream = {
|
||||||
abort(); // TODO
|
let rd = alloc(chunked_reader {
|
||||||
|
vtable = &chunked_reader_vtable,
|
||||||
|
conn = conn,
|
||||||
|
...
|
||||||
|
});
|
||||||
|
rd.buffer[..len(buffer)] = buffer[..];
|
||||||
|
rd.pending = len(buffer);
|
||||||
|
return rd;
|
||||||
};
|
};
|
||||||
|
|
||||||
const chunked_reader_vtable = io::vtable {
|
const chunked_reader_vtable = io::vtable {
|
||||||
|
|
Loading…
Reference in a new issue