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;
    }
     
  • 相关阅读:
    DateTime.Now的精度这么高! (转)
    RC4经典加密算法VB版本代码
    反拍卖采购技术的应用
    用C#写 四舍五入函数(函数版)
    CRM(客户关系管理)
    给按钮增加属性
    用C#写 四舍五入函数(原理版)
    合并datagrid中内容相同的单元格(VB.Net)
    DataGrid删除确认及Item颜色交替
    得到目录大小
  • 原文地址:https://www.cnblogs.com/lvchengda/p/12626088.html
Copyright © 2011-2022 走看看