HTTP Request.docx
- 文档编号:5940581
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:16
- 大小:22.40KB
HTTP Request.docx
《HTTP Request.docx》由会员分享,可在线阅读,更多相关《HTTP Request.docx(16页珍藏版)》请在冰豆网上搜索。
HTTPRequest
HTTPRequest
ThissamplerletsyousendanHTTP/HTTPSrequesttoawebserver.ItalsoletsyoucontrolwhetherornotJMeterparsesHTMLfilesforimagesandotherembeddedresourcesandsendsHTTPrequeststoretrievethem.Thefollowingtypesofembeddedresourceareretrieved:
∙images
∙applets
∙stylesheets
∙externalscripts
∙frames,iframes
∙backgroundimages(body,table,TD,TR)
∙backgroundsound
Thedefaultparserishtmlparser.Thiscanbechangedbyusingtheproperty"htmlparser.classname"-seejmeter.propertiesfordetails.
Ifyouaregoingtosendmultiplerequeststothesamewebserver,considerusinganHTTPRequestDefaultsConfigurationElementsoyoudonothavetoenterthesameinformationforeachHTTPRequest.
Or,insteadofmanuallyaddingHTTPRequests,youmaywanttouseJMeter'sHTTP(S)TestScriptRecordertocreatethem.ThiscansaveyoutimeifyouhavealotofHTTPrequestsorrequestswithmanyparameters.
Therearetwodifferentscreensfordefiningthesamplers:
∙AJP/1.3Sampler-usestheTomcatmod_jkprotocol(allowstestingofTomcatinAJPmodewithoutneedingApachehttpd)TheAJPSamplerdoesnotsupportmultiplefileupload;onlythefirstfilewillbeused.
∙HTTPRequest-thishasanimplementationdrop-downbox,whichselectstheHTTPprotocolimplementationtobeused:
oJava-usestheHTTPimplementationprovidedbytheJVM.ThishassomelimitationsincomparisonwiththeHttpClientimplementations-seebelow.
oHTTPClient3.1-usesApacheCommonsHttpClient3.1.Thisisnolongerbeingdeveloped,andsupportforthismaybedroppedinafutureJMeterrelease.
oHTTPClient4-usesApacheHttpComponentsHttpClient4.x.
oBlankValue-doesnotsetimplementationonHTTPSamplers,soreliesonHTTPRequestDefaultsifpresentoronjmeter.httpsamplerpropertydefinedinjmeter.properties
TheJavaHTTPimplementationhassomelimitations:
∙Thereisnocontroloverhowconnectionsarere-used.WhenaconnectionisreleasedbyJMeter,itmayormaynotbere-usedbythesamethread.
∙TheAPIisbestsuitedtosingle-threadedusage-varioussettingsaredefinedviasystemproperties,andthereforeapplytoallconnections.
∙ThereisabuginthehandlingofHTTPSviaaProxy(theCONNECTisnothandledcorrectly).SeeJavabugs6226610and6208335.
∙Itdoesnotsupportvirtualhosts.
∙Itdoesnotsupportthefollowingmethods:
COPY,LOCK,MKCOL,MOVE,PATCH,PROPFIND,PROPPATCH,UNLOCK.
∙ItdoesnotsupportclientbasedcertificatetestingwithKeystoreConfig.
Note:
theFILEprotocolisintendedfortestingpurposesonly.ItishandledbythesamecoderegardlessofwhichHTTPSamplerisused.
Iftherequestrequiresserverorproxyloginauthorization(i.e.whereabrowserwouldcreateapop-updialogbox),youwillalsohavetoaddanHTTPAuthorizationManagerConfigurationElement.Fornormallogins(i.e.wheretheuserenterslogininformationinaform),youwillneedtoworkoutwhattheformsubmitbuttondoes,andcreateanHTTPrequestwiththeappropriatemethod(usuallyPOST)andtheappropriateparametersfromtheformdefinition.IfthepageusesHTTP,youcanusetheJMeterProxytocapturetheloginsequence.
InversionsofJMeterupto2.2,onlyasingleSSLcontextwasusedforallthreadsandsamplers.Thisdidnotgeneratetheproperloadformultipleusers.AseparateSSLcontextisnowusedforeachthread.Toreverttotheoriginalbehaviour,settheJMeterproperty:
https.sessioncontext.shared=true
Bydefault,theSSLcontextisretainedforthedurationofthetest.InversionsofJMeterfrom2.5.1,theSSLsessioncanbeoptionallyresetforeachtestiteration.Toenablethis,settheJMeterproperty:
https.use.cached.ssl.context=false
Note:
thisdoesnotapplytotheJavaHTTPimplementation.
JMeterdefaultstotheSSLprotocollevelTLS.Iftheserverneedsadifferentlevel,e.g.SSLv3,changetheJMeterproperty,forexample:
https.default.protocol=SSLv3
JMeteralsoallowsonetoenableadditionalprotocols,bychangingthepropertyhttps.socket.protocols.
Iftherequestusescookies,thenyouwillalsoneedanHTTPCookieManager.YoucanaddeitheroftheseelementstotheThreadGrouportheHTTPRequest.IfyouhavemorethanoneHTTPRequestthatneedsauthorizationsorcookies,thenaddtheelementstotheThreadGroup.Thatway,allHTTPRequestcontrollerswillsharethesameAuthorizationManagerandCookieManagerelements.
Iftherequestusesatechniquecalled"URLRewriting"tomaintainsessions,thenseesection6.1HandlingUserSessionsWithURLRewritingforadditionalconfigurationsteps.
ControlPanel
Parameters
Attribute
Description
Required
Name
Descriptivenameforthissamplerthatisshowninthetree.
No
Server
DomainnameorIPaddressofthewebserver.e.g..[Donotincludethehttp:
//prefix.]Note:
inJMeter2.5(andlater)ifthe"Host"headerisdefinedinaHeaderManager,thenthiswillbeusedasthevirtualhostname.
Yes,unlessprovidedbyHTTPRequestDefaults
Port
Portthewebserverislisteningto.Default:
80
No
ConnectTimeout
ConnectionTimeout.Numberofmillisecondstowaitforaconnectiontoopen.
No
ResponseTimeout
ResponseTimeout.Numberofmillisecondstowaitforaresponse.Notethatthisappliestoeachwaitforaresponse.Iftheserverresponseissentinseveralchunks,theoverallelapsedtimemaybelongerthanthetimeout.ADurationAssertioncanbeusedtodetectresponsesthattaketoolongtocomplete.
No
Server(proxy)
HostnameorIPaddressofaproxyservertoperformrequest.[Donotincludethehttp:
//prefix.]
No
Port
Porttheproxyserverislisteningto.
No,unlessproxyhostnameisspecified
Username
(Optional)usernameforproxyserver.
No
Password
(Optional)passwordforproxyserver.(N.B.thisisstoredunencryptedinthetestplan)
No
Implementation
Java,HttpClient3.1,HttpClient4.Ifnotspecified(andnotdefinedbyHTTPRequestDefaults),thedefaultdependsonthevalueoftheJMeterpropertyjmeter.httpsampler,failingthat,theHttpClient4implementationisused.
No
Protocol
HTTP,HTTPSorFILE.Default:
HTTP
No
Method
GET,POST,HEAD,TRACE,OPTIONS,PUT,DELETE,PATCH(notsupportedforJAVAimplementation).WithHttpClient4,thefollowingmethodsrelatedtoWebDavarealsoallowed:
COPY,LOCK,MKCOL,MOVE,PROPFIND,PROPPATCH,UNLOCK.
Yes
ContentEncoding
Contentencodingtobeused(forPOST,PUT,PATCHandFILE).Thisthethecharacterencodingtobeused,andisnotrelatedtotheContent-EncodingHTTPheader.
No
RedirectAutomatically
Setstheunderlyinghttpprotocolhandlertoautomaticallyfollowredirects,sotheyarenotseenbyJMeter,andthuswillnotappearassamples.ShouldonlybeusedforGETandHEADrequests.TheHttpClientsamplerwillrejectattemptstouseitforPOSTorPUT.Warning:
seebelowforinformationoncookieandheaderhandling.
No
FollowRedirects
Thisonlyhasanyeffectif"RedirectAutomatically"isnotenabled.Ifset,theJMetersamplerwillcheckiftheresponseisaredirectandfollowitifso.Theinitialredirectandfurtherresponseswillappearasadditionalsamples.TheURLanddatafieldsoftheparentsamplewillbetakenfromthefinal(non-redirected)sample,buttheparentbytecountandelapsedtimeincludeallsamples.Thelatencyistakenfromtheinitialresponse(versionsofJMeterafter2.3.4-previouslyitwaszero).NotethattheHttpClientsamplermaylogthefollowingmessage:
"RedirectrequestedbutfollowRedirectsisdisabled"
Thiscanbeignored.
Inversionsafter2.3.4,JMeterwillcollapsepathsoftheform'/../segment'inbothabsoluteandrelativeredirectURLs.Forexamplehttp:
//host/one/../two=>http:
//host/two.Ifnecessary,thisbehaviourcanbesuppressedbysettingtheJMeterpropertyhttpsampler.redirect.removeslashdotdot=false
No
UseKeepAlive
JMetersetstheConnection:
keep-aliveheader.ThisdoesnotworkproperlywiththedefaultHTTPimplementation,asconnectionre-useisnotunderuser-control.ItdoesworkwiththeApacheHttpComponentsHttpClientimplementations.
No
Usemultipart/form-dataforHTTPPOST
Useamultipart/form-dataorapplication/x-www-form-urlencodedpostrequest
No
Browser-compatibleheaders
Whenusingmultipart/form-data,thissuppressestheContent-TypeandContent-Transfer-Encodingheaders;onlytheContent-Dispositionheaderissent.
No
Path
Thepathtoresource(forexample,/servlets/myServlet).Iftheresourcerequiresquerystringparameters,addthembelowinthe"SendParametersWiththeRequest"section.Asaspecialcase,ifthepathstartswith"http:
//"or"https:
//"thenthisisusedasthefullURL.Inthiscase,theserver,portandprotocolfieldsareignored;parametersarealsoignoredforGETandDELETEmethods.Alsopleasenotethatthepathisnotencoded-apartfromreplacingspaceswith%20-sounsafecharactersmayneedtobeencodedtoavoiderrorssuchasURISyntaxException.
Yes
SendParametersWiththeRequest
Thequerystringwillbegeneratedfromthelistofparametersyouprovide.Eachparameterhasanameandvalue,theoptionstoencodetheparameter,andanoptiontoincludeorexcludeanequalssign(someapplicationsdon'texpectanequalswhenthevalueistheemptystring).Thequerystringwillbegeneratedinthecorrectfashion,dependingonthechoiceof"Method"youmade(ieifyouchoseGETorDELETE,thequerystringwillbeappendedtotheURL,ifPOSTorPUT,thenitwillbesentseparately).Also,ifyouaresendingafileusingamultipartform,thequerystringwillbecreatedusingthemultipartformspecifications.Seebelowforsom
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- HTTP Request
![提示](https://static.bdocx.com/images/bang_tan.gif)