HTTP Message Body

Published 1/22/2017 11:11:54 AM  |  Last update 1/22/2017 11:12:26 AM

HTTP Message Body is the data bytes transmitted in an HTTP transaction message following immediately the headers, if there is any.

In an HTTP request, POST request as usual, HTTP Message Body is used for sending additional information in inform of query string parameters to server, happened whenever user fill in a web form and select the submit command. In an HTTP response, HTTP Message Body is the content, the HTML code of a web page for example, that the server sends back to client upon request, happened whenever user visit a webpage, and that will be shown by the browser to the user. [caption id="attachment_2041" align="aligncenter" width="583"]HTTP Protocol HTTP Protocol[/caption] The following is an example of HTTP Message Body of a GET request to the server www.tinyray.com; the request URI (Uniform Resource Identifier) is "/netcam". Additional information which was sent by this request is "img=lnt&idx=1&imgno=10&cid=thanh+le". [caption id="attachment_2046" align="aligncenter" width="594"]HTTP Message HTTP Message[/caption] The response message has the same structure, its first line however is called the Status Line which indicates how successful the request is. Followings are of another example that shows the message headers of both the HTTP request and response when user visits the website at http://www.tinyray.com. Request message header

GET /welcome.htm HTTP/1.1
Host: www.tinyray.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: lntapp=r2t5uvjq435r4q7ib3vtdjq120
Pragma: no-cache
Cache-Control: no-cache

Response message header

HTTP/1.x 200 OK
Transfer-Encoding: chunked
Date: Sat, 18 Apr 2015 04:36:25 GMT
Server: nginx
Connection: close
X-Powered-By: W3 Total Cache/0.8
Pragma: public
Expires: Sat, 18 Apr 2015 05:36:25 GMT
Etag: "pub1259380237;gz"
Cache-Control: max-age=3600, public
Content-Type: text/html; charset=UTF-8
Last-Modified: Sat, 18 Apr 2015 04:36:25 GMT
Content-Encoding: gzip
Vary: Accept-Encoding, Cookie, User-Agent

<!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" dir="ltr" lang="en-gb" xml:lang="en-gb">
<head id="PageHead"><link rel="shortcut icon" type="image/ico" href="//ws.tinyray.com/images/favicon.ico" /><link href="//ws.tinyray.com/2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ws.tinyray.com/jquery.js"></script>
<script type="text/javascript" src="//ws.tinyray.com/lntajax.js"></script>
<script type="text/javascript" src="//ws.tinyray.com/lntmms.js"></script>
<script type="text/javascript" src="//ws.tinyray.com/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//ws.tinyray.com/juiblue.css" />
<title>Welcome to TINYRAY!</title>
<!-- ... rest of the html ... -->

Please refer this PHP script for how to dump the header content of an HTTP response.

© 2024 blog.tinyray.com  by tinyray