grits-http

grits-http — Hyper Text Transfer Protocol

Synopsis

                    GritsHttp;
GList *             grits_http_available                (GritsHttp *http,
                                                         gchar *filter,
                                                         gchar *cache,
                                                         gchar *extract,
                                                         gchar *index);
gchar *             grits_http_fetch                    (GritsHttp *http,
                                                         const gchar *uri,
                                                         const gchar *local,
                                                         GritsCacheType mode,
                                                         GritsChunkCallback callback,
                                                         gpointer user_data);
void                grits_http_free                     (GritsHttp *http);
GritsHttp *         grits_http_new                      (const gchar *prefix);

Description

GritsHttp is a small wrapper around libsoup to provide data access using the Hyper Text Transfer Protocol. Each GritsHttp should be associated with a particular server or dataset, all the files downloaded for this dataset will be cached together in $HOME/.cache/grits/

Details

GritsHttp

typedef struct {
	SoupSession *soup;
	gchar *prefix;
	gboolean aborted;
} GritsHttp;


grits_http_available ()

GList *             grits_http_available                (GritsHttp *http,
                                                         gchar *filter,
                                                         gchar *cache,
                                                         gchar *extract,
                                                         gchar *index);

Look through the cache and an HTTP index page for a list of available files. The name of each file that matches the filter is added to the returned list.

The list as well as the strings contained in it should be freed afterwards.

http :

the GritsHttp connection to use

filter :

filter used to extract files from the index, or NULL For example: "href=\"([^"]*)\""

cache :

path to the local cache, or NULL to not search the cache

extract :

regex used to extract filenames from the page, should match the filename as $1, or NULL to use /http="([^"])"/

index :

path to the index page, or NULL to not search online

Returns :

the list of matching filenames

grits_http_fetch ()

gchar *             grits_http_fetch                    (GritsHttp *http,
                                                         const gchar *uri,
                                                         const gchar *local,
                                                         GritsCacheType mode,
                                                         GritsChunkCallback callback,
                                                         gpointer user_data);

Fetch a file from the cache. Whether the file is actually loaded from the remote server depends on the value of mode.

http :

the GritsHttp connection to use

uri :

the URI to fetch

local :

the local name to give to the file

mode :

the update type to use when fetching data

callback :

callback to call when a chunk of data is received

user_data :

user data to pass to the callback

Returns :

The local path to the complete file

grits_http_free ()

void                grits_http_free                     (GritsHttp *http);

Frees resources used by http and cancels any pending requests.

http :

the GritsHttp to free

grits_http_new ()

GritsHttp *         grits_http_new                      (const gchar *prefix);

Create a new GritsHttp for the given prefix

prefix :

The prefix in the cache to store the downloaded files. For example: * "/nexrad/level2/".

Returns :

the new GritsHttp