loadrunner处理HTTP重定向请求

本文详细介绍了如何使用特定的API和函数实现对HTTP重定向的深度处理,包括设置最大重定向深度、保存参数、解析HTTP响应头等关键步骤。通过实例演示,帮助开发者深入理解并掌握这一技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值