question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content-Type header in multipart does not contain required parameter boundary

See original GitHub issue

RFC: https://tools.ietf.org/html/rfc7578#appendix-A

Related Comment and issue: https://github.com/django/channels/issues/1386#issuecomment-568215439 https://twistedmatrix.com/trac/ticket/9739

Background:

Consider a multipart request as such:

Body:

--d66f495a-c4d1-487c-9277-9ab1a20001cc
Content-Disposition: form-data; name="content"
Content-Type: multipart/form-data; charset=utf-8

Anything
--d66f495a-c4d1-487c-9277-9ab1a20001cc--

Header: Content-Type: multipart/form-data; boundary=d66f495a-c4d1-487c-9277-9ab1a20001cc

A new change in Python 3.7 considers this request multipart header as invalid, which according to @twm is not compliant with the latest change in the RFC (2015).

Hence, on new Python versions, when the request is parsed, it tries to get the boundary from the multipart body Content-Type header and it returns empty string since there is none, and throws saying that is is Invalid Boundary

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
twmcommented, Dec 31, 2019

I don’t see anything in https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/MultipartBody.kt that would generate this header. Nor do I see such sniffing here https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/RequestBody.kt Does your application code set it?

0reactions
iamareebjamalcommented, Feb 14, 2020

Thanks. Will try and revert

Read more comments on GitHub >

github_iconTop Results From Across the Web

fetch - Missing boundary in multipart/form-data POST
The solution to the problem is to explicitly set Content-Type to undefined so that your browser or whatever client you're using can set...
Read more >
RFC1341(MIME) : 7 The Multipart content type
The only mandatory parameter for the multipart Content-Type is the boundary parameter, which consists of 1 to 70 characters from a set of...
Read more >
Multipart Bodies - Documentation - Perforce Software
All multipart types require that the header value contain a boundary parameter. The value of the boundary parameter delimits the parts of the...
Read more >
Multipart | Distech Controls Wiki
The Content-Type field for multipart entities requires one parameter, "boundary", which is used to specify the encapsulation boundary.
Read more >
RFC 7578: Returning Values from Forms: multipart/form-data
It has received public review and has been approved for publication by the ... the "boundary" parameter values in quotes in the Content-Type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found