Skip to main content

Streaming parser for multipart/form-data

Project description

Streaming multipart/form-data parser

image

image

image

image

streaming_form_data provides a Python parser for parsing multipart/form-data input chunks (the encoding used when submitting data over HTTP through HTML forms).

Installation

$ pip install streaming-form-data

In case you prefer cloning the Github repository and installing manually, please note that develop is the development branch, so stable is what you should be working with.

Usage

>>> from streaming_form_data import StreamingFormDataParser
>>> from streaming_form_data.targets import ValueTarget, FileTarget, NullTarget
>>>
>>> headers = {'Content-Type': 'multipart/form-data; boundary=boundary'}
>>>
>>> parser = StreamingFormDataParser(headers=headers)
>>>
>>> parser.register('name', ValueTarget())
>>> parser.register('file', FileTarget('/tmp/file.txt'))
>>> parser.register('discard-me', NullTarget())
>>>
>>> for chunk in request.body:
...     parser.data_received(chunk)
...
>>>

Documentation

Up-to-date documentation is available on Read the Docs.

Development

Please make sure you have Python 3.6+ and pip-tools installed.

Since this package includes a C extension, please make sure you have a working C compiler available. On Debian-based distros this usually means installing the build-essentials package.

  1. Git clone the repository - git clone https://github.com/siddhantgoel/streaming-form-data

  2. Install the packages required for development - pip install -r requirements-dev.txt

  3. That's basically it. You should now be able to run the test suite - make test.

Please note that tests/test_parser_stress.py stress tests the parser with large inputs, which can take a while. As an alternative, pass the filename as an argument to py.test to run tests selectively.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streaming-form-data-1.10.1.tar.gz (91.0 kB view hashes)

Uploaded Source

Built Distributions

streaming_form_data-1.10.1-cp38-cp38-win_amd64.whl (64.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

streaming_form_data-1.10.1-cp38-cp38-win32.whl (55.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

streaming_form_data-1.10.1-cp38-cp38-manylinux2010_x86_64.whl (379.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

streaming_form_data-1.10.1-cp38-cp38-manylinux2010_i686.whl (363.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

streaming_form_data-1.10.1-cp38-cp38-manylinux1_i686.whl (363.7 kB view hashes)

Uploaded CPython 3.8

streaming_form_data-1.10.1-cp38-cp38-macosx_10_9_x86_64.whl (66.9 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

streaming_form_data-1.10.1-cp37-cp37m-win_amd64.whl (62.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

streaming_form_data-1.10.1-cp37-cp37m-win32.whl (54.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

streaming_form_data-1.10.1-cp37-cp37m-manylinux2010_x86_64.whl (311.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

streaming_form_data-1.10.1-cp37-cp37m-manylinux2010_i686.whl (298.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

streaming_form_data-1.10.1-cp37-cp37m-manylinux1_i686.whl (298.0 kB view hashes)

Uploaded CPython 3.7m

streaming_form_data-1.10.1-cp37-cp37m-macosx_10_9_x86_64.whl (65.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

streaming_form_data-1.10.1-cp36-cp36m-win_amd64.whl (62.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

streaming_form_data-1.10.1-cp36-cp36m-win32.whl (54.0 kB view hashes)

Uploaded CPython 3.6m Windows x86

streaming_form_data-1.10.1-cp36-cp36m-manylinux2010_x86_64.whl (314.5 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

streaming_form_data-1.10.1-cp36-cp36m-manylinux2010_i686.whl (300.9 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

streaming_form_data-1.10.1-cp36-cp36m-manylinux1_i686.whl (300.9 kB view hashes)

Uploaded CPython 3.6m

streaming_form_data-1.10.1-cp36-cp36m-macosx_10_9_x86_64.whl (68.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page