MessageBody
Object Hierarchy:
Description:
A Message request or response body.
Note that while length always reflects the full length of the message body, data is normally null,
and will only be filled in after flatten is called. For client-side messages,
this automatically happens for the response body after it has been fully read, unless you set the
OVERWRITE_CHUNKS flags. Likewise, for server-side messages, the
request body is automatically filled in after being read.
As an added bonus, when data is filled in, it is always terminated with a '\0' byte (which is not reflected in length
).
Namespace: Soup
Package: libsoup-2.4
Content:
Creation methods:
Methods:
-
public void append (MemoryUse use, uint8[] data)
Appends length bytes from data to body according to use
.
-
public void append_buffer (Buffer buffer)
Appends the data from buffer to body. (#SoupMessageBody uses SoupBuffers
internally, so this is normally a constant-time operation that doesn't actually require copying the data in buffer
.)
-
public void append_take (owned uint8[] data)
Appends length bytes from data to body.
-
public void complete ()
Tags body as being complete; Call this when using chunked encoding after you have appended
the last chunk.
-
public Buffer flatten ()
Fills in body's data field with a buffer containing all of the data in body
(plus an additional '\0' byte not counted by body's length field).
-
public void free ()
Frees body. You will not normally need to use this, as
Message frees its associated message bodies automatically.
-
public bool get_accumulate ()
-
public Buffer get_chunk (int64 offset)
Gets a Buffer containing data from body
starting at offset. The size of the returned chunk is unspecified. You can iterate through the entire body by first
calling get_chunk with an offset of 0, and then on each successive call,
increment the offset by the length of the previously-returned chunk.
-
public void got_chunk (Buffer chunk)
Handles the MessageBody part of receiving a chunk of
data from the network. Normally this means appending chunk to body, exactly as with
append_buffer, but if you have set body's accumulate
flag to false, then that will not happen.
-
public void set_accumulate (bool accumulate)
Sets or clears the accumulate flag on body. (The default value is true.) If
set to false, body's data field will not be filled in after the body is fully sent/received,
and the chunks that make up body may be discarded when they are no longer needed.
-
public void truncate ()
Deletes all of the data in body.
-
public void wrote_chunk (Buffer chunk)
Handles the MessageBody part of writing a chunk of
data to the network. Normally this is a no-op, but if you have set body's accumulate flag to false, then
this will cause chunk to be discarded to free up memory.
Fields: