Call the as_string() method for the headers in the
message. This will be the same as
$mess->headers->as_string
but it will make your program a whole character shorter :-)
=item $mess->content
=item $mess->content( $bytes )
The content() method sets the raw content if an argument is given. If no
argument is given the content is not touched. In either case the
original raw content is returned.
Note that the content should be a string of bytes. Strings in perl
can contain characters outside the range of a byte. The C<Encode>
module can be used to turn such strings into a string of bytes.
=item $mess->add_content( $bytes )
The add_content() methods appends more data bytes to the end of the
current content buffer.
=item $mess->add_content_utf8( $string )
The add_content_utf8() method appends the UTF-8 bytes representing the
string to the end of the current content buffer.
=item $mess->content_ref
=item $mess->content_ref( \$bytes )
The content_ref() method will return a reference to content buffer string.
It can be more efficient to access the content this way if the content
is huge, and it can even be used for direct manipulation of the content,
for instance:
${$res->content_ref} =~ s/\bfoo\b/bar/g;
This example would modify the content buffer in-place.
If an argument is passed it will setup the content to reference some
external source. The content() and add_content() methods
will automatically dereference scalar references passed this way. For
other references content() will return the reference itself and
add_content() will refuse to do anything.
=item $mess->decoded_content( %options )
Returns the content with any C<Content-Encoding> undone and the raw
content encoded to perl's Unicode strings. If the C<Content-Encoding>
or C<charset> of the message is unknown this method will fail by
returning C<undef>.
The following options can be specified.
=over
=item C<charset>
This override the charset parameter for text content. The value
C<none> can used to suppress decoding of the charset.
=item C<default_charset>
This override the default charset of "ISO-8859-1".
=item C<charset_strict>
Abort decoding if malformed characters is found in the content. By
default you get the substitution character ("\x{FFFD}") in place of
malformed characters.
=item C<raise_error>
If TRUE then raise an exception if not able to decode content. Reason
might be that the specified C<Content-Encoding> or C<charset> is not
supported. If this option is FALSE, then decoded_content() will return
C<undef> on errors, but will still set $@.
=item C<ref>
If TRUE then a reference to decoded content is returned. This might
be more efficient in cases where the decoded content is identical to
the raw content as no data copying is required in this case.
=back
=item $mess->decodeable
=item HTTP::Message::decodeable()
This returns the encoding identifiers that decoded_content() can
process. In scalar context returns a comma separated string of
identifiers.
This value is suitable for initializing the C<Accept-Encoding> request
header field.
=8= |