Skip to content

Conversation

eulersIDcrisis
Copy link
Contributor

Add a basic multipart/form-data parser to tornado that can stream to files instead of in-memory as the existing call to: tornado.httputil.parse_multipart_form_data does.

Still need to fix the tests and also improve Awaitable vs. None interface.
@eulersIDcrisis eulersIDcrisis marked this pull request as ready for review February 25, 2023 19:46
@bdarnell bdarnell added the web label Apr 8, 2023
@eulersIDcrisis
Copy link
Contributor Author

One way this PR could be improved is if tornado offered an API of sorts that permitted partial searching as data comes in. For example, something like this (some details omitted):

class BufferedStream:
    def __init__(self):
        self._chunks = deque()

    def append(chunk: bytes):
        self._chunks.append(chunk)

    def read_next_until(self, match: bytes) -> Optional[bytes]:
        # 

Calls to read_next_until() could return either:

  1. Non-empty bytes chunk --> Common case.
  2. Empty bytes chunk --> Implies a match.
  3. None --> Implies not enough data (partial match)

If this class were implemented properly, this could avoid some spurious copies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants