#!/usr/bin/env python3
#
# Retreives a file using libsoup
# Michael Gratton <mike@vee.net>
#

import sys
from gi.repository import Soup
from gi.repository import SoupGNOME

def main():
    if len(sys.argv) <= 1:
        print('Usage: {} URI'.format(sys.argv[0]), file=sys.stderr)
        sys.exit(1)

    uri = sys.argv[1]
    message = Soup.Message.new("GET", uri);

    session = Soup.SessionSync()
    session.add_feature_by_type(SoupGNOME.gnome_features_2_26_get_type())
    session.send_message(message)

    print(message.response_body.data)

if __name__ == '__main__':
    main()

