ahknight / httpsig

HTTP Signature for Python
https://datatracker.ietf.org/doc/draft-cavage-http-signatures/
MIT License
36 stars 20 forks source link

CaseInsensitiveDict incompatible with normal dict ? #8

Closed ldng closed 5 years ago

ldng commented 8 years ago

I might have found a bug. Unless I'm missunderstanding something. If you try to merge an existing normal dict the result is None Tested with Python 3.5.1 :

    import httpsig
    from email.utils import formatdate

    headers = {'whatever': 'the weather' }
    signed_headers_dict = hs.sign(
        {'Date': formatdate(timeval=None, localtime=False, usegmt=True), 'Host': '127.0.0.1:8000'},
        method='GET',
        path='/'
    )
    headers = headers.update(signed_headers_dict)
    print header # wil be None
    headers = signed_headers_dict.update(headers)
    print header # wil be None
ldng commented 8 years ago

I see my mistake, I should not be trying to modify headers after signing them anyway. So this bug is irrelevant in httpsig usecase (still an CaseInsensitiveDict bug though IMHO)

ldng commented 8 years ago

Ok, I'm confused. I'll let someone else judge the relevancy of the bug.

ahknight commented 6 years ago

I should probably use the headers object from the email package here, honestly. It's designed for HTTP headers as well and does the same things I'm expecting. It's just more code to get to the same end.