What is a HTTP multipart request?
It is a type of HTTP request that HTTP client construct to send information to the server.
An example:
POST
http://127.0.0.1/GetPostRequest.php HTTP/1.1
Host: 127.0.0.1
Connection: keep-alive
Referer:
http://localhost/GetPostRequest.php
Content-Length: 1611568
Cache-Control: max-age=0
Origin:
http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryX6nBO7q27yQ1JNbb
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
------WebKitFormBoundaryX6nBO7q27yQ1JNbb
Content-Disposition: form-data; name="myFileDescription"
My sample file description.
------WebKitFormBoundaryX6nBO7q27yQ1JNbb
Content-Disposition: form-data; name="myFile"; filename="SomeRandomFile.pdf"
Content-Type: application/pdf
file contents...
------WebKitFormBoundaryX6nBO7q27yQ1JNbb--
Notice the
string "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryX6nBO7q27yQ1JNbb".
This is the part that tells the server:
1) the HTTP request is a multipart request
2) The separator between different chunks of data.
In the example, there are two pieces of information:
1) A form data "myFileDescription" with value My sample file description.
2) A file named as "SomeRandomFile.pdf" and its contents.
Where it can be used?
It is used by browsers and HTTP clients to upload files to the server.
Hope this helps.