How to use the vdirsyncer.http.request function in vdirsyncer

To help you get started, we’ve selected a few vdirsyncer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / vdirsyncer / vdirsyncer / storage / remotestorage.py View on Github external
def _discover_endpoints(self, subpath):
        r = http.request(
            'GET', 'https://{host}/.well-known/webfinger?resource=acct:{user}'
            .format(host=self.host, user=self.user),
            **self._settings
        )
        j = r.json()
        for link in j['links']:
            if 'remotestorage' in link['rel']:
                break

        storage = urljoin(_ensure_slash(link['href']),
                          _ensure_slash(subpath))
        props = link['properties']
        oauth = props['http://tools.ietf.org/html/rfc6749#section-4.2']
        self.endpoints = dict(storage=storage, oauth=oauth)
github pimutils / vdirsyncer / tests / system / utils / test_main.py View on Github external
def test_request_ssl(httpsserver):
    httpsserver.serve_content('')  # we need to serve something

    with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
        http.request('GET', httpsserver.url)
    assert 'certificate verify failed' in str(excinfo.value)

    http.request('GET', httpsserver.url, verify=False)
github pimutils / vdirsyncer / tests / system / utils / test_main.py View on Github external
def test_request_ssl(httpsserver):
    httpsserver.serve_content('')  # we need to serve something

    with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
        http.request('GET', httpsserver.url)
    assert 'certificate verify failed' in str(excinfo.value)

    http.request('GET', httpsserver.url, verify=False)
github pimutils / vdirsyncer / tests / system / utils / test_main.py View on Github external
def test_request_ssl_fingerprints(httpsserver, fingerprint):
    httpsserver.serve_content('')  # we need to serve something

    http.request('GET', httpsserver.url, verify=False,
                 verify_fingerprint=fingerprint)
    with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
        http.request('GET', httpsserver.url,
                     verify_fingerprint=fingerprint)

    with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
        http.request('GET', httpsserver.url, verify=False,
                     verify_fingerprint=''.join(reversed(fingerprint)))
    assert 'Fingerprints did not match' in str(excinfo.value)
github pimutils / vdirsyncer / vdirsyncer / storage / http.py View on Github external
def list(self):
        r = request('GET', self.url, headers=self._default_headers(),
                    **self._settings)
        self._items = {}

        for item in split_collection(r.text):
            item = Item(item)
            if self._ignore_uids:
                item = item.with_uid(item.hash)

            self._items[item.ident] = item, item.hash

        return ((href, etag) for href, (item, etag) in self._items.items())
github pimutils / vdirsyncer / vdirsyncer / storage / olddav.py View on Github external
def request(self, method, path, **kwargs):
        url = self.url
        if path:
            url = urlparse.urljoin(self.url, path)

        more = dict(self._settings)
        more.update(kwargs)
        return http.request(method, url, session=self._session, **more)
github pimutils / vdirsyncer / vdirsyncer / storage / dav.py View on Github external
def request(self, method, path, **kwargs):
        url = self.url
        if path:
            url = urlparse.urljoin(self.url, path)

        more = dict(self._settings)
        more.update(kwargs)
        return http.request(method, url, session=self._session, **more)