diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-05-24 15:05:10 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-05-24 17:48:22 -0400 |
commit | 4ed116eee2949e134d7312acfcc57f9672ff18ca (patch) | |
tree | 8b1cfddf2e3f1033ac62847a84075231f8f76147 | |
parent | 3ae3e642ece7899e59706722446766e4441462a2 (diff) | |
download | libsoup-4ed116eee2949e134d7312acfcc57f9672ff18ca.tar.gz libsoup-4ed116eee2949e134d7312acfcc57f9672ff18ca.tar.bz2 libsoup-4ed116eee2949e134d7312acfcc57f9672ff18ca.zip |
soup-message-body: Add a soup_buffer_get_as_bytes method
This new method will return a GBytes instance containing the
contents of the SoupBuffer.
https://bugzilla.gnome.org/show_bug.cgi?id=676776
-rw-r--r-- | docs/reference/libsoup-2.4-sections.txt | 1 | ||||
-rw-r--r-- | libsoup/soup-message-body.c | 18 | ||||
-rw-r--r-- | libsoup/soup-message-body.h | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt index 8731edd9..87633c77 100644 --- a/docs/reference/libsoup-2.4-sections.txt +++ b/docs/reference/libsoup-2.4-sections.txt @@ -159,6 +159,7 @@ soup_buffer_get_owner soup_buffer_get_data soup_buffer_copy soup_buffer_free +soup_buffer_get_as_bytes <SUBSECTION> SoupMessageBody soup_message_body_new diff --git a/libsoup/soup-message-body.c b/libsoup/soup-message-body.c index daf9d1ec..899c04a4 100644 --- a/libsoup/soup-message-body.c +++ b/libsoup/soup-message-body.c @@ -308,6 +308,24 @@ soup_buffer_free (SoupBuffer *buffer) } } +/** + * soup_buffer_get_as_bytes: + * @buffer: a #SoupBuffer + * + * Returns: (transfer full): a new #GBytes which has the same content + * as the #SoupBuffer. + * + * Since: 2.40 + */ +GBytes * +soup_buffer_get_as_bytes (SoupBuffer *buffer) +{ + SoupBuffer *copy; + + copy = soup_buffer_copy (buffer); + return g_bytes_new_with_free_func (copy->data, copy->length, soup_buffer_free, copy); +} + GType soup_buffer_get_type (void) { diff --git a/libsoup/soup-message-body.h b/libsoup/soup-message-body.h index 4edaaf0f..ee840837 100644 --- a/libsoup/soup-message-body.h +++ b/libsoup/soup-message-body.h @@ -44,6 +44,7 @@ void soup_buffer_get_data (SoupBuffer *buffer, gsize *length); SoupBuffer *soup_buffer_copy (SoupBuffer *buffer); void soup_buffer_free (SoupBuffer *buffer); +GBytes *soup_buffer_get_as_bytes (SoupBuffer *buffer); typedef struct { const char *data; |