diff options
author | Gustavo Noronha Silva <gns@gnome.org> | 2009-06-17 20:53:17 -0300 |
---|---|---|
committer | Gustavo Noronha Silva <gns@gnome.org> | 2009-07-02 11:03:11 -0300 |
commit | 3c9f3cdffc32126700f25d8a0c55f68b6f587bde (patch) | |
tree | f76973c1af6d10b0e967a2424cd5dc047c01156f /libsoup/soup-content-sniffer.h | |
parent | ead8e2f2ab8f2fb38a288e12e5f2d9b88c429cc4 (diff) | |
download | libsoup-3c9f3cdffc32126700f25d8a0c55f68b6f587bde.tar.gz |
Implement content sniffing
The implementation is based on the draft spec on Content-Type
Processing Model (draft-abarth-mime-sniff-01). It is a spinoff from
the HTML5 spec.
Soup now provides a SoupContentSniffer session feature, which hooks
into the message I/O, and delays emissions of the got-chunk signal to
be able to figure out the Content-Type of messages from the actual
content received, in some cases.
GIO is also used to sniff content, whenever the spec allows further
sniffing.
http://bugzilla.gnome.org/show_bug.cgi?id=572589
Diffstat (limited to 'libsoup/soup-content-sniffer.h')
-rw-r--r-- | libsoup/soup-content-sniffer.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libsoup/soup-content-sniffer.h b/libsoup/soup-content-sniffer.h new file mode 100644 index 00000000..a8aa9156 --- /dev/null +++ b/libsoup/soup-content-sniffer.h @@ -0,0 +1,57 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2009 Gustavo Noronha Silva. + */ + +#ifndef SOUP_CONTENT_SNIFFER_H +#define SOUP_CONTENT_SNIFFER_H 1 + +#include <libsoup/soup-types.h> +#include <libsoup/soup-message-body.h> + +G_BEGIN_DECLS + +#define SOUP_TYPE_CONTENT_SNIFFER (soup_content_sniffer_get_type ()) +#define SOUP_CONTENT_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CONTENT_SNIFFER, SoupContentSniffer)) +#define SOUP_CONTENT_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CONTENT_SNIFFER, SoupContentSnifferClass)) +#define SOUP_IS_CONTENT_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CONTENT_SNIFFER)) +#define SOUP_IS_CONTENT_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CONTENT_SNIFFER)) +#define SOUP_CONTENT_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CONTENT_SNIFFER, SoupContentSnifferClass)) + +typedef struct _SoupContentSnifferPrivate SoupContentSnifferPrivate; + +typedef struct { + GObject parent; + + SoupContentSnifferPrivate *priv; +} SoupContentSniffer; + +typedef struct { + GObjectClass parent_class; + + char* (*sniff) (SoupContentSniffer *sniffer, + SoupMessage *msg, + SoupBuffer *buffer, + GHashTable **params); + gsize (*get_buffer_size) (SoupContentSniffer *sniffer); + + /* Padding for future expansion */ + void (*_libsoup_reserved1) (void); + void (*_libsoup_reserved2) (void); + void (*_libsoup_reserved3) (void); + void (*_libsoup_reserved4) (void); + void (*_libsoup_reserved5) (void); +} SoupContentSnifferClass; + +GType soup_content_sniffer_get_type (void); + +SoupContentSniffer *soup_content_sniffer_new (void); + +char *soup_content_sniffer_sniff (SoupContentSniffer *sniffer, + SoupMessage *msg, + SoupBuffer *buffer, + GHashTable **params); + +G_END_DECLS + +#endif /* SOUP_CONTENT_SNIFFER_H */ |