HTTP multipart/form-data Request Protocol Analysis

Source: Internet
Author: User

The protocol header and the protocol body are separated by "\r\n\r\n"

The content of the protocol body is obtained by the length of the Content-length


The attachment is uploaded as follows

Post/logsys/home/uploadispeedlog!dodefault.html http/1.1

Accept:text/plain, */*
Accept-language:zh-cn
host:192.168.24.56
content-type:multipart/form-data;boundary=-----------------------------7db372eb000e2
User-agent:winhttpclient
content-length:3693
Connection:keep-alive

-------------------------------7db372eb000e2

Content-disposition:form-data; Name= "File"; Filename= "Kn.jpg"

Content-type:image/jpeg

(Omit JPEG file binary data here ...) )

-------------------------------7db372eb000e2--

The red font part is the head of the protocol, where Content-type is a must, and it includes a flag of a similar character named boundary, which can be a random input string.

content-length:3693, 3693 Here is the total length of the file to be uploaded. If set transfer-encoding:chunked can not be set content-length

The green font part is the data that needs to be uploaded, can be text, it can be pictures and so on. Content-disposition, Content-type, and content-transfer-encoding are required in front of the data content.

The final purple part is the end of the protocol.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.