The HTTP message headers associated with a request or response.
Appends a new header with name name and value value to self.
(If there is an existing header with name name, then this creates
a second one, which is only allowed for list-valued headers; see also
MessageHeaders.replace.)
The caller is expected to make sure that name and value are syntactically correct.
Passed: a <SoupMessageHeaders>.
Passed: a string.
the header name to add
Passed: a string.
the new value of name
Removes all the headers listed in the Connection header.
Passed: a <SoupMessageHeaders>.
Clears self.
Passed: a <SoupMessageHeaders>.
Calls func once for each header value in self.
Beware that unlike MessageHeaders.get_list, this processes the
headers in exactly the way they were added, rather than concatenating
multiple same-named headers into a single value. (This is intentional;
it ensures that if you call MessageHeaders.append multiple times
with the same name, then the I/O code will output multiple copies of the
header when sending the message to the remote implementation, which may
be required for interoperability in some cases.)
You may not modify the headers from func.
Passed: a <SoupMessageHeaders>.
Passed: a procedure.
callback function to run for each header
See
SoupMessageHeadersForeachFunc
for how it is called.
Not passed: guile-gi supplies it.
data to pass to func
Looks up the "Content-Disposition" header in self, parses it, and returns its value in *disposition and *params.
params can be #f if you are only interested in the
disposition-type.
In HTTP, the most common use of this header is to set a disposition-type of "attachment", to suggest to the browser that a response should be saved to disk rather than displayed in the browser. If params contains a "filename" parameter, this is a suggestion of a filename to use. (If the parameter value in the header contains an absolute or relative path, libsoup will truncate it down to just the final path component, so you do not need to test this yourself.)
Content-Disposition is also used in "multipart/form-data", however this
is handled automatically by Multipart and the associated form
methods.
Passed: a <SoupMessageHeaders>.
Returned: a boolean.
#t if self contains a "Content-Disposition" header,
#f if not (in which case *disposition and *params
will be unchanged).
Returned: a string.
return location for the disposition-type, or #f
Returned: a hash table, each key a string and each value a string.
return location for the Content-Disposition parameters, or #f
Gets the message body length that self declare.
This will only be non-0 if MessageHeaders.get_encoding returns
content-length.
Passed: a <SoupMessageHeaders>.
Returned: a 64-bit integer.
the message body length declared by self.
Parses self’s Content-Range header and returns it in start, end, and total-length. If the total length field in the header was specified as "*", then total-length will be set to -1.
Passed: a <SoupMessageHeaders>.
Returned: a boolean.
#t if self contained a "Content-Range" header containing a
byte range which could be parsed, #f otherwise.
Returned: a 64-bit integer.
return value for the start of the range
Returned: a 64-bit integer.
return value for the end of the range
Returned: a 64-bit integer.
return value for the total length of the resource, or #f if you
don’t care.
Looks up the "Content-Type" header in self, parses it, and returns its value in *content-type and *params.
params can be #f if you are only interested in the content
type itself.
Passed: a <SoupMessageHeaders>.
Returned: a string, or #f.
a string with the value of the "Content-Type" header or #f if
self does not contain that header or it cannot be parsed (in which
case *params will be unchanged).
Returned: a hash table, each key a string and each value a string.
return location for the Content-Type parameters (eg, "charset"), or
#f
Gets the message body encoding that self declare.
This may not always correspond to the encoding used on the wire; eg, a HEAD response may declare a Content-Length or Transfer-Encoding, but it will never actually include a body.
Passed: a <SoupMessageHeaders>.
Returned: a <SoupEncoding>.
the encoding declared by self.
Gets the expectations declared by self’s "Expect" header.
Currently this will either be continue or
unrecognized.
Passed: a <SoupMessageHeaders>.
Returned: a <SoupExpectation>.
the contents of self’s "Expect" header
Gets the type of headers.
Passed: a <SoupMessageHeaders>.
Returned: a <SoupMessageHeadersType>.
the header’s type.
Gets the value of header name in self.
Use this for headers whose values are comma-delimited lists, and which
are therefore allowed to appear multiple times in the headers. For
non-list-valued headers, use MessageHeaders.get_one.
If name appears multiple times in self,
MessageHeaders.get_list will concatenate all of the values
together, separated by commas. This is sometimes awkward to parse (eg,
WWW-Authenticate, Set-Cookie), but you have to be able to deal with it
anyway, because the HTTP spec explicitly states that this transformation
is allowed, and so an upstream proxy could do the same thing.
Passed: a <SoupMessageHeaders>.
Passed: a string.
header name
Returned: a string, or #f.
the header’s value or #f if not found.
Gets the value of header name in self.
Use this for headers whose values are not comma-delimited lists,
and which therefore can only appear at most once in the headers. For
list-valued headers, use MessageHeaders.get_list.
If self does erroneously contain multiple copies of the header, it is not defined which one will be returned. (Ideally, it will return whichever one makes libsoup most compatible with other HTTP implementations.)
Passed: a <SoupMessageHeaders>.
Passed: a string.
header name
Returned: a string, or #f.
the header’s value or #f if not found.
Checks whether the list-valued header name is present in self, and contains a case-insensitive match for token.
(If name is present in self, then this is equivalent to
calling header_contains on its value.)
Passed: a <SoupMessageHeaders>.
Passed: a string.
header name
Passed: a string.
token to look for
Returned: a boolean.
#t if the header is present and contains token, #f
otherwise.
Checks whether the header name is present in self and is (case-insensitively) equal to value.
Passed: a <SoupMessageHeaders>.
Passed: a string.
header name
Passed: a string.
expected value
Returned: a boolean.
#t if the header is present and its value is value,
#f otherwise.
Creates a MessageHeaders.
(Message does this automatically for its own headers. You would
only need to use this method if you are manually parsing or generating
message headers.)
Passed: a <SoupMessageHeadersType>, or
one of its symbols.
the type of headers
Returned: a <SoupMessageHeaders>.
a new <SoupMessageHeaders>
Atomically increments the reference count of self by one.
Passed: a <SoupMessageHeaders>.
Returned: a <SoupMessageHeaders>.
the passed in <SoupMessageHeaders>
Removes name from self.
If there are multiple values for name, they are all removed.
Passed: a <SoupMessageHeaders>.
Passed: a string.
the header name to remove
Replaces the value of the header name in self with value.
See also MessageHeaders.append.
The caller is expected to make sure that name and value are syntactically correct.
Passed: a <SoupMessageHeaders>.
Passed: a string.
the header name to replace
Passed: a string.
the new value of name
Sets the "Content-Disposition" header in self to disposition, optionally with additional parameters specified in params.
See MessageHeaders.get_content_disposition for a discussion of
how Content-Disposition is used in HTTP.
Passed: a <SoupMessageHeaders>.
Passed: a string.
the disposition-type
Passed, or left out: a hash table, each key a string and each value a
string, or #f.
additional parameters
Sets the message body length that self will declare, and sets
self’s encoding to content-length.
You do not normally need to call this; if self is set to use
Content-Length encoding, libsoup will automatically set its
Content-Length header for you immediately before sending the headers.
One situation in which this method is useful is when generating the
response to a HEAD request; Calling
MessageHeaders.set_content_length allows you to put the correct
content length into the response without needing to waste memory by
filling in a response body which won’t actually be sent.
Passed: a <SoupMessageHeaders>.
Passed: a 64-bit integer.
the message body length
Sets self’s Content-Range header according to the given values.
(Note that total-length is the total length of the entire resource that this is a range of, not simply end - start + 1.)
Server has built-in handling for range requests, and you do not
normally need to call this function youself. See
MessageHeaders.get_ranges for more details.
Passed: a <SoupMessageHeaders>.
Passed: a 64-bit integer.
the start of the range
Passed: a 64-bit integer.
the end of the range
Passed: a 64-bit integer.
the total length of the resource, or -1 if unknown
Sets the "Content-Type" header in self to content-type.
Accepts additional parameters specified in params.
Passed: a <SoupMessageHeaders>.
Passed: a string.
the MIME type
Passed, or left out: a hash table, each key a string and each value a
string, or #f.
additional parameters
Sets the message body encoding that self will declare.
In particular, you should use this if you are going to send a request or response in chunked encoding.
Passed: a <SoupMessageHeaders>.
Passed: a <SoupEncoding>, or one of its symbols.
Sets self’s "Expect" header according to expectations.
Currently continue is the only known
expectation value. You should set this value on a request if you are
sending a large message body (eg, via POST or PUT), and want to give the
server a chance to reject the request after seeing just the headers (eg,
because it will require authentication before allowing you to post, or
because you’re POSTing to a URL that doesn’t exist). This saves you
from having to transmit the large request body when the server is just
going to ignore it anyway.
Passed: a <SoupMessageHeaders>.
Passed: a <SoupExpectation>, or a list of its
symbols, or one of them.
the expectations to set
Sets self’s Range header to request the indicated range.
start and end are interpreted as in a Range.
If you need to request multiple ranges, use
MessageHeaders.set_ranges.
Passed: a <SoupMessageHeaders>.
Passed: a 64-bit integer.
the start of the range to request
Passed: a 64-bit integer.
the end of the range to request
Atomically decrements the reference count of self by one.
When the reference count reaches zero, the resources allocated by self are freed
Passed: a <SoupMessageHeaders>.