Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Unexpected keyword argument 'content_type' #6

@danballance

Description

@danballance

Hi,

I am getting an error when I try to use the HAL codec, as follows:

python2.7/site-packages/coreapi/transports/http.py", line 249, in _decode_result
result = codec.load(response.content, **options)
TypeError: load() got an unexpected keyword argument 'content_type'

Looking at http.py around line 249, I can see that if a content-type header was returned, it's inserted into options.

if 'content-type' in response.headers:
    options['content_type'] = response.headers['content-type']

Options is then unpacked and passed as parameters to codec.load(). The signature for the base codec is:

load(self, *args, **kwargs)

However the HAL codec has:

load(self, bytes, base_url=None)

This is unable to handle the content_type parameter. Changing this to the below gets everything working for me.

load(self, bytes, base_url=None, **kwargs)

Have I debugged this correctly? Happy to submit a PR if you agree that this correctly solves a valid issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions