Add support for multipart/form-data requests***#704
Open
ziyacivan wants to merge 9 commits intojazzband:masterfrom
Open
Add support for multipart/form-data requests***#704ziyacivan wants to merge 9 commits intojazzband:masterfrom
ziyacivan wants to merge 9 commits intojazzband:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #704 +/- ##
==========================================
- Coverage 86.76% 86.56% -0.20%
==========================================
Files 52 52
Lines 2115 2121 +6
==========================================
+ Hits 1835 1836 +1
- Misses 280 285 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…rt' into add_multipart_support
for more information, see https://pre-commit.ci
…django-silk into add_multipart_support
50-Course
approved these changes
Mar 24, 2024
Comment on lines
+229
to
+238
| content_type = self.request.content_type | ||
|
|
||
| if content_type.startswith('multipart/form-data'): | ||
| body = { | ||
| 'form_data': self.request.POST.dict(), | ||
| 'files': {f: self.request.FILES[f].name for f in self.request.FILES} | ||
| } | ||
| raw_body = None # Raw body is not available for multipart/form-data | ||
| else: | ||
| body, raw_body = self.body() |
Member
There was a problem hiding this comment.
@ziyacivan Good catch, and thank you for making this patch! 👏🏼
Author
There was a problem hiding this comment.
Oh thank you so much! I couldn't continue to the development process (means is tests) because of my social life issues, thank you again 👏🏽
This test-patch addresses the newly updated patch changes when dealing with `multipart/form_data` request
for more information, see https://pre-commit.ci
Member
|
Just found out six different test are failing, I do have to fix them by tomorrow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: Add Support for Multipart/Form-Data Requests
Description: I've encountered an issue when Silk attempts to handle
multipart/form-datarequests, specificallywhen trying to access
request.bodydirectly. This operation triggers aRawPostDataExceptionbecause Django consumes the stream upon parsing the multipart data, making it inaccessible afterwards.To address this, I've implemented a check for
multipart/form-datacontent type within the request handling logic. When such a content type is detected, the code now properly handles form data and file information usingrequest.POSTandrequest.FILES, avoiding direct access torequest.body. This allows Silk to gracefully handle and log multipart requests without raising exceptions.