zoukankan      html  css  js  c++  java
  • loadrunner处理HTTP重定向请求

    //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=
    ", 
                    "notfound=warning", 
                    "Search=Headers", 
                    LAST); 
      
        web_reg_save_param("cTransactionName", 
                    "LB=https://Domain.com/", 
                    "RB=
    ", 
                    "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=
    ", 
                    "Search=Headers", 
                    "notfound=warning", 
                    LAST); 
      
            web_reg_save_param("cTransactionName", 
                    "LB=https://https://Domain.com/", 
                    "RB=
    ", 
                    "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

  • 相关阅读:
    SAP Spartacus 自定义Popover指令,如何实现弹出对话框自动关闭功能
    SAP Spartacus B2B 页面信息提示图标的弹出窗口显示实现逻辑
    一个好用的 SAP UI5 本地打包(build)工具,自动生成Component-preload.js
    什么是 SAP UI5 的 Component-preload.js, 什么是Minification和Ugification
    云小课 | 一个三分钟快速定制OCR应用的神器,要不?
    JavaScript实现:如何写出漂亮的条件表达式
    想做测试工程师,这7件事你必须先知道
    比物理线程都好用的C++20的协程,你会用吗?
    解读 SSDB、LevelDB 和 RocksDB 到 GaussDB(for Redis) 的迁移
    数据中心太耗电,送你一个节能神器
  • 原文地址:https://www.cnblogs.com/qmfsun/p/4947775.html
Copyright © 2011-2022 走看看