3.3 <SoupMessageBody>

Structure: <SoupMessageBody>

MessageBody represents the request or response body of a Message.

Note that while length always reflects the full length of the message body, data is normally #f, and will only be filled in after MessageBody.flatten is called. For client-side messages, this automatically happens for the response body after it has been fully read. 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).

Fields

data

the data

length

length of data

Procedures

Method: message-body:append self data
Method: append self data

Appends length bytes from data to self according to use.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

data

Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.

data to append

use

how to use data

length

Not passed: guile-gi gives the length of data.

length of data

Method: message-body:append-bytes self buffer
Method: append-bytes self buffer

Appends the data from buffer to self.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

buffer

Passed: a <GBytes>.

a <GBytes>

Method: message-body:complete self
Method: complete self

Tags self as being complete.

Call this when using chunked encoding after you have appended the last chunk.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

Method: message-body:flatten self ⇒ %return
Method: flatten self ⇒ %return

Fills in self’s data field with a buffer containing all of the data in self.

Adds an additional \0 byte not counted by self’s length field.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

%return

Returned: a <GBytes>.

a <GBytes> containing the same data as self. (You must bytes:unref this if you do not want it.)

Method: message-body:get-accumulate? self ⇒ %return
Method: get-accumulate? self ⇒ %return

Gets the accumulate flag on self.

See [method@MessageBody.set_accumulate. for details.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

%return

Returned: a boolean.

the accumulate flag for self.

Method: message-body:get-chunk self offset ⇒ %return
Method: get-chunk self offset ⇒ %return

Gets a <GBytes> containing data from self starting at offset.

The size of the returned chunk is unspecified. You can iterate through the entire body by first calling MessageBody.get_chunk with an offset of 0, and then on each successive call, increment the offset by the length of the previously-returned chunk.

If offset is greater than or equal to the total length of self, then the return value depends on whether or not MessageBody.complete has been called or not; if it has, then MessageBody.get_chunk will return a 0-length chunk (indicating the end of self). If it has not, then MessageBody.get_chunk will return #f (indicating that self may still potentially have more data, but that data is not currently available).

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

offset

Passed: a 64-bit integer.

an offset

%return

Returned: a <GBytes>, or #f.

a <GBytes>

Method: message-body:got-chunk self chunk
Method: got-chunk self chunk

Handles the MessageBody part of receiving a chunk of data from the network.

Normally this means appending chunk to self, exactly as with MessageBody.append_bytes, but if you have set self’s accumulate flag to #f, then that will not happen.

This is a low-level method which you should not normally need to use.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

chunk

Passed: a <GBytes>.

a <GBytes> received from the network

Procedure: message-body:new ⇒ %return

Creates a new MessageBody

Message uses this internally; you will not normally need to call it yourself.

%return

Returned: a <SoupMessageBody>.

a new <SoupMessageBody>.

Method: message-body:ref self ⇒ %return
Method: ref self ⇒ %return

Atomically increments the reference count of self by one.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

%return

Returned: a <SoupMessageBody>.

the passed in <SoupMessageBody>

Method: message-body:set-accumulate self accumulate
Method: set-accumulate self accumulate

Sets or clears the accumulate flag on self.

(The default value is #t.) If set to #f, self’s data field will not be filled in after the body is fully sent/received, and the chunks that make up self may be discarded when they are no longer needed.

If you set the flag to #f on the Message request_body of a client-side message, it will block the accumulation of chunks into self’s data field, but it will not normally cause the chunks to be discarded after being written like in the server-side Message response_body case, because the request body needs to be kept around in case the request needs to be sent a second time due to redirection or authentication.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

accumulate

Passed: a boolean.

whether or not to accumulate body chunks in self

Method: message-body:truncate self
Method: truncate self

Deletes all of the data in self.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

Method: message-body:unref self
Method: unref self

Atomically decrements the reference count of self by one.

When the reference count reaches zero, the resources allocated by self are freed

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

Method: message-body:wrote-chunk self chunk
Method: wrote-chunk self 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 self’s accumulate flag to #f, then this will cause chunk to be discarded to free up memory.

This is a low-level method which you should not need to use, and there are further restrictions on its proper use which are not documented here.

self

Passed: a <SoupMessageBody>.

a <SoupMessageBody>

chunk

Passed: a <GBytes>.

a <GBytes> returned from MessageBody.get_chunk