Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deflate encoding in load_document #46

Merged

Conversation

coffindragger
Copy link
Contributor

When attempting to load a document that returned Content-Encoding: deflate, a utf8 decode error exception was thrown.

This patch uses the zlib library to inflate the binary bytes before before decoding

Details: {'url': u'https://w3id.org/openbadges/legacy-v1'}
Cause: ('Could not retrieve a JSON-LD document from the URL.',)
Type: jsonld.LoadDocumentError
Code: loading document failed
Cause: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte  
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 399, in load_document
    'document': data.decode('utf8')
  File "xxxxx/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 4066, in _retrieve_context_urls
    remote_doc = load_document(url)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 425, in load_document
    cause=cause)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 1177, in process_context
    local_ctx, {}, options['documentLoader'], options['base'])
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 4105, in _retrieve_context_urls
    self._retrieve_context_urls(ctx, cycles_, load_document, url)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 4073, in _retrieve_context_urls
    code='loading remote context failed', cause=cause)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 683, in compact
    active_ctx = self.process_context(active_ctx, ctx, options)
  File "xxxxx/lib/python2.7/site-packages/pyld/jsonld.py", line 1181, in process_context
    'jsonld.ContextError', cause=cause)

@davidlehn
Copy link
Member

Thanks for the patch. In the future please just squash code commits as appropriate and leave out the release process commits. In this case it's fine since I'll just publish the package right away but would be harder to merge if other code was going to be released too.

@davidlehn davidlehn merged commit 3ef1761 into digitalbazaar:master May 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants