Skip to content

'None' in HTTP headers #2183

Closed
Closed
@nesdis

Description

Long story short

Sometimes in file cookies.py the rawdata is of type None and above exception is hit.

def load(self, rawdata):
    """Load cookies from a string (presumably HTTP_COOKIE) or
    from a dictionary.  Loading cookies from a dictionary 'd'
    is equivalent to calling:
        map(Cookie.__setitem__, d.keys(), d.values())
    """
    if isinstance(rawdata, str):
        self.__parse_string(rawdata)
    else:
        # self.update() wouldn't call our custom __setitem__
        for key, value in rawdata.items():
            self[key] = value
    return

Expected behaviour

Why is raw_data given to load of type None?

This is called in function start of C:\Python36\Lib\site-packages\aiohttp\client_reqrep.py

for hdr in self.headers.getall(hdrs.SET_COOKIE, ()):
        try:
            self.cookies.load(hdr)
        except CookieError as exc:
            client_logger.warning(
                'Can not load response cookies: %s', exc)
    return self

Actual behaviour

Looks like self.headers.getall(hdrs.SET_COOKIE, ()) is returning hdr of type None, This looks buggy. It should return actual header or raise stopiteration. At times it returns None.

Steps to reproduce

I have not been able to reproduce this issue. Unfortunately I lost the stack trace console output too. But have debugged till the above point.

Your environment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions