LoadRunner: Associating HTTP Requests

Source: Internet
Author: User

LoadRunner: Associating HTTP Requests This example analyzes loadrunner how to make an HTTP association by using a VUser script that sends and obtains server data with the Http/html protocol.  The following example includes two transactions: uploading data to the server, downloading the server data, and saving the data returned from the server through the Association for easy analysis.  1. Define variables to define variables at the top of action, otherwise you will get an error.  Code: merc_timer_handle_t Timer;  Double wastetime=0;  Char *actualbuffer;  int numberofbytes;  Char *tmp;  Char tmpcode[24]={0};  iterator int i=0;  int j = 0;  int m = 0; Mobile Char codearray[100][24]={0};  Store the mobile download code, each code is temporarily set to 24 bytes long char* code;        Short Codelen;        The length of the code that stores the mobile download short codenum;  Total code number int Retul =-1;   Upload return value//int lenul = 0;  Upload return length int retdl =-1;   Download return value int lendl = 0;    Download return length int flag = 0;  Number of compliant code//PC//char retcodeul[10]={0};  Char retcodedl[2048]={0};  char* Pcretul;  Char pccode[24]={0};  Char pccodearray[1024][24]={0};  Short pccodelen=0;  2. Save service return data after defining a variable or constant, start defining the transaction and associating it.  Code: Web_set_max_html_param_len ("2000000");//Set the page to receive the maximum number of bytes, the setting should be greater than the size of the download file//Use the correlation function to get the contents of the downloaded file, where the left and right boundaries are not defined, to get all the contents of the server response Web_reg_save_param ("Filecontent", "lb=", "rb=", "Search=body ", last), Lr_rendezvous (" re_ul_pc "), Lr_start_transaction (" ul_pc ")//pc upload Web_url (" Create "," url=10.15.1 07.112:9089/sys/userdata/create?userid={userid}&content={' group0 ': [{' Data ': ' {code1}.stk ', ' time ' : 1376904823299640},{' data ': ' {code2}.stk ', ' time ': 1376904823299647},{' data ': ' {code3}.stk ', ' time ' : 1376904823299651},{' data ': ' {code4}.stk ', ' time ': 1376904836969909}]}&filename=mystock.json&rawtype=true &accept=json "," resource=0 "," reccontenttype=text/html "," referer= "," Snapshot=t1.inf "," Mode=http ", last); PCR Etul = Lr_eval_string ("{filecontent}"), if (NULL! = strcmp (Pcretul, "{\" state\ ": 1")) lr_end_transaction ("Ul_pc", Lr_ PASS); else lr_end_transaction ("ul_pc", lr_fail); In the preceding code, the Web_reg_save_param function has an association and must be used before calling Web_url, which acts like a registration mechanism. Called the statement web_reg_save_param ("Filecontent", "lb=", "rb=", "Search=body", last); The LoadRunner automatically saves the contents of the body of the HTTP data returned by the server to the variable filecontent in the left and right boundaries (the LB-R border, the margin of the RB-starboard).  Please refer to the Help documentation for specific parameter descriptions. Filecontent is automatically assigned by the system, we only need to give it a name, we can use the variable directly later. Pcretul =Lr_eval_string ("{filecontent}"); Assigns the content extract of the variable filecontent to our custom variable Pcretul. Note the invocation form. After obtaining the server data, determine the transaction success or failure by adding your own judgment logic.

LoadRunner: Associating HTTP Requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.