zoukankan      html  css  js  c++  java
  • 其他函数-web_get_int_property

    用于记录http响应的信息。这个函数在调试脚本的常用,但是在实际压力测试中请将这些注释

    使用这个函数可以获取到的信息有:
    
    1、HTTP_INFO_RETURN_CODE:返回HTTP响应码
    
    2、HTTP_INFO_DOWNLOAD_SIZE:返回页面字节数
    
    3、HTTP_INFO_DOWNLOAD_TIME:返回页面下载的时间
    Action()
    
    {
    
    int nHttpRetCode;
    
    int nHttpDownloadSize;
    
    int nHttpDownloadTime;
    
    web_set_max_html_param_len("44700"); // 默认最大长度为256
    
    web_url("try",
    
     "URL={url地址}",
    
     "Resource=0",
    
     "RecContentType=text/html",
    
     "Referer=",
    
    "Mode=HTTP",
    
    LAST);
    
    nHttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
    
    nHttpDownloadSize=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
    
    nHttpDownloadTime=web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
    
    lr_output_message("HTTP Code:%d
    ",nHttpRetCode);
    
    lr_output_message("Download Size:%d
    ",nHttpDownloadSize);
    
    lr_output_message("Download Time:%d",nHttpDownloadTime);
    
    
    return 0;
    
    }
    Action()
    {
        int size;
        int code;
        
        
     
        
        web_add_header("pid","{pi}");
        lr_output_message("%s",lr_eval_string("{pi}"));
        
        web_add_header("Content-Type","application/json");
        
        lr_think_time(2);
        lr_start_transaction("请求");
     
        lr_start_transaction("业务请求");
     
        web_custom_request("web_custom_request",
            "URL=https://app.xxxxx/xqAppServer/api/APPBizRest/queryCoupons/v1/",
            "Method=POST",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTTP",
            /* json和键值对数据格式,建议使用web_add_header方法添加Content-Type头 */
            //"EncType=application/json",
            "Body={"aesRequest": "{data}"}",
            LAST);
        code=web_get_int_property(HTTP_INFO_RETURN_CODE);
        size=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
        
        if(code==200)
        {
            lr_log_message("请求成功");
            lr_end_transaction("请求", LR_PASS);
     
            
            if(size>5000)
            {
                    lr_end_transaction("业务请求", LR_PASS);
            lr_log_message("业务处理成功");
            }
            else
            {
                lr_error_message("业务处理失败:size=%d",size);
                lr_end_transaction("业务请求", LR_FAIL);
            }
        }
        else
        {
            lr_error_message("请求失败");
            lr_end_transaction("请求", LR_FAIL);
        }
        
     
        return 0;
    }
     
  • 相关阅读:
    xxl-job docker版分布式任务
    nginx学习http_access_module模块
    nginx学习sub_filter模块
    nginx学习首页随机模块
    mysql使用命令
    laravel数据填充
    LINUX下统计代码行数
    检查字符串结尾 判断一个字符串(str)是否以指定的字符串(target)结尾。
    右边大数组中包含了4个小数组,分别找到每个小数组中的最大值,然后把它们串联起来,形成一个新数组。
    确保字符串的每个单词首字母都大写,其余部分小写。
  • 原文地址:https://www.cnblogs.com/lvchengda/p/12626088.html
Copyright © 2011-2022 走看看