Jmeter file upload example
Content-Type: multipart/form-data boundary=-WebKitFormBoundarydMIgtiA2YeB1Z0kl Arbitrary Boundary If you run the file upload example using Restlet client then you will see similar to the below value for the boundary parameter in Content-Type. In the above example the boundary is defined by -293582696224464 and the content is written inside the boundary delimiter or marker.Īt the end of the boundary marker you will see - which indicates the end of the boundary. URL: Request Headers: Content-Type:multipart/form-data boundary=-293582696224464 I have uploaded here an image file using Mozilla FireFox browser (you can use any browser).Ĭlicking on the Network tab of the browser debug tool you will find such information. If you run the example at link Python Flask File Upload, you will see the similar kind of data as shown below. Examples – Boundary in multipart/form-dataĮnough talking about boundary parameter, let’s see with examples… File Upload Such a delimiter line is identical to the previous delimiter lines, with the addition of two more hyphens after the boundary parameter value. The boundary delimiter line following the last body part is a distinguished delimiter that indicates that no further body parts will follow. The boundary delimiter line is then defined as a line consisting entirely of two hyphen characters (“-“, decimal value 45) followed by the boundary parameter value from the Content-Type header field, optional linear whitespace, and a terminating CRLF (Carriage Return Line Feed).īoundary delimiters must not appear within the encapsulated material, and must be no longer than 70 characters, not counting the two leading hyphens. Boundary DelimiterĪccording to the RFC2046, the Content-Type field for multipart entities requires one parameter – boundary. Yes, you can set the charset parameter, for example, to UTF-8 in Content-Type header unless you are absolutely sure that only US-ASCII charset, which is a default value in the absence of charset parameter, will be used in payload. If you do not specify the boundary parameter then your server will not be able to parse the request payload. Yes, it is not only mandatory in multipart/form-data but also in any of the multipart/* content types. Is boundary parameter mandatory in multipart/form-data? Make sure that the value for the boundary parameter does not exceed 70 bytes in length and consists only of 7-bit US-ASCII characters. Yes, an arbitrary value is allowed in boundary parameter. The name/value pair is passed when you submit an HTML form data and the Content-Type with boundary parameter gets added automatically upon form submission. The name and value pair correspond to the name and value respectively of the input fields in an HTML form which you define in the web page. Even you can use this encoding if your HTML form does not contain any input type file but application/x-In conclusion when you make a POST request, your data need to be encoded in the request body by some means and it is where your one of the encoding methods comes into picture.Īpplication/x-multipart/form-data is significantly more complex but it allows entire file data to be included in the body of the request. Generally you include multipart/form-data in your HTML form for an input type file. For example, you can use JSON (JavaScript Object Notation) data format in REST service over an HTTP/HTTPS protocol. You can also use other encoding method by other means over HTTP protocol than an HTML form submission. application/x-www-form-urlencoded (default).There are three encoding methods provided by the HTML form: It is one of the encoding methods provided by an HTML (Hyper Text Markup Language) form data. The boundary parameter is automatically added to the Content-Type in the http (Hyper Text Transfer Protocol) request header. The boundary parameter acts like a marker for each pair of name and value in the multipart/form-data. The boundary is included to separate name/value pair in the multipart/form-data. I am going to discuss here what is boundary in multipart/form-data which is mainly found for an input type of file in an HTML form.