首页 > Web开发 > 详细

loadrunner处理HTTP重定向请求

时间:2015-11-09 10:43:03      阅读:1274      评论:0      收藏:0      [点我收藏+]
//place this in global.h 
  
int HttpRetCode; 
int i=0; 
char depthVal[10]; 
char cTransactName[20000]; 
  
recursiveRedirect_open() 
{ 
    web_set_max_html_param_len("10000"); 
  
    web_reg_save_param("cRedirectUrl", 
                "LB=Location: ", 
                "RB=\r\n", 
                "notfound=warning", 
                "Search=Headers", 
                LAST); 
  
    web_reg_save_param("cTransactionName", 
                "LB=https://Domain.com/", 
                "RB=\r\n", 
                "Search=Headers", 
                "notfound=warning", 
                LAST); 
  
    web_reg_save_param("httpCode", 
                "LB=HTTP/1.1 ", 
                "RB= ", 
                "Search=Headers", 
                "ORD=1", 
                "notfound=warning", 
                LAST); 
} 
  
recursiveRedirect_close() 
{ 
  
    HttpRetCode = atoi(lr_eval_string("{httpCode}")); 
    lr_output_message("xReturnCode=%d",  HttpRetCode); 
  
    if(HttpRetCode == 302)//If redirect 
    { 
        i++; 
        web_reg_save_param("cRedirectUrl", 
                "LB=Location: ", 
                "RB=\r\n", 
                "Search=Headers", 
                "notfound=warning", 
                LAST); 
  
        web_reg_save_param("cTransactionName", 
                "LB=https://https://Domain.com/", 
                "RB=\r\n", 
                "Search=Headers", 
                "notfound=warning", 
                LAST); 
  
        web_reg_save_param("httpCode", 
               "LB=HTTP/1.1 ", 
               "RB= ", 
               "ORD=1", 
               "notfound=warning", 
               LAST); 
  
sprintf(cTransactName, "Redirect_depth_%d_%s", i,lr_eval_string("{cTransactionName}")); 
lr_start_transaction(cTransactName); 
web_url(cTransactName, "URL={cRedirectUrl}", "Mode=HTTP", LAST); 
lr_end_transaction(cTransactName, LR_AUTO); 
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE); 
recursiveRedirect_close(); 
  
} 
else
{ 
    return; 
}

 

 

 

//In your action file
Place this in the beginning of the action file
 
web_set_option("MaxRedirectionDepth", "0", LAST ); //This is the key
 
recursiveRedirect_open();
web_url("url_which_gets_redirected","http://sampleredirect.com/",LAST);
recursiveRedirect_close();

 

 

深圳湖北籍软件测试群 275212937

loadrunner处理HTTP重定向请求

原文:http://www.cnblogs.com/qmfsun/p/4947775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!