Files
flatpak/tests/httpcache.c
Owen W. Taylor 951aed561a Add flatpak_cache_http_uri: cache downloads based on HTTP headers
Add a new function, flatpak_cache_http_uri() that when passed an URL and
a local destination location, either a) downloads the content and stores
it at the destination location, storing HTTP cache header information
like Last-Modified, Etag into user xattrs (if available) or a separate
file or b) if the downloaded content is already present, checks the
header information to decide whether the downloaded content can be used
or needs to be revalidated witha conditional request.

Tests are added that use a special case test server that adds HTTP caching
headers and reacts to them based on query parameters. A small test binary
'httpcache' is added for the tests to use.

Closes: #1910
Approved by: alexlarsson
2018-08-09 12:49:35 +00:00

31 lines
595 B
C

#include "common/flatpak-utils-private.h"
int
main (int argc, char *argv[])
{
SoupSession *session = flatpak_create_soup_session (PACKAGE_STRING);
g_autoptr(GFile) dest = NULL;
GError *error = NULL;
if (argc != 3)
{
g_printerr("Usage testhttp URL DEST\n");
return 1;
}
if (!flatpak_cache_http_uri (session,
argv[1],
0,
AT_FDCWD, argv[2],
NULL, NULL, NULL, &error))
{
g_print ("%s\n", error->message);
return 1;
}
else
{
g_print ("Server returned status 200: ok\n");
return 0;
}
}