Files
flatpak/tests/httpcache.c
Owen W. Taylor c4c06b7be4 Allow using a compressed cache for HTTP downloads
Add a new flag for flatpak_cache_http_uri() that adds Accept-Encoding: gzip
to the request, and if the result is returned compressed, stores the data
compressed. If the data result is return uncompressed, it's compressed.

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

44 lines
855 B
C

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