loadrunner模擬文件下載

Action()
{
         int flen;
         long filedes;
         char file[1024]="\0";
         char fuzhi[1024]="\0";
         char * chNumber=fuzhi;

         chNumber=lr_eval_string("{NewParam}");
         strcat(file,"c:\\policyNo_");
         strcat(file,chNumber);
         strcat(file,".txt");
         web_set_max_html_param_len("20000000");
         web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=BODY", LAST);

    lr_start_transaction("保單下載");

	web_url("epolicyDownload.do", 
		"URL=http://11.0.71.211:9001/web/epolicy/epolicyDownload.do?orderNo={NewParam_orderNo}", 
		"Resource=1", 
		"RecContentType=application/octet-stream", 
		"Referer=http://11.0.71.211:9001/web/web/default.jsp", 
		"Snapshot=t88.inf", 
		LAST);

         int flen;
		 unsigned int flen2;
         long filedes;
         char file[1024]="\0";
         char fuzhi[1024]="\0";
         char * chNumber=fuzhi;

         chNumber=lr_eval_string("{NewParam}");

         strcat(file,"c:\\policyNo_");
         strcat(file,chNumber);
         strcat(file,".txt");
		 unsigned int recvlen;//定義一個無符號的變量
         long policyfile_stream;
         web_set_max_html_param_len("20000000");
         web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=BODY", LAST);
      //獲取響應中的文件長度
         flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
		 flen2 = lr_eval_string("{fcontent}"); 
     if(flen > 0){  
         if((filedes = fopen(file, "wb")) == NULL){
           lr_output_message("Open File Failed!");
           return -1;
          }
          fprintf(policyfile_bytes,"%s",flen2);
          fclose(policyfile_bytes);        
	    lr_end_transaction("保單下載", LR_PASS);
    }else{       
	    lr_end_transaction("保單下載", LR_FAIL);
	}
	return 0;
}
相關文章
相關標籤/搜索