HTTPiAbouttheTutorialTheHypertextTransferProtocol(HTTP)isanapplication-levelprotocolfordistributed,collaborative,hypermediainformationsystems.
ThisisthefoundationfordatacommunicationfortheWorldWideWeb(i.
e.
internet)since1990.
HTTPisagenericandstatelessprotocolwhichcanbeusedforotherpurposesaswellusingextensionsofitsrequestmethods,errorcodes,andheaders.
ThistutorialisbasedonRFC-2616specification,whichdefinestheprotocolreferredtoasHTTP/1.
1.
HTTP/1.
1isarevisionoftheoriginalHTTP(HTTP/1.
0).
AmajordifferencebetweenHTTP/1.
0andHTTP/1.
1isthatHTTP/1.
0usesanewconnectionforeachrequest/responseexchange,whereasHTTP/1.
1connectionmaybeusedforoneormorerequest/responseexchanges.
AudienceThistutorialhasbeenpreparedforcomputersciencegraduatesandwebdeveloperstohelpthemunderstandthebasic-to-advancedlevelconceptsrelatedtoHypertextTransferProtocol(HTTP).
PrerequisitesBeforeproceedingwiththistutorial,itisgoodtohaveabasicunderstandingofwebconcepts,webbrowsers,webservers,clientandserverarchitecturebasedsoftwares.
Copyright&DisclaimerCopyright2014byTutorialsPoint(I)Pvt.
Ltd.
Allthecontentandgraphicspublishedinthise-bookarethepropertyofTutorialsPoint(I)Pvt.
Ltd.
Theuserofthise-bookisprohibitedtoreuse,retain,copy,distributeorrepublishanycontentsorapartofcontentsofthise-bookinanymannerwithoutwrittenconsentofthepublisher.
Westrivetoupdatethecontentsofourwebsiteandtutorialsastimelyandaspreciselyaspossible,however,thecontentsmaycontaininaccuraciesorerrors.
TutorialsPoint(I)Pvt.
Ltd.
providesnoguaranteeregardingtheaccuracy,timelinessorcompletenessofourwebsiteoritscontentsincludingthistutorial.
Ifyoudiscoveranyerrorsonourwebsiteorinthistutorial,pleasenotifyusatcontact@tutorialspoint.
comHTTPiiTableofContentsAbouttheTutorialiAudience·iPrerequisites·iCopyright&DisclaimeriTableofContents·ii1.
OVERVIEW·1BasicFeatures·1BasicArchitecture·1Client2Server22.
PARAMETERS3HTTPVersion3UniformResourceIdentifiers3Date/TimeFormats·4CharacterSets·4ContentEncodings4MediaTypes5LanguageTags·53.
MESSAGES·7MessageStart-Line8HeaderFields8MessageBody·94.
REQUESTS10Request-Line·10RequestMethod10HTTPiiiRequest-URI·11RequestHeaderFields12ExamplesofRequestMessage135.
RESPONSES·15MessageStatus-Line15HTTPVersion15StatusCode·16ResponseHeaderFields16ExamplesofResponseMessage·176.
METHODS·19GETMethod·20HEADMethod·20POSTMethod·21PUTMethod·22DELETEMethod·23CONNECTMethod·24OPTIONSMethod·24TRACEMethod·257.
STATUSCODES261xx:Information262xx:Successful·273xx:Redirection·274xx:ClientError285xx:ServerError298.
HEADERFIELDS·31HTTPivGeneralHeaders31Cache-Control·31Connection33Date·34Pragma34Trailer34Transfer-Encoding35Upgrade·35Via·35Warning·35ClientRequestHeaders·36Accept·36Accept-Charset·36Accept-Encoding·36Accept-Language·37Authorization·37Cookie·37Expect·38From38Host38If-Match·38If-Modified-Since·39If-None-Match·39If-Range40If-Unmodified-Since40Max-Forwards40Proxy-Authorization41Range·41Referer·42TE·42User-Agent42ServerResponseHeaders·43Accept-Ranges·43Age·43ETag·43Location·44Proxy-Authenticate44Retry-After·44Server45Set-Cookie45Vary46WWW-Authenticate·46EntityHeaders47Allow·47Content-Encoding·47Content-Language47Content-Length48HTTPvContent-Location·48Content-MD5·48Content-Range49Content-Type·49Expires50Last-Modified509.
CACHING·5110.
URLENCODING·5411.
SECURITY·60PersonalInformationLeakage60FileandPathNamesBasedAttack·60DNSSpoofing61LocationHeadersandSpoofing·61AuthenticationCredentials61ProxiesandCaching·6112.
MESSAGEEXAMPLES·62Example162Clientrequest62Serverresponse·62Example263Clientrequest63Serverresponse·63Example364Clientrequest64Serverresponse·64Example465Clientrequest65Serverresponse·65HTTP1TheHypertextTransferProtocol(HTTP)isanapplication-levelprotocolfordistributed,collaborative,hypermediainformationsystems.
ThisisthefoundationfordatacommunicationfortheWorldWideWeb(i.
e.
internet)since1990.
HTTPisagenericandstatelessprotocolwhichcanbeusedforotherpurposesaswellusingextensionsofitsrequestmethods,errorcodes,andheaders.
Basically,HTTPisaTCP/IPbasedcommunicationprotocolthatisusedtodeliverdata(HTMLfiles,imagefiles,queryresults,etc.
)ontheWorldWideWeb.
ThedefaultportisTCP80,butotherportscanbeusedaswell.
Itprovidesastandardizedwayforcomputerstocommunicatewitheachother.
HTTPspecificationspecifieshowclients'requestdatawillbeconstructedandsenttotheserver,andhowtheserversrespondtotheserequests.
BasicFeaturesTherearethreebasicfeaturesthatmakeHTTPasimplebutpowerfulprotocol:HTTPisconnectionless:TheHTTPclient,i.
e.
,abrowserinitiatesanHTTPrequestandafterarequestismade,theclientdisconnectsfromtheserverandwaitsforaresponse.
Theserverprocessestherequestandre-establishestheconnectionwiththeclienttosendaresponseback.
HTTPismediaindependent:Itmeans,anytypeofdatacanbesentbyHTTPaslongasboththeclientandtheserverknowhowtohandlethedatacontent.
ItisrequiredfortheclientaswellastheservertospecifythecontenttypeusingappropriateMIME-type.
HTTPisstateless:Asmentionedabove,HTTPisconnectionlessanditisadirectresultofHTTPbeingastatelessprotocol.
Theserverandclientareawareofeachotheronlyduringacurrentrequest.
Afterwards,bothofthemforgetabouteachother.
Duetothisnatureoftheprotocol,neithertheclientnorthebrowsercanretaininformationbetweendifferentrequestsacrossthewebpages.
HTTP/1.
0usesanewconnectionforeachrequest/responseexchange,whereasHTTP/1.
1connectionmaybeusedforoneormorerequest/responseexchanges.
BasicArchitectureThefollowingdiagramshowsaverybasicarchitectureofawebapplicationanddepictswhereHTTPsits:1.
OVERVIEWHTTP2TheHTTPprotocolisarequest/responseprotocolbasedontheclient/serverbasedarchitecturewherewebbrowsers,robotsandsearchengines,etc.
actlikeHTTPclients,andtheWebserveractsasaserver.
ClientTheHTTPclientsendsarequesttotheserverintheformofarequestmethod,URI,andprotocolversion,followedbyaMIME-likemessagecontainingrequestmodifiers,clientinformation,andpossiblebodycontentoveraTCP/IPconnection.
ServerTheHTTPserverrespondswithastatusline,includingthemessage'sprotocolversionandasuccessorerrorcode,followedbyaMIME-likemessagecontainingserverinformation,entitymeta-information,andpossibleentity-bodycontent.
HTTP3ThischapterisgoingtolistdownfewoftheimportantHTTPProtocolParametersandtheirsyntaxthewaytheyareusedinthecommunication.
Forexample,formatfordate,formatofURL,etc.
ThiswillhelpyouinconstructingyourrequestandresponsemessageswhilewritingHTTPclientorserverprograms.
YouwillseethecompleteusageoftheseparametersinsubsequentchapterswhilelearningthemessagestructureforHTTPrequestsandresponses.
HTTPVersionHTTPusesa.
numberingschemetoindicateversionsoftheprotocol.
TheversionofanHTTPmessageisindicatedbyanHTTP-Versionfieldinthefirstline.
HereisthegeneralsyntaxofspecifyingHTTPversionnumber:HTTP-Version="HTTP""/"1*DIGIT".
"1*DIGITExampleHTTP/1.
0orHTTP/1.
1UniformResourceIdentifiersUniformResourceIdentifiers(URI)aresimplyformatted,case-insensitivestringcontainingname,location,etc.
toidentifyaresource,forexample,awebsite,awebservice,etc.
AgeneralsyntaxofURIusedforHTTPisasfollows:URI="http:""//"host[":"port][abs_path[""query]]Hereiftheportisemptyornotgiven,port80isassumedforHTTPandanemptyabs_pathisequivalenttoanabs_pathof"/".
Thecharactersotherthanthoseinthereservedandunsafesetsareequivalenttotheir""%"HEXHEX"encoding.
2.
PARAMETERSHTTP4ExampleThefollowingthreeURIsareequivalent:http://abc.
com:80/~smith/home.
htmlhttp://ABC.
com/%7Esmith/home.
htmlhttp://ABC.
com:/%7esmith/home.
htmlDate/TimeFormatsAllHTTPdate/timestampsMUSTberepresentedinGreenwichMeanTime(GMT),withoutexception.
HTTPapplicationsareallowedtouseanyofthefollowingthreerepresentationsofdate/timestamps:Sun,06Nov199408:49:37GMT;RFC822,updatedbyRFC1123Sunday,06-Nov-9408:49:37GMT;RFC850,obsoletedbyRFC1036SunNov608:49:371994;ANSIC'sasctime()formatCharacterSetsWeusecharactersetstospecifythecharactersetsthattheclientprefers.
Multiplecharactersetscanbelistedseparatedbycommas.
Ifavalueisnotspecified,thedefaultistheUS-ASCII.
ExampleFollowingarethevalidcharactersets:US-ASCIIorISO-8859-1orHTTP5ISO-8859-7ContentEncodingsAcontentencodingvalueindicatesthatanencodingalgorithmhasbeenusedtoencodethecontentbeforepassingitoverthenetwork.
Contentcodingareprimarilyusedtoallowadocumenttobecompressedorotherwiseusefullytransformedwithoutlosingtheidentity.
Allcontent-codingvaluesarecase-insensitive.
HTTP/1.
1usescontent-codingvaluesintheAccept-EncodingandContent-Encodingheaderfieldswhichwewillseeinthesubsequentchapters.
ExampleFollowingarethevalidencodingschemes:Accept-encoding:gziporAccept-encoding:compressorAccept-encoding:deflateMediaTypesHTTPusesInternetMediaTypesintheContent-TypeandAcceptheaderfieldsinordertoprovideopenandextensibledatatypingandtypenegotiation.
AlltheMedia-typevaluesareregisteredwiththeInternetAssignedNumberAuthority(IANA).
Thegeneralsyntaxtospecifymediatypeisasfollows:media-type=type"/"subtype*(";"parameter)Thetype,subtype,andparameterattributenamesarecase-insensitive.
HTTP6ExampleAccept:image/gifLanguageTagsHTTPuseslanguagetagswithintheAccept-LanguageandContent-Languagefields.
Alanguagetagiscomposedofoneormoreparts:aprimarylanguagetagandapossiblyemptyseriesofsubtags:language-tag=primary-tag*("-"subtag)Whitespacesarenotallowedwithinthetagsandalltagsarecase-insensitive.
ExampleExampletagsinclude:en,en-US,en-cockney,i-cherokee,x-pig-latinwhereanytwo-letterprimary-tagisanISO-639languageabbreviationandanytwo-letterinitialsubtagisanISO-3166countrycode.
HTTP7HTTPisbasedontheclient-serverarchitecturemodelandastatelessrequest/responseprotocolthatoperatesbyexchangingmessagesacrossareliableTCP/IPconnection.
AnHTTP"client"isaprogram(Webbrowseroranyotherclient)thatestablishesaconnectiontoaserverforthepurposeofsendingoneormoreHTTPrequestmessages.
AnHTTP"server"isaprogram(generallyawebserverlikeApacheWebServerorInternetInformationServicesIIS,etc.
)thatacceptsconnectionsinordertoserveHTTPrequestsbysendingHTTPresponsemessages.
HTTPmakesuseoftheUniformResourceIdentifier(URI)toidentifyagivenresourceandtoestablishaconnection.
Oncetheconnectionisestablished,HTTPmessagesarepassedinaformatsimilartothatusedbytheInternetmail[RFC5322]andtheMultipurposeInternetMailExtensions(MIME)[RFC2045].
Thesemessagesincluderequestsfromclienttoserverandresponsesfromservertoclientwhichwillhavethefollowingformat:HTTP-message=|;HTTP/1.
1messagesHTTPrequestsandHTTPresponsesuseagenericmessageformatofRFC822fortransferringtherequireddata.
Thisgenericmessageformatconsistsofthefollowingfouritems.
AStart-lineZeroormoreheaderfieldsfollowedbyCRLFAnemptyline(i.
e.
,alinewithnothingprecedingtheCRLF)indicatingtheendoftheheaderfieldsOptionallyamessage-bodyInthefollowingsections,wewillexplaineachoftheentitiesusedinanHTTPmessage.
3.
MESSAGESHTTP8MessageStart-LineAstart-linewillhavethefollowinggenericsyntax:start-line=Request-Line|Status-LineWewilldiscussRequest-LineandStatus-LinewhilediscussingHTTPRequestandHTTPResponsemessagesrespectively.
Fornow,let'sseetheexamplesofstartlineincaseofrequestandresponse:GET/hello.
htmHTTP/1.
1(ThisisRequest-Linesentbytheclient)HTTP/1.
1200OK(ThisisStatus-Linesentbytheserver)HeaderFieldsHTTPheaderfieldsproviderequiredinformationabouttherequestorresponse,orabouttheobjectsentinthemessagebody.
TherearefourtypesofHTTPmessageheaders:General-header:Theseheaderfieldshavegeneralapplicabilityforbothrequestandresponsemessages.
Request-header:Theseheaderfieldshaveapplicabilityonlyforrequestmessages.
Response-header:Theseheaderfieldshaveapplicabilityonlyforresponsemessages.
Entity-header:Theseheaderfieldsdefinemeta-informationabouttheentity-bodyor,ifnobodyispresent,abouttheresourceidentifiedbytherequest.
Alltheabove-mentionedheadersfollowthesamegenericformatandeachoftheheaderfieldconsistsofanamefollowedbyacolon(:)andthefieldvalueasfollows:message-header=field-name":"[field-value]Followingaretheexamplesofvariousheaderfields:User-Agent:curl/7.
16.
3libcurl/7.
16.
3OpenSSL/0.
9.
7lzlib/1.
2.
3Host:www.
example.
comAccept-Language:en,miDate:Mon,27Jul200912:28:53GMTHTTP9Server:ApacheLast-Modified:Wed,22Jul200919:15:56GMTETag:"34aa387-d-1568eb00"Accept-Ranges:bytesContent-Length:51Vary:Accept-EncodingContent-Type:text/plainMessageBodyThemessagebodypartisoptionalforanHTTPmessagebutifitisavailable,thenitisusedtocarrytheentity-bodyassociatedwiththerequestorresponse.
Ifentitybodyisassociated,thenusuallyContent-TypeandContent-Lengthheaderslinesspecifythenatureofthebodyassociated.
AmessagebodyistheonewhichcarriestheactualHTTPrequestdata(includingformdataanduploaded,etc.
)andHTTPresponsedatafromtheserver(includingfiles,images,etc.
).
Shownbelowisthesimplecontentofamessagebody:Hello,World!
HTTP10AnHTTPclientsendsanHTTPrequesttoaserverintheformofarequestmessagewhichincludesthefollowingformat:ARequest-lineZeroormoreheader(General|Request|Entity)fieldsfollowedbyCRLFAnemptyline(i.
e.
,alinewithnothingprecedingtheCRLF)indicatingtheendoftheheaderfieldsOptionallyamessage-bodyThefollowingsectionsexplaineachoftheentitiesusedinanHTTPrequestmessage.
Request-LineTheRequest-Linebeginswithamethodtoken,followedbytheRequest-URIandtheprotocolversion,andendingwithCRLF.
TheelementsareseparatedbyspaceSPcharacters.
Request-Line=MethodSPRequest-URISPHTTP-VersionCRLFLet'sdiscusseachofthepartsmentionedintheRequest-Line.
RequestMethodTherequestmethodindicatesthemethodtobeperformedontheresourceidentifiedbythegivenRequest-URI.
Themethodiscase-sensitiveandshouldalwaysbementionedinuppercase.
ThefollowingtablelistsallthesupportedmethodsinHTTP/1.
1.
4.
REQUESTSHTTP11EndofebookpreviewIfyoulikedwhatyousaw…Buyitfromourstore@https://store.
tutorialspoint.
com
从介绍看啊,新增的HostYun 俄罗斯机房采用的是双向CN2线路,其他的像香港和日本机房,均为国内直连线路,访问质量不错。HostYun商家通用九折优惠码:HostYun内存CPUSSD流量带宽价格(原价)购买地址1G1核10G300G/月200M28元/月购买链接1G1核10G500G/月200M38元/月购买链接1G1核20G900G/月200M68元/月购买链接2G1核30G1500G/月...
需要提前声明的是有网友反馈到,PacificRack 商家是不支持DD安装Windows系统的,他有安装后导致服务器被封的问题。确实有一些服务商是不允许的,我们尽可能的在服务商选择可以直接安装Windows系统套餐,毕竟DD安装的Win系统在使用上实际上也不够体验好。在前面有提到夏季促销的"PacificRack夏季促销PR-M系列和多IP站群VPS主机 年付低至19美元"有提到年付12美元的洛杉...
Virmach商家我们是不是比较熟悉?速度一般,但是人家价格低,而且机房是比较多的。早年的时候有帮助一个有做外贸也许需要多个机房且便宜服务商的时候接触到这个商家,有曾经帮助够买过上百台这样的低价机器。这里需要提醒的,便宜但是速度一般,尤其是中文业务速度确实不快,如果是外贸业务,那肯定是没有问题。这几天,我们有看到Virmach推出了夏季优惠促销,VPS首年8折,最低年付仅7.2美元,多机房可选,如...
acceptencoding为你推荐
单击media大学生就业信息获取与信息分析speakingphp重要产品信息指南支持ipad我研制千万亿次超级电脑支持ipadeaccelerator使用apmsevr中eAccelerator显示NO是什么问题tcpip上的netbiostcp 协议里的 netbios . 在哪,找不到google中国地图谷歌退出中国,地图要是关了就太可惜了!手机谷歌地图还能用吗?
jsp虚拟空间 百度域名 域名出售 抗投诉vps主机 二级域名申请 阿里云搜索 cpanel 哈喽图床 火车票抢票攻略 天猫双十一抢红包 新站长网 镇江联通宽带 租空间 免费smtp服务器 牛人与腾讯客服对话 最好的qq空间 raid10 台湾google qq金券 免费个人主页 更多