-
-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for multipart/form-data requests*** #704
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: 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. |
…rt' into add_multipart_support
for more information, see https://pre-commit.ci
…django-silk into add_multipart_support
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ziyacivan Good catch, and thank you for making this patch! 👏🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Just found out six different test are failing, I do have to fix them by tomorrow. |
Title: Add Support for Multipart/Form-Data Requests
Description: I've encountered an issue when Silk attempts to handle
multipart/form-data
requests, specificallywhen trying to access
request.body
directly. This operation triggers aRawPostDataException
because Django consumes the stream upon parsing the multipart data, making it inaccessible afterwards.To address this, I've implemented a check for
multipart/form-data
content type within the request handling logic. When such a content type is detected, the code now properly handles form data and file information usingrequest.POST
andrequest.FILES
, avoiding direct access torequest.body
. This allows Silk to gracefully handle and log multipart requests without raising exceptions.