Esempio n. 1
0
    def post(self, url, data, expiration=None):
        scheme, host, port, path, query = http.parse(url)
        location = http.compose(path, query)

        key = (scheme, host, port)

        now = time.time()
        exp = expiration + now if expiration is not None else None

        if key in self._quarantined:
            return self._add_pending(key, path, data, exp)

        if key not in self._peers:
            d = self._add_pending(key, path, data, exp)
            self._connect(key)
            return d

        d = defer.Deferred()
        self._post(key, location, data, exp, now, d)
        return d
Esempio n. 2
0
def parse(connection_string):
    """Parse a tunnel connection string and build a recipient from it."""
    scheme, host, port, location, _query = http.parse(str(connection_string))
    route = http.compose(host=host, port=port, scheme=scheme)
    key = location.lstrip("/")
    return recipient.Recipient(key, route, CHANNEL_TYPE)