def test_soup(self): for url in self.GOOD: session = Soup.Session() request = session.request_http("get", url) request.send(None).close() for url in self.BAD: with self.assertRaises(GLib.GError): session = Soup.Session() request = session.request_http("get", url) request.send(None).close()
def _send(self, data): uri = Soup.URI.new(self._url) message = Soup.Message(method='POST', uri=uri) message.request_headers.append('x-api-key', self._api_key) message.set_request(self.TYPE, Soup.MemoryUse.COPY, data, len(data)) message.connect('network-event', self.__network_event_cb) message.connect('wrote-body-data', self.__wrote_body_data_cb) message.connect('finished', self.__finished_cb) session = Soup.SessionSync() session.add_feature_by_type(Soup.ProxyResolverDefault) session.send_message(message)
def create_companion_app_webserver(application, cache, content_db_conn, middlewares=None): '''Create a HTTP server with companion app routes.''' def _on_request_aborted(server, msg, *args): '''Signal handler for when a request is aborted. We'll look at the msg here and if there is an attached cancellable put there by cancellability_middleware then we can cancel it now. ''' del server del args cancellable = getattr(msg, 'cancellable', None) if cancellable is None: logging.debug('Message aborted without a cancellable') return cancellable.cancel() server = Soup.Server() for path, handler in create_companion_app_routes(content_db_conn).items(): server.add_handler( path, compose_middlewares(cache_middleware(cache), cancellability_middleware, handle_404_middleware(path), application_hold_middleware(application), *(middlewares or []), handler)) server.connect('request-aborted', _on_request_aborted) return server
def __playing_now(self, track): """ Now playing track @param track as Track """ try: token = App().ws_director.token_ws.get_token( self.__name, self.__cancellable) if token is None: return args = self.__get_args_for_method("track.updateNowPlaying") args.append(("artist", track.artists[0])) args.append(("track", track.name)) args.append(("album", track.album.name)) if track.mbid and track.mbid.find(":") == -1: args.append(("mbid", track.mbid)) args.append(("duration", str(track.duration // 1000))) args.append(("sk", token)) api_sig = self.__get_sig_for_args(args) args.append(("api_sig", api_sig)) post_data = {} for (name, value) in args: post_data[name] = value msg = Soup.form_request_new_from_hash("POST", self.__uri, post_data) msg.request_headers.append("Accept-Charset", "utf-8") data = App().task_helper.send_message_sync(msg, self.__cancellable) if data is not None: Logger.debug("%s: %s -> %s", self.__uri, data, post_data) except Exception as e: Logger.error("LastFMWebService::__playing_now(): %s" % e)
def run(): parser = ArgumentParser( description='Something For Reddit - a Gtk+ Reddit Client') parser.add_argument('uri', help='Reddit.com URI to open, or None', default=None, nargs='?') parser.add_argument('--dark', help='Force Gtk+ dark theme', action='store_true') args = parser.parse_args() settings = Gtk.Settings.get_default() theme = get_settings()['theme'] if theme == 'dark': settings.props.gtk_application_prefer_dark_theme = True elif theme == 'light': settings.props.gtk_application_prefer_dark_theme = False if args.dark: settings.props.gtk_application_prefer_dark_theme = True session = Soup.Session() ic = IdentityController(session) api_factory = APIFactory(session) a = Application(ic, api_factory) if args.uri is not None: a.goto_reddit_uri(args.uri) status = a.run() get_read_controller().save() sys.exit(status)
def checkuri(self, uri, callback, **kwargs): if not self.soup: self.soup = Soup.SessionAsync() msg = Soup.Message.new("GET", uri) self.to_check.append(uri) kwargs['uri'] = uri self.soup.queue_message(msg, callback, kwargs)
def changed(self, entry): from gi.repository import Gtk, GObject, GLib, Soup text = misc.utf8(self.city_entry.get_text()) if not text: return # TODO if the completion widget has a selection, return? How do we # determine this? if text in self.geoname_cache: model = self.geoname_cache[text] self.city_entry.get_completion().set_model(model) else: model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING) if self.geoname_session is None: self.geoname_session = Soup.SessionAsync() url = _geoname_url % (quote(text), misc.get_release().version) message = Soup.Message.new('GET', url) message.request_headers.append('User-agent', 'Ubiquity/1.0') self.geoname_session.abort() if self.geoname_timeout_id is not None: GLib.source_remove(self.geoname_timeout_id) self.geoname_timeout_id = \ GLib.timeout_add_seconds(2, self.geoname_timeout, (text, model)) self.geoname_session.queue_message(message, self.geoname_cb, (text, model))
def do_activate(self): shell = self.object self.db = shell.props.db self.artcache = os.path.join(RB.user_cache_dir(), "album-art", "") self.art_store = RB.ExtDB(name="album-art") self.art_store.connect("added", self.art_added_cb) self.shell_player = shell.props.shell_player self.shell_player.connect("playing-song-changed", self.playing_song_changed_cb) self.shell_player.connect("playing-song-property-changed", self.playing_song_property_changed_cb) self.shell_player.connect("playing-changed", self.playing_changed_cb) self.shell_player.connect("elapsed-nano-changed", self.elapsed_nano_changed_cb) self.playing_song_changed_cb(self.shell_player, self.shell_player.get_playing_entry()) self.http_server = Soup.Server() self.http_server.add_handler(path="/art/", callback=self.http_art_cb) self.http_server.add_handler(path="/icon/", callback=self.http_icon_cb) self.http_server.add_handler(path="/entry/current/stream", callback=self.http_track_cb) self.http_server.add_handler(path="/css/", callback=self.http_static_css_cb) self.http_server.add_handler(path="/js/", callback=self.http_static_js_cb) self.http_server.add_websocket_handler("/ws/player", None, None, self.player_websocket_cb) self.http_server.add_handler(path="/", callback=self.http_root_cb) self.http_listen()
def __love(self, artist, title, status): """ Love track @param artist as string @param title as string @param status as bool """ try: token = App().ws_director.token_ws.get_token( self.__name, self.__cancellable) if token is None: return if status: args = self.__get_args_for_method("track.love") else: args = self.__get_args_for_method("track.unlove") args.append(("artist", artist)) args.append(("track", title)) args.append(("sk", token)) api_sig = self.__get_sig_for_args(args) args.append(("api_sig", api_sig)) post_data = {} for (name, value) in args: post_data[name] = value msg = Soup.form_request_new_from_hash("POST", self.__uri, post_data) msg.request_headers.append("Accept-Charset", "utf-8") data = App().task_helper.send_message_sync(msg, self.__cancellable) if data is not None: Logger.debug("%s: %s", self.__uri, data) except Exception as e: Logger.error("LastFMWebService::__love(): %s" % e)
def menter(self, msgserver, meeting, token): if not self.vlc: self.vlc = VLCWidget(self.get("vlc")) tmp = self.get("messages") for i in tmp: tmp.remove(i) tmp = self.get("members") for i in tmp: tmp.remove(i) self.mid = meeting["id"] self.mcode = meeting["code"] self.session = Soup.Session() msg = Soup.Message.new("GET", msgserver["ip"]) self.session.websocket_connect_async(msg, None, None, None, self.on_ws_connected, meeting, token) if meeting["uid"] == get_uid(): self.madmin = True self.get("mexit").set_label(_("End meeting")) else: self.madmin = False self.get("mexit").set_label(_("Exit")) self.get("stack_main").set_visible_child_name("meeting")
def __init__(self): GObject.Object.__init__(self) self.subs_path = "" self.current_name = {"name": "", "fn": ""} self.settings = Gio.Settings('org.gnome.shell') self.ext_settings = None self.ws_conn = None self.ws_data = None self.ws_connecting = False self.soup_client = Soup.Session(timeout=3) Gio_SSS = Gio.SettingsSchemaSource if os.path.isfile(EXTENSION_PATH + '/schemas/gschemas.compiled'): schema_source = Gio_SSS.new_from_directory( EXTENSION_PATH + '/schemas', Gio_SSS.get_default(), False) else: schema_source = Gio_SSS.get_default() schema_obj = schema_source.lookup( 'org.gnome.shell.extensions.cast-to-tv', True) if schema_obj: self.ext_settings = Gio.Settings.new_full(schema_obj) locale.setlocale(locale.LC_ALL, '') if os.path.exists(EXTENSION_PATH + '/locale'): gettext.bindtextdomain('cast-to-tv', EXTENSION_PATH + '/locale') else: gettext.bindtextdomain('cast-to-tv', None) gettext.textdomain('cast-to-tv')
def get_token(cancellable): """ Get a new auth token @param cancellable as Gio.Cancellable @return str """ # Remove 60 seconds to be sure if int(time()) + 60 < SpotifySearch.__EXPIRES and\ SpotifySearch.__TOKEN is not None: debug("Use spotify token: %s" % SpotifySearch.__TOKEN) return SpotifySearch.__TOKEN try: token_uri = "https://accounts.spotify.com/api/token" credentials = "%s:%s" % (SPOTIFY_CLIENT_ID, SPOTIFY_SECRET) encoded = b64encode(credentials.encode("utf-8")) credentials = encoded.decode("utf-8") session = Soup.Session.new() data = {"grant_type": "client_credentials"} msg = Soup.form_request_new_from_hash("POST", token_uri, data) msg.request_headers.append("Authorization", "Basic %s" % credentials) status = session.send_message(msg) if status == 200: body = msg.get_property("response-body") data = body.flatten().get_data() decode = json.loads(data.decode("utf-8")) SpotifySearch.__EXPIRES = int(time()) +\ int(decode["expires_in"]) SpotifySearch.__TOKEN = decode["access_token"] return SpotifySearch.__TOKEN except: return ""
def normalize_or_autosearch_url(self, url): """Normalize the url input or return a url for search. We use SoupURI as an indication of whether the value given in url is not something we want to search; we only do that, though, if the address has a web scheme, because SoupURI will consider any string: as a valid scheme, and we will end up prepending http:// to it. This code is borrowed from Epiphany. url -- input string that can be normalized to an url or serve as search Return: a string containing a valid url """ def has_web_scheme(address): if address == '': return False scheme, sep, after = address.partition(':') if sep == '': return False return scheme in _WEB_SCHEMES soup_uri = None effective_url = None url = url.lstrip() if has_web_scheme(url): try: soup_uri = Soup.URI.new(url) except TypeError: pass if soup_uri is None and not _NON_SEARCH_REGEX.match(url): # Get the user's LANG to use as default language of # the results locale = os.environ.get('LANG', '') language_location = locale.split('.', 1)[0].lower() language = language_location.split('_')[0] # If the string doesn't look like an URI, let's search it: url_search = 'http://www.google.com/search?' \ 'q=%(query)s&ie=UTF-8&oe=UTF-8&hl=%(language)s' query_param = Soup.form_encode_hash({'q': url}) # [2:] here is getting rid of 'q=': effective_url = url_search % { 'query': query_param[2:], 'language': language } else: if has_web_scheme(url): effective_url = url else: effective_url = 'http://' + url return effective_url
def __init__(self, client): BaseModule.__init__(self, client) self._client = client self.handlers = [] self._proxy_resolver = None self._soup_session = Soup.Session()
def get_soup_session(): global _session if _session is None: _session = Soup.SessionAsync() _session.set_property("timeout", 60) _session.set_property("idle-timeout", 60) _session.set_property("user-agent", "Sugar/%s" % config.version) return _session
def setup_features(self): try: session = WebKit.get_default_session() session.connect('request-queued', self.on_session_request_queued) cookie = Soup.CookieJarText( filename=os.path.join(CONFIG_ROOT, 'cookies')) session.add_feature(cookie) self._cache = Soup.Cache(cache_dir=os.path.join( CONFIG_ROOT, 'cache'), cache_type=Soup.CacheType.SHARED) session.add_feature(self._cache) self._cache.set_max_size(10 * 1024 * 1024) self._cache.load() except Exception, e: log.error("setup_features failed with %s" % e)
def _setup_message(self, method="GET"): self._message = Soup.Message(method=method, uri=self._uri) self._message.connect('got-chunk', self._got_chunk_cb) self._message.connect('got-headers', self._headers_cb, None) if self._request_headers is not None: for header_key in self._request_headers.keys(): self._message.request_headers.append( header_key, self._request_headers[header_key])
def __init__(self, *args, **kwargs): """Initialize this instance.""" super(WebClient, self).__init__(*args, **kwargs) # pylint: disable=E0611,F0401 from gi.repository import Soup, SoupGNOME self.soup = Soup self.session = Soup.SessionAsync() self.session.add_feature(SoupGNOME.ProxyResolverGNOME()) self.session.connect("authenticate", self._on_authenticate)
def get_soup_session(): global _session if _session is None: _session = Soup.SessionAsync() _session.set_property("timeout", 60) _session.set_property("idle-timeout", 60) _session.set_property("user-agent", "Sugar/%s" % config.version) _session.add_feature_by_type(Soup.ProxyResolverDefault) return _session
def _request(self, method, url, data, content): uri = Soup.URI.new(url) message = Soup.Message(method=method, uri=uri) message.request_body.append(data) message.request_headers.append('Content-Type', content) message.request_headers.append('Authorization', self._authorize()) #logger = Soup.Logger.new(Soup.LoggerLogLevel.BODY, -1) session = Soup.SessionSync() #session.add_feature(logger) session.add_feature_by_type(Soup.ProxyResolverDefault) session.send_message(message) self._data = message.response_body.data if not 200 <= message.status_code < 300: raise ZendeskError(self._data)
def normalize_or_autosearch_url(self, url): """Normalize the url input or return a url for search. We use SoupURI as an indication of whether the value given in url is not something we want to search; we only do that, though, if the address has a web scheme, because SoupURI will consider any string: as a valid scheme, and we will end up prepending http:// to it. This code is borrowed from Epiphany. url -- input string that can be normalized to an url or serve as search Return: a string containing a valid url """ def has_web_scheme(address): if address == '': return False scheme, sep, after = address.partition(':') if sep == '': return False return scheme in _WEB_SCHEMES soup_uri = None effective_url = None url = url.lstrip() if has_web_scheme(url): try: soup_uri = Soup.URI.new(url) except TypeError: pass if soup_uri is None and not _NON_SEARCH_REGEX.match(url): # Get the user's LANG to use as default language of # the results locale = os.environ.get('LANG', '') language_location = locale.split('.', 1)[0].lower() language = language_location.split('_')[0] # If the string doesn't look like an URI, let's search it: url_search = 'http://www.google.com/search?' \ 'q=%(query)s&ie=UTF-8&oe=UTF-8&hl=%(language)s' query_param = Soup.form_encode_hash({'q': url}) # [2:] here is getting rid of 'q=': effective_url = url_search % {'query': query_param[2:], 'language': language} else: if has_web_scheme(url): effective_url = url else: effective_url = 'http://' + url return effective_url
def __init__(self): GObject.GObject.__init__(self) self._token = None get_identity_controller().token_changed.connect( self.__token_changed_cb) self.user_name = None self.session = Soup.Session() self.session.props.user_agent = USER_AGENT
def _on_message_finish(self, session, message, user_data=None): if user_data: logging.warning("in on_message, to handle %s" % (user_data.__name__)) else: print("there is no callback") status_code = message.props.status_code logging.debug('Got response code: {} ({})'.format( Soup.Status(status_code).value_name, status_code)) print("status code = %d" % (status_code)) self.wait_for_response = False if status_code == Soup.Status.UNAUTHORIZED: if not self.login or not self.password: self.emit('auth-failed') logging.warning('Requires login and password') else: self.emit('auth-failed') logging.warning('Failed to authenticate using {}'.format( self.login)) response_str = message.props.response_body_data.get_data().decode( 'UTF-8') if not 200 <= status_code < 300: logging.warning('Response was not successful') print("output is:%s" % (response_str)) return print("the json response is %s" % response_str) response = json.loads(response_str) # logging.debug('<<<\n{}'.format(pprint.pformat(response))) if user_data: user_data(response) print("now checking to see if we have something else to send", self.sendqueue) # after we come back from handling the callback, we want to check if we have # something we have to send. if self.sendqueue and self.wait_for_response is False: # check if we have anything in our sendqueue [method, url, content, query_params, headers, callback] = self.sendqueue.pop() print("making the call with:", method, url, content, query_params, headers, callback) self._make_request_async(method, url, content, query_params={}, headers={}, callback=None)
def on_connect_clicked(self, widget): if not self.host_entry.get_text(): self.host_entry.grab_focus() return self.spinner.start() self.session = Soup.Session() msg = Soup.Message.new("GET", self.host_entry.get_text()) self.session.websocket_connect_async(msg, None, None, None, self.on_connection)
def _seed_xs_cookie(cookie_jar): """Create a HTTP Cookie to authenticate with the Schoolserver. Do nothing if the laptop is not registered with Schoolserver, or if the cookie already exists. """ settings = Gio.Settings('org.sugarlabs') backup_url = settings.get_string('backup-url') if not backup_url: _logger.debug('seed_xs_cookie: Not registered with Schoolserver') return settings = Gio.Settings('org.sugarlabs.collaboration') jabber_server = settings.get_string('jabber-server') soup_uri = Soup.URI() soup_uri.set_scheme('xmpp') soup_uri.set_host(jabber_server) soup_uri.set_path('/') xs_cookie = cookie_jar.get_cookies(soup_uri, for_http=False) if xs_cookie is not None: _logger.debug('seed_xs_cookie: Cookie exists already') return pubkey = profile.get_profile().pubkey cookie_data = { 'color': profile.get_color().to_string(), 'pkey_hash': sha1(pubkey).hexdigest() } expire = int(time.time()) + 10 * 365 * 24 * 60 * 60 xs_cookie = Soup.Cookie() xs_cookie.set_name('xoid') xs_cookie.set_value(json.dumps(cookie_data)) xs_cookie.set_domain(jabber_server) xs_cookie.set_path('/') xs_cookie.set_max_age(expire) cookie_jar.add_cookie(xs_cookie) _logger.debug('seed_xs_cookie: Updated cookie successfully')
def new_from_message(cls, soup_message: Soup.Message): data = soup_message.props.response_body_data.get_data() if data: data = json.loads(data.decode('utf-8')) message = data['message'] error_code = data['errorCode'] error_message = data['errorString'] else: message = 'HTTP Error' error_code = soup_message.props.status_code error_message = Soup.Status(error_code).value_name return cls(message, error_code, error_message)
def _on_message_finish(self, session, message, user_data=None): status_code = message.props.status_code logging.debug('Got response code: {} ({})'.format( Soup.Status(status_code).value_name, status_code)) if status_code == Soup.Status.UNAUTHORIZED: if not self.username or not self.password: logging.warning('Requires authentication') else: logging.warning('Failed to log in as {}'.format(self.username)) elif status_code == Soup.Status.CONFLICT: self._session_id = message.props.response_headers.get( 'X-Transmission-Session-Id') logging.info('Got new session id ({}), retrying'.format( self._session_id)) message.props.request_headers.replace('X-Transmission-Session-Id', self._session_id) # requeue_message fails? self._session.cancel_message(message, Soup.Status.CANCELLED) self._session.queue_message(message, self._on_message_finish, user_data=user_data) if not 200 <= status_code < 300: logging.warning('Response was not successful: {} ({})'.format( Soup.Status(status_code).value_name, status_code)) return response_str = message.props.response_body_data.get_data().decode( 'UTF-8') response = json.loads(response_str) logging.debug('<<<\n{}'.format(pprint.pformat(response))) if response.get('result') != 'success': logging.warning('Request failed: {}'.format( response.get('result'))) return if user_data: user_data(response)
def _lastfm_api_call(self, media, time_stamp, request_type_key): """Internal method called by self.scrobble""" api_key = self._goa_lastfm.client_id sk = self._goa_lastfm.session_key secret = self._goa_lastfm.secret artist = utils.get_artist_name(media) title = utils.get_media_title(media) request_type = { "update now playing": "track.updateNowPlaying", "scrobble": "track.scrobble" } # The album is optional. So only provide it when it is # available. album = media.get_album() request_dict = {} if album: request_dict.update({ "album": album }) if time_stamp is not None: request_dict.update({ "timestamp": str(time_stamp) }) request_dict.update({ "api_key": api_key, "method": request_type[request_type_key], "artist": artist, "track": title, "sk": sk, }) sig = "" for key in sorted(request_dict): sig += key + request_dict[key] sig += secret api_sig = md5(sig.encode()).hexdigest() request_dict.update({ "api_sig": api_sig }) msg = Soup.form_request_new_from_hash( "POST", "https://ws.audioscrobbler.com/2.0/", request_dict) self._soup_session.queue_message( msg, self._lastfm_api_callback, request_type_key)
def file_loaded(self, data): buff = Soup.Buffer.new(data) multipart = Soup.Multipart.new('multipart/form-data') multipart.append_form_string('data_type', 'fit') multipart.append_form_file('file', self.activity.filename, 'application/octet-stream', buff) message = Soup.form_request_new_from_multipart(UPLOAD_URL, multipart) message.request_headers.append('Authorization', 'Bearer {}'.format(self.token)) self.session.send_async(message, callback=self.sent_cb) self.change_status(Uploader.Status.UPLOADING)
def __init__(self, activity): GObject.GObject.__init__(self) self.token = activity.app.config.get('strava', 'access_token') self.activity = activity self.session = Soup.Session() # somewhat public attrs self.id = None self.status = Uploader.Status.NONE self.error = None self.activity_id = None
def __init__(self, con): BaseModule.__init__(self, con) self.available = False self.component = None self.httpupload_namespace = None self.max_file_size = None # maximum file size in bytes self._proxy_resolver = None self._queued_messages = {} self._session = Soup.Session() self._session.props.ssl_strict = False self._session.props.user_agent = 'Gajim %s' % app.version
def _request(self, method, url, data, content): uri = Soup.URI.new(url) message = Soup.Message(method=method, uri=uri) message.request_body.append(data) message.request_headers.append('Content-Type', content) message.request_headers.append('Authorization', self._authorize()) session = Soup.SessionSync() session.add_feature_by_type(Soup.ProxyResolverDefault) session.send_message(message) self._data = message.response_body.data self._code = message.status_code if self._code < 100: raise NetworkError('transmission failed with %d, %s, %s', self._code, Soup.status_get_phrase(self._code), str(self._data)) if not 200 <= self._code < 300: raise ServerError('operation failed with %d, %s, %s', self._code, Soup.status_get_phrase(self._code), str(self._data))
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) self._session = Soup.Session() self._session.props.ssl_strict = False if self._log.getEffectiveLevel() == logging.INFO: self._session.add_feature( Soup.Logger.new(Soup.LoggerLogLevel.BODY, -1)) self._websocket = None self._cancellable = Gio.Cancellable() self._input_closed = False self._output_closed = False
def _on_request(self, view, frame, resource, request, response): print (' on request', view, frame, resource, request, response) if request: message = request.get_message() # SoupMessage if resource: uri = request.get_uri() print (' Resource data:') print (' Data:', resource.get_data()) print (' URI:', uri) print (' MIME:', resource.get_mime_type()) print (' Frame:', resource.get_frame_name()) #print uri if self._env is None: print ('ENVIROMENT NONE ON REQUEST') return uri = request.get_uri() message = request.get_message() # SoupMessage print ('URI:' + str(uri)) u = urlparse(uri) if u.netloc != self._u.netloc: print ('netloc:' + str(u.netloc)) print ('self netloc:' + str(self._u.netloc)) return if u.scheme != self._u.scheme: print ('scheme:' + str(u.scheme)) print ('self scheme:' + str(self._u.scheme)) return if self._oauth: print ('oauth CALL FIRST TIME') """query = dict(parse_qsl(u.query)) if u.query and not query: query = {u.query: ''} baseurl = ''.join([u.scheme, '://', u.netloc, u.path]) print ('baseurl:' + str(baseurl)) method = message.method print ('method:' + str(method)) h = _oauth_header(self._oauth, method, baseurl, query)""" elif self._basic: # http://comments.gmane.org/gmane.os.opendarwin.webkit.gtk/1194 # http://webkitgtk.org/reference/webkitgtk/stable/WebKitSoupAuthDialog.html print (WebKit.get_default_session().new()) h = _basic_auth_header(self._basic) else: return print ('request message method:' + str(request.props.message.props.method)) print ('request message uri:' + str(request.props.message.props.uri)) print ('request message http_version:' + str(request.props.message.props.http_version)) print ('request message flags:' + str(request.props.message.props.flags)) print ('request message server_side:' + str(request.props.message.props.server_side)) print ('request message status_code:' + str(request.props.message.props.status_code)) print ('request message reason_phrase:' + str(request.props.message.props.reason_phrase)) print ('request message first_party:' + str(request.props.message.props.first_party)) print ('request message request_body:' + str(request.props.message.props.request_body)) print ('request message request_headers:' + str(request.props.message.props.request_headers)) print ('request message tls_certificate:' + str(request.props.message.props.tls_certificate)) print ('request message tls_errors:' + str(request.props.message.props.tls_errors)) # http://developer.gnome.org/libsoup/stable/SoupSession.html#SoupSession-authenticate # Removes all the headers listed in the Connection header. message.request_headers.clean_connection_headers() print ('request uri:' + str(request.props.uri)) for (key, value) in h.items(): print ('key:' + str(key)) print ('value:' + str(value)) message.request_headers.append(key, value) print('COOKIES' + str(Soup.cookies_from_request(message))) print('AUTH' + str(message.request_headers.get("Authorization"))) print('Referer' + str(message.request_headers.get("Referer"))) print('Connection' + str(message.request_headers.get("Connection"))) print('Content-Type' + str(message.request_headers.get("Content-Type"))) print('Timeout' + str(message.request_headers.get("Timeout"))) print('Accept' + str(message.request_headers.get("Accept"))) # http://developer.gnome.org/libsoup/stable/SoupMessage.html print ('STATUS HTTP STATUS' + str(request.props.message.get_https_status())) print ('STATUS HTTP VERSION' + str(request.props.message.get_http_version())) print ('STATUS HTTP URI' + str(request.props.message.get_uri())) print ('STATUS HTTP ADDRESS' + str(request.props.message.get_address())) print ('STATUS HTTP FLAGS' + str(request.props.message.get_flags())) print ('STATUS KEEPALIVE' + str(request.props.message.is_keepalive())) print ('STATUS get_first_party' + str(request.props.message.get_first_party())) print ('STATUS get_' + str(request.props.message.props.request_headers.get_list(str(Soup.MessageHeadersType.RESPONSE)))) """SoupMessageHeaders