We are hiring
HTTPRequests
Advertisements
PreviousPage
NextPage
AnHTTPclientsendsanHTTPrequesttoaserverintheformofarequestmessagewhichincludesfollowingformat:
ARequestline
Zeroormoreheader(General|Request|Entity)fieldsfollowedbyCRLF
Anemptyline(i.e.,alinewithnothingprecedingtheCRLF)
indicatingtheendoftheheaderfields
Optionallyamessagebody
ThefollowingsectionsexplaineachoftheentitiesusedinanHTTPrequestmessage.
RequestLine
TheRequestLinebeginswithamethodtoken,followedbytheRequestURIandtheprotocolversion,[Link]
separatedbyspaceSPcharacters.
RequestLine=MethodSPRequestURISPHTTPVersionCRLF
Let'sdiscusseachofthepartsmentionedintheRequestLine.
RequestMethod
The request method indicates the method to be performed on the resource identified by the given RequestURI. The method is case
[Link]/1.1.
S.N.
MethodandDescription
GET
[Link]
dataandshouldhavenoothereffectonthedata.
2
HEAD
SameasGET,butittransfersthestatuslineandtheheadersectiononly.
3
POST
APOSTrequestisusedtosenddatatotheserver,forexample,customerinformation,fileupload,[Link].
4
PUT
Replacesallthecurrentrepresentationsofthetargetresourcewiththeuploadedcontent.
5
DELETE
RemovesallthecurrentrepresentationsofthetargetresourcegivenbyURI.
6
CONNECT
EstablishesatunneltotheserveridentifiedbyagivenURI.
7
OPTIONS
Describethecommunicationoptionsforthetargetresource.
8
TRACE
Performsamessageloopbacktestalongwiththepathtothetargetresource.
RequestURI
The RequestURI is a Uniform Resource Identifier and identifies the resource upon which to apply the request. Following are the most
commonlyusedformstospecifyanURI:
RequestURI="*"|absoluteURI|abs_path|authority
S.N.
MethodandDescription
Theasterisk*isusedwhenanHTTPrequestdoesnotapplytoaparticularresource,buttotheserveritself,andisonlyallowedwhenthe
[Link]:
OPTIONS*HTTP/1.1
2
[Link]
validcache,[Link]:
GET[Link]
3
[Link],aclientwishingto
retrievearesourcedirectlyfromtheoriginserverwouldcreateaTCPconnectiontoport80ofthehost"[Link]"andsendthefollowing
lines:
GET/pub/WWW/[Link]/1.1
Host:[Link]
NotethattheabsolutepathcannotbeemptyifnoneispresentintheoriginalURI,itMUSTbegivenas"/"(theserverroot).
RequestHeaderFields
We will study Generalheader and Entityheader in a separate chapter when we will learn HTTP header fields. For now, let's check what
Requestheaderfieldsare.
Therequestheaderfieldsallowtheclienttopassadditionalinformationabouttherequest,andabouttheclientitself,[Link]
[Link]:
AcceptCharset
AcceptEncoding
AcceptLanguage
Authorization
Expect
From
Host
IfMatch
IfModifiedSince
IfNoneMatch
IfRange
IfUnmodifiedSince
MaxForwards
ProxyAuthorization
Range
Referer
TE
UserAgent
YoucanintroduceyourcustomfieldsincaseyouaregoingtowriteyourowncustomClientandWebServer.
ExamplesofRequestMessage
Nowlet'[Link]
GET/[Link]/1.1
UserAgent:Mozilla/4.0(compatible;MSIE5.01;WindowsNT)
Host:[Link]
AcceptLanguage:enus
AcceptEncoding:gzip,deflate
Connection:KeepAlive
[Link]
header,[Link]
messagebody:
POST/cgibin/[Link]/1.1
UserAgent:Mozilla/4.0(compatible;MSIE5.01;WindowsNT)
Host:[Link]
ContentType:application/xwwwformurlencoded
ContentLength:length
AcceptLanguage:enus
AcceptEncoding:gzip,deflate
Connection:KeepAlive
licenseID=string&content=string&/paramsXML=string
HerethegivenURL/cgibin/[Link],[Link]
typetellstheserverthatthepasseddataisasimplewebformdataandlengthwillbetheactuallengthofthedataputinthemessage
[Link]:
POST/cgibin/[Link]/1.1
UserAgent:Mozilla/4.0(compatible;MSIE5.01;WindowsNT)
Host:[Link]
ContentType:text/xml;charset=utf8
ContentLength:length
AcceptLanguage:enus
AcceptEncoding:gzip,deflate
Connection:KeepAlive
<?xmlversion="1.0"encoding="utf8"?>
<stringxmlns="[Link]
PreviousPage
NextPage
Advertisements
Write for us
FAQ's
Helping
Contact
Copyright 2016. All Rights Reserved.
Enter email for newsletter
go