Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are valid characters for creating a multipart form boundary?

In an HTML form post what are valid characters for creating a multipart boundary?

like image 639
lajos Avatar asked Sep 29 '08 03:09

lajos


People also ask

How do you create a boundary in multipart form data?

The boundary is included to separate name/value pair in the multipart/form-data . The boundary parameter acts like a marker for each pair of name and value in the multipart/form-data. The boundary parameter is automatically added to the Content-Type in the http (Hyper Text Transfer Protocol) request header.

What is boundary in Content-Type multipart form data?

multipart/form-data contains boundary to separate name/value pairs. The boundary acts like a marker of each chunk of name/value pairs passed when a form gets submitted. The boundary is automatically added to a content-type of a request header.

What is the format of multipart form data?

A multipart/form-data request body contains a series of parts separated by a boundary delimiter, constructed using Carriage Return Line Feed (CRLF), "--", and also the value of the boundary parameters. The boundary delimiter must not appear inside any of the encapsulated parts.

How do you set boundaries in HTTP request?

The boundary is specified like this: Content-Type: multipart/form-data; boundary=AaB03x . So, without a proper content-type, you almost can't have true multipart/form-data.


2 Answers

According to RFC 2046, section 5.1.1:

 boundary := 0*69<bchars> bcharsnospace

 bchars := bcharsnospace / " "

 bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
                  "+" / "_" / "," / "-" / "." /
                  "/" / ":" / "=" / "?"

So it can be between 1 and 70 characters long, consisting of alphanumeric, and the punctuation you see in the list. Spaces are allowed except at the end.

like image 103
Chris Jester-Young Avatar answered Oct 20 '22 16:10

Chris Jester-Young


There are no rules as of the content of the boundary but as it must not occur in any of the parts of your message content is usually a randomly generated sequence of numbers, letters or combination of both in order to guarantee uniqueness and differentiate from any possible dictionary words. So as you start your message each data type section is separated by “–” followed by the boundary sequence and the content type + encoding. After the last section “–” followed by the boundary followed by “–” is used to delimit the end of the message. The way multipart content works is by specifying a boundary in the “Content-type:” header of your email. The boundary is used to separate the different content types and looks something like this:

Content-type: multipart/mixed; boundary="fU3W4Vzr4G3D54f3"
like image 30
camflan Avatar answered Oct 20 '22 17:10

camflan