Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LoadRunner performance Test-download File script

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Loadrunner Download File Script

Action()

{

intflen; //define an integer variable to hold the file size

longfiles; //save file handles

charfile[256]="\0"; //Save file path and file name

inttime ;

//Set the maximum number of bytes the page receives, which should be larger than the size of the download file, here 1MB

web_set_max_html_param_len("1024000");

//Use the correlation function to get the content of the downloaded file

web_reg_save_param_ex(

"ParamName=filecontent",

"LB=",

"RB=",

SEARCH_FILTERS,

"Scope=Body",

"RequestUrl=http://10.255.0.145/download.php? userId={userID}&bigmd5={userID}&offset=0",

LAST);

//download file

lr_start_transaction("download");

web_url("download",

"URL=http://10.255.0.145/download.php? userId={userID}&bigmd5={userID}&offset=0",

Resource=1",

"RecContentType=application/octet-stream",

"Referer=",

LAST);

lr_end_transaction("download",LR_AUTO);

/*web_get_int_property Returns the specific information of the previous http request, such as HTTP_INFO_DOWNLOAD_SIZE, HTTP_INFO_DOWNLOAD_TIME , HTTP_INFO_RETURN_CODE */

flen=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

lr_output_message("download file size is:%d",flen);

time=web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);

lr_output_message("download time is:%d",time);

//Write the string "E:\\FSDownload\\%d.txt" to file

sprintf(file,"E:\\FSDownload\\%d.txt",rand());

lr_output_message("saved path:%s",file);

if(flen> 0){

if((filedes= fopen(file,"wb")) == NULL){

lr_output_message("OpenFile Failed! ", lr_eval_string("{filecontent}"));

return-1;

}

//write filecontent to the file pointed to by the files pointer, write flen once at a time

fwrite(lr_eval_string("{filecontent}"),flen,1,filedes);

fclose(filedes );

}

return0;

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report