HTTPServer._on_headers should catch ValueError from HTTPHeaders.parse() #699

scavpy opened this Issue Mar 19, 2013 · 0 comments


None yet

1 participant


tornado/, line 283

The call to HTTPHeaders.parse() is not in a try block, so if there's a malformed header, the exception isn't caught. It would be better to do this:

    headers = httputil.HTTPHeaders.parse(data[eol:])
except ValueError:
    raise _BadRequestException("Malformed header")

which is consistent with how other problems in the headers are handled. ValueError is the most likely, because that's what you get if a header line contains no colon; the tuple unpack inside parse_line() fails.

@bdarnell bdarnell closed this in 8ca13ef Apr 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment