✖ #include <libsoup/soup.h>

  int main(void) {
          GMainLoop *loop = g_main_loop_new(NULL, FALSE);

          SoupSession *session = soup_session_new();
          SoupMessage *msg = NULL;

          SoupCache *diskcache = soup_cache_new("/tmp/soup-cache", SOUP_CACHE_SINGLE_USER);
          soup_cache_set_max_size(diskcache, 50000000);
          soup_cache_load(diskcache);
          soup_session_add_feature(session, SOUP_SESSION_FEATURE(diskcache));

          SoupLogger *logger = soup_logger_new(SOUP_LOGGER_LOG_HEADERS, 0);
          soup_session_add_feature(session, SOUP_SESSION_FEATURE(logger));

          msg = soup_message_new("GET", "http://techslides.com/demos/sample-videos/small.webm");

          GInputStream *stream;
          GError *error = NULL;
          stream = soup_session_send (session, msg, NULL, &error);

          void *c = g_malloc(100000);
          while (TRUE) {
              ssize_t ret = g_input_stream_read(stream, c, 100000, NULL, &error);
              if (ret == 0 || ret == -1) {
                  g_printerr ("g_input_stream_read: EOF\n");
                  break;
              } else if (error != NULL) {
                  g_printerr ("g_input_stream_read failed: %s\n", error->message);
                  break;
              }
              g_print ("read: %d\n", ret);
          }

          soup_cache_flush(diskcache);
          soup_cache_dump(diskcache);

          g_object_unref(stream);
          g_free(c);
          g_main_loop_unref(loop);
  }