django / django/new-features

Add pluggable request body parsers

Open
#105 6 comments 21 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

Make request body parsing pluggable.

Benefits

1. Performance, can not use different, more performant libraries like python-multipart or mutipart for parsing forms.
2. Extensibility - Support for msgpack, protobuf, CBOR, and custom formats

Prior

- Django REST Framework: parser_classes on views - proven pattern, widely adopted

### Problem

Django's HttpRequest._load_post_and_files() currently hardcodes support for only two content types:
```
# django/http/request.py:411-455
def _load_post_and_files(self):
if self.content_type == "multipart/form-data":
# MultiPartParser
elif self.content_type == "application/x-www-form-urlencoded":
# QueryDict(self.body)
else:
# Empty QueryDict - no parsing
```

### Request or proposal

proposal

### Additional Details

It is related to https://github.com/django/deps/pull/88. It can be a stepping stone for that dep.

### Implementation Suggestions

Proposed API

Body parser can just be an attribute of the `request`. The user can override that attribute if they want to implement their own parser.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.