您的位置:首页 > 理论基础 > 计算机网络

web_get_int_property(HTTP_INFO_RETURN_CODE)详解(原创)

2011-03-11 16:51 477 查看
近期做一个网站的性能测试,意图想检查每个请求都正常返回。用了web_get_int_property(HTTP_INFO_RETURN_CODE)方法

发现了一些奇怪的现象:

lr_start_transaction("高考政策");

web_url("ZhengCe",
"URL=http://content.21edu.com/GaoKao/XinWen/ZhengCe",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://content.21edu.com/",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"Url=/Template/21Edu/BinaryResource/Theme/21edu.theme/Images/bg_list_left.gif", ENDITEM,
"Url=/Template/21Edu/BinaryResource/Theme/21edu.theme/images/icon.gif", ENDITEM,
LAST);

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200){
lr_end_transaction("高考政策", LR_PASS);
}
else
{
lr_end_transaction("高考政策", LR_FAIL);

}

/*高考动态*/

lr_think_time(5);
lr_start_transaction("高考动态");
web_url("DongTai",
"URL=http://content.21edu.com/GaoKao/XinWen/DongTai",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://content.21edu.com/GaoKao/XinWen/ZhengCe",
"Snapshot=t3.inf",
"Mode=HTML",
LAST);
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200){
lr_end_transaction("高考动态", LR_PASS);
}
else
{
lr_end_transaction("高考动态", LR_FAIL);

}

允许结果:

Action.c(62): Notify: Transaction "高考政策" started.
Action.c(64): Resource "http://passport.xueda.com/Scripts/passport.logon.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://images.21edu.com/passport/passport.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Found resource "http://content.21edu.com/Template/21Edu/LayoutTemplate/head.css" in HTML "http://content.21edu.com/GaoKao/XinWen/ZhengCe" [MsgId: MMSG-26659]
Action.c(64): Resource "http://www.21edu.com/scripts/400_phone.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/head.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/index.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/menu.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/pagination.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/picturn.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/tanchu.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/aaaaaaaaajquery.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/autoscroll_pack.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/cityschool.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/easySlider.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/jquery.pagination.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Downloading resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/Images/bg_list_left.gif" (specified by argument number 10) [MsgId: MMSG-26577]
Action.c(64): Downloading resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/images/icon.gif" (specified by argument number 12) [MsgId: MMSG-26577]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/scroller.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/study.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/tabClick.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/texiao.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://images.21edu.com/www/images/logo.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://images.21edu.com/www/images/icon_jt_downhead.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://images.21edu.com/www/js/location_mono.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://images.21edu.com/content/images/bj/ad/gaosan.jpg" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Resource "http://stat.xueda.com/phpstat/count/abceffgh/abceffgh.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Warning -26627: HTTP Status-Code=404 (Not Found) for "http://content.21edu.com/Template/21Edu/LayoutTemplate/head.css" [MsgId: MWAR-26627]
Action.c(64): web_url("ZhengCe") highest severity level was "warning", 58846 body bytes, 1128 header bytes [MsgId: MMSG-26388]
Action.c(77): web_get_int_property was successful [MsgId: MMSG-26392]
Action.c(79): Notify: Transaction "高考政策" ended with "Pass" status (Duration: 0.8926 Wasted Time: 0.0107).
Action.c(90): Notify: Transaction "高考动态" started.
Action.c(91): Resource "http://passport.xueda.com/Scripts/passport.logon.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://images.21edu.com/passport/passport.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Found resource "http://content.21edu.com/Template/21Edu/LayoutTemplate/head.css" in HTML "http://content.21edu.com/GaoKao/XinWen/DongTai" [MsgId: MMSG-26659]
Action.c(91): Resource "http://www.21edu.com/scripts/400_phone.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/head.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/index.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/menu.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/pagination.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/picturn.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Theme/21edu.theme/css/tanchu.css" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/aaaaaaaaajquery.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/autoscroll_pack.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/cityschool.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/easySlider.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/jquery.pagination.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/scroller.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/study.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/tabClick.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://content.21edu.com/Template/21Edu/BinaryResource/Javascript/texiao.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://images.21edu.com/www/images/logo.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://images.21edu.com/www/images/icon_jt_downhead.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://images.21edu.com/www/js/location_mono.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://images.21edu.com/content/images/bj/ad/gaosan.jpg" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Resource "http://stat.xueda.com/phpstat/count/abceffgh/abceffgh.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(91): Warning -26627: HTTP Status-Code=404 (Not Found) for "http://content.21edu.com/Template/21Edu/LayoutTemplate/head.css" [MsgId: MWAR-26627]
Action.c(91): web_url("DongTai") highest severity level was "warning", 26860 body bytes, 520 header bytes [MsgId: MMSG-26388]
Action.c(100): web_get_int_property was successful [MsgId: MMSG-26392]
Action.c(106): Notify: Transaction "高考动态" ended with "Fail" status (Duration: 1.0974 Wasted Time: 0.0044).

两个web_url请求中服务器返回结果中都有HTTP Status-Code=404但是从事务结果看 前面一个是成功,后面一个是失败的。(纳闷吧)

接下来吧 上面代码第一个web_url修改下

lr_start_transaction("高考政策");

web_url("ZhengCe",
"URL=http://content.21edu.com/GaoKao/XinWen/ZhengCe",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://content.21edu.com/",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);

//把请求附属资源去掉

//EXTRARES,
//"Url=/Template/21Edu/BinaryResource/Theme/21edu.theme/Images/bg_list_left.gif", ENDITEM,
//"Url=/Template/21Edu/BinaryResource/Theme/21edu.theme/images/icon.gif", ENDITEM,

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if(HttpRetCode==200){
lr_end_transaction("高考政策", LR_PASS);
}
else
{
lr_end_transaction("高考政策", LR_FAIL);

}

看运行结果:

Action.c(64): Resource "http://stat.xueda.com/phpstat/count/abceffgh/abceffgh.js" is in the cache already and will not be downloaded again [MsgId: MMSG-26655]
Action.c(64): Warning -26627: HTTP Status-Code=404 (Not Found) for "http://content.21edu.com/Template/21Edu/LayoutTemplate/head.css" [MsgId: MWAR-26627]
Action.c(64): web_url("ZhengCe") highest severity level was "warning", 26896 body bytes, 520 header bytes [MsgId: MMSG-26388]
Action.c(73): web_get_int_property was successful [MsgId: MMSG-26392]
Action.c(83): Notify: Transaction "高考政策" ended with "Fail" status (Duration: 0.9543 Wasted Time: 0.0040).

这次跟第二个事务一样 事务失败。

这个方法 如果事务里头包含多个请求,建议不要用,因为他返回的值 是最后一个接收到响应头里的状态码。

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE)

Note:
The web_get_int_property function only captures the last status code that was received. If there is a redirection in between, it is not reflected. To get all of the responses, you can use the web_reg_save_param function with:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: