Visitar URL original
How to do an early stop? 路 Issue #87 路 MagicStack/httptools 路 GitHub
Skip to content

How to do an early stop?聽#87

Description

@Kludex

Hi there 馃憢

I'm trying to implement a flag --limit-request-header-count on uvicorn, which I implemented changing the value of an attribute too_many_headers and raising an exception from on_header callback, see https://github.com/encode/uvicorn/pull/1683/files.

My question is: is my implementation as intended? Should the HttpParserCallbackError send more information when an exception happens from one of the callbacks?

Activity

  1. Kludex commented on Oct 2, 2022

    @Kludex
    ContributorAuthor

    It looks like checking the count doesn't make much sense if we can limit the size of the headers. How can I do it for httptools? Should it be on httptools itself?

  2. Kludex commented on Oct 30, 2022

    @Kludex
    ContributorAuthor

    Ok. Now I understand more. What I did doesn't make any sense.

    httptools does something cool here:

    if PyMemoryView_Check(data):
    buf = PyMemoryView_GET_BUFFER(data)
    data_len = <size_t>buf.len
    err = cparser.llhttp_execute(
    self._cparser,
    <char*>buf.buf,
    data_len)
    else:
    buf = &self.py_buf
    PyObject_GetBuffer(data, buf, PyBUF_SIMPLE)
    owning_buf = True
    data_len = <size_t>buf.len
    err = cparser.llhttp_execute(
    self._cparser,
    <char*>buf.buf,
    data_len)

    Still, I cannot do anything on uvicorn to limit the size of the headers/body, because I need to do it before it's parsed.

    Ref.: https://github.com/nodejs/node/tree/fd36a8dadba7fcbd74f0ab82a8ee1b3150ce5167/deps/llhttp/src (this is for myself)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions