AutoMarshallingHTTPClient __init__ bug

Bug #1295258 reported by Nathan Buckner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenCafe
New
Undecided
Unassigned

Bug Description

When instansiating the AutoMarshalling client it uses the serialize_format to set the Content-Type but ignores the deserialize_format in terms of the Accept header requiring users to set it __init__ is called or serialization will fail.(unless the api defaults to the type the user sent in deserialize_format. Also it is possible to have a content_type that does not match the format used by the client.(application/{0}) Examples application/atom+xml.

Other known problems.
Since default_headers is not a CaseInsensitiveDict, setting content-type wont change the content type because of the capitalization.

class AutoMarshallingHTTPClient(HTTPClient):
    """@TODO: Turn serialization and deserialization into decorators so
    that we can support serialization and deserialization on a per-method
    basis"""
    def __init__(self, serialize_format=None, deserialize_format=None):
        super(AutoMarshallingHTTPClient, self).__init__()
        self.serialize_format = serialize_format
        self.deserialize_format = deserialize_format or self.serialize_format
        self.default_headers = {'Content-Type': 'application/{format}'.format(
            format=serialize_format)}

Proposed solutions:
1.
Remove editing default_headers from client
Making all users set the content-type and accept headers.
2.
Add Accept header to default headers
Expect users to make overrides for special cases ie. application/atom+xml

3. Add a headers override in the init

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.