Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximal header field length is not configurable #833

Closed
filmor opened this issue Mar 18, 2016 · 4 comments
Closed

Maximal header field length is not configurable #833

filmor opened this issue Mar 18, 2016 · 4 comments

Comments

@filmor
Copy link
Contributor

filmor commented Mar 18, 2016

Long story short

When connecting with Internet Explorer using SSPI to our aiohttp server we saw that it sends tokens in the Negotiate header that are longer than the statically configured maximal length of 8 KiB. It would be helpful to allow this value to be configured in the application, as currently we have

Expected behaviour

Request with a header field longer than 8192 bytes gets handled.

Actual behaviour

We receive a LineTooLong exception (see traceback). Also note, that this triggers a failure in the error logging as the headers member has not been written at that time.

Traceback (most recent call last):
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\server.py", l
ine 247, in start
    message = yield from httpstream.read()
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\streams.py",
line 591, in read
    result = yield from super().read()
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\streams.py",
line 446, in read
    yield from self._waiter
  File "d:\Miniconda3\envs\kerberos_test\lib\asyncio\futures.py", line 358, in _
_iter__
    yield self  # This tells Task to wait for completion.
  File "d:\Miniconda3\envs\kerberos_test\lib\asyncio\tasks.py", line 290, in _wa
keup
    future.result()
  File "d:\Miniconda3\envs\kerberos_test\lib\asyncio\futures.py", line 274, in r
esult
    raise self._exception
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\parsers.py",
line 139, in feed_data
    self._parser.send(data)
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\protocol.py",
 line 201, in __call__
    headers, raw_headers, close, compression = self.parse_headers(lines)
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\protocol.py",
 line 114, in parse_headers
    'limit request headers fields size')
aiohttp.errors.LineTooLong: 400, message='got more than Unknown bytes when readi
ng limit request headers fields size'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\helpers.py",
line 365, in log
    [message, environ, response, transport, time]))
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\helpers.py",
line 352, in _format_line
    return tuple(m(args) for m in self._methods)
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\helpers.py",
line 352, in 
    return tuple(m(args) for m in self._methods)
  File "d:\Miniconda3\envs\kerberos_test\lib\site-packages\aiohttp\helpers.py",
line 301, in _format_i
    return args[0].headers.get(multidict.upstr(key), '-')
AttributeError: 'NoneType' object has no attribute 'headers'

Steps to reproduce

Request something with a header > 8k in length.

Your environment

We use a conda environment with Python 3.5 on Windows, using the latest aiohttp package from PyPI.

@filmor filmor changed the title Header field length is not configurable Maximal header field length is not configurable Mar 18, 2016
@asvetlov asvetlov added the sprint label Jun 2, 2016
@djmitche
Copy link
Contributor

djmitche commented Jun 3, 2016

I have fixed the secondary error, but I'm not sure what the preferred interface would be for configuring these lengths. Should the configuration values be passed to Application()? to run()? Should the user have to send a custom RequestHandlerFactory class? Or something else?

@asvetlov
Copy link
Member

asvetlov commented Jun 3, 2016

I believe it should be ServerHttpProtocol constructor keyword-only parameter.
User may change it by passing a flag into app.make_handler(...) call.

run_app is just a syntax sugar, I don't care about it too much.

@asvetlov
Copy link
Member

Fixed by #912

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants