HTTP request message format GET and POST

Recently, I am working on the Android client image upload plug-in function for background calls. It involves splicing HTTP request packets, so I studied the contents of the packets, and now make a summary and memo.

Use Fiddler to grab the message yourself as follows:

POST request message

POST http://oa.funds.com.cn:9080/DMFramework/sys/attachment.jsp?path=&action=attachmanageadd&tableName=GZZJ&docID=0 HTTP/1.1
Accept: */*
Referer: http://oa.funds.com.cn:9080/DMFramework/sys/attachment.jsp?f=0.8902145912683143&tableName=GZZJ&docID=0&action=attachmentstart&nameAttachMentIDs=
Accept-Language: zh-CN
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
Content-Type: multipart/form-data; boundary=---------------------------7e21361611db0
Accept-Encoding: gzip, deflate
Host: oa.funds.com.cn:9080
Content-Length: 14623
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=0000AgK4N-vgetNoKBOfYd_hJQP:-1; ECSNSessionID=721303315959898497; ASPSESSIONIDQQSCRBSQ=OMFFMGDCJHLLHCLPGMKCEOEG; ASPSESSIONIDCCCRTRDD=KMENDGIBFBKFDLHKKPJGJNMF

-----------------------------7e21361611db0
Content-Disposition: form-data; name="nameAttachMentIDs"


-----------------------------7e21361611db0
Content-Disposition: form-data; name="path"


-----------------------------7e21361611db0
Content-Disposition: form-data; name="attachFile"; filename="C:\Users\qqqq\Desktop\timg.jpg"
Content-Type: image/pjpeg

此处省略二进制图片等数据
-----------------------------7e21361611db0--

Contains 4 parts.
1. The first line: the request line, indicating the request type and protocol version.

HTTP 1.0 defines three request methods: GET, POST and HEAD methods.
HTTP1.1 added five new request methods: OPTIONS, PUT, DELETE, TRACE and CONNECT methods.

write picture description here
2. The second line to the twelfth line: the request header.
3. The thirteenth line: a blank line (very important), indicating the end of the message header.
4. The following are the text of the message.

1 —————————–7e21361611db0, that is, “–boundary” is the separator that separates multiple forms and multiple pictures in the message.
2 End each part of the text with a newline character.
3 The entire packet is terminated with "-boundary-".


POST response message

HTTP/1.1 200 OK
Content-Type: text/html;charset=GBK
Content-Language: zh-CN
Date: Tue, 03 Apr 2018 05:59:10 GMT
Server: WebSphere Application Server/6.1
Content-Length: 137214



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

The HTTP response also consists of four parts: the status line, the header, the blank line, and the body .

1. The first line: protocol version number (HTTP/1.1), status code (200), status message (OK).

The status code consists of three digits. The first digit defines the category of the response, which is divided into five categories:
1xx: Indication Information – Indicates that the request has been received, continue processing
2xx: Success – Indicates that the request has been successfully received, understood, accepted
3xx : redirect – further action must be taken to complete the request
4xx: client error – the request has a syntax error or the request cannot be fulfilled
5xx: server side error – the server failed to fulfill a legitimate request
write picture description here

2. The second line to the sixth line: the message header.
3. The seventh line: a blank line, representing the end of the message header, is required.
4. The eighth line down: the message body.


GET request message:

GET http://oa.funds.com.cn:9080/OMSS/index/index.jsp?f=Fri%20Jan%205%2008:56:35%20UTC+0800%202018 HTTP/1.1
Accept: */*
Accept-Language: zh-CN
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: oa.funds.com.cn:9080
Cookie: JSESSIONID=0000AgK4N-vgetNoKBOfYd_hJQP:-1; ECSNSessionID=721303315959898497; ASPSESSIONIDQQSCRBSQ=OMFFMGDCJHLLHCLPGMKCEOEG; ASPSESSIONIDCCCRTRDD=KMENDGIBFBKFDLHKKPJGJNMF
空行

The same four parts.
1. The first line: The name of the resource to be requested and the protocol version used.
2. Lines 2 to 8: Request header.
3. The ninth line: a blank line, which means the end of the packet header.
4. The following blank line, in this example, the GET request has no request body. Parameters in a GET request can also be placed after the resource name on the first line.


GET response message

The result is basically the same as that of the Response request method, and is no longer stated.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325477849&siteId=291194637