web_get_int_property
Returns specific information about the previous HTTP request.
C Language
int web_get_int_property( const int HttpInfoType);
Java Language
long object.get_int_property( int HttpInfoType );
Argument | Description |
|---|---|
object | An expression evaluating to an object of type WebApi. Usually web for Java. See also
Function and Constant Prefixes. |
HttpInfoType | One of the options listed below. |
Parameterization
Parameterization is not applicable to this function.
General Information and Return Values
The web_get_int_property function returns specific information about the previous HTTP request.
The meaning of the return value depends on the HttpInfoType argument. HttpInfoType can be any of the following options. The first constant in each pair (HTTP_*) is for C, the second (object.HTTP_*) is for object oriented languages.
HTTP_INFO_LAST_SOCKET_ERROR or object.HTTP_INFO_LAST_SOCKET_ERROR
The last socket error. On timeout, web_get_int_property(HTTP_INFO_LAST_SOCKET_ERROR) returns 10060. For other errors, see the socket documentation.
HTTP_INFO_RETURN_CODE or object.HTTP_INFO_RETURN_CODE
The return code in HTTP response header.
HTTP_INFO_DOWNLOAD_SIZE or object.HTTP_INFO_DOWNLOAD_SIZE
The size (in bytes) of the last download, including the header, body, and communications overhead (for example, NTLM negotiation).
HTTP_INFO_DOWNLOAD_TIME or object.HTTP_INFO_DOWNLOAD_TIME
The time in (milliseconds) of the last download.
HTTP_INFO_TOTAL_REQUEST_STAT or object.HTTP_INFO_TOTAL_REQUEST_STAT
Returns the accumulated size of all headers and bodies since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_REQUEST_STAT.
HTTP_INFO_TOTAL_RESPONSE_STAT or object.HTTP_INFO_TOTAL_RESPONSE_STAT
Returns the accumulated size, including header and body, of all responses since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_RESPONSE_STAT
This function is supported for all web scripts.
C Example
The following example uses the web_get_int_property function to check if the script successfully accessed the my_home home page.
{
int HttpRetCode;
web_url("my_home",
"URL=http://my_home",
"TargetFrame=_TOP",
LAST );HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (HttpRetCode == 200)
lr_log_message("The script successfully accessed the My_home home page");
else
lr_log_message("The script failed to access the My_home home page ");
}The script successfully accessed the My_home home page
The following example uses the web_get_int_property function to return the size (in bytes) of a URL and a PDF download.
Action()
{
int i;
int j;
lr_start_transaction("DownloadUrL");
web_url("club_registration.html",
"URL=https://secure.funclubreg.com/funclub.com/registration_form.html",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=images/inside/all_about_club.gif", ENDITEM,
"Url=images/inside/whats_new.gif", ENDITEM,
"Url=images/inside/club_news.gif", ENDITEM,
"Url=images/inside/club_events_roll.gif", ENDITEM,
"Url=findclubs.swf", ENDITEM,
LAST );/* Code the web_get_int_property function after the request (such as web_url or web_link) which starts the download. */
i = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("The download size of the URL was: %d",i);
if(i > 10000)
{
lr_end_transaction("DownloadUrL", LR_PASS);
}
else
{
lr_end_transaction("DownloadUrL", LR_FAIL);
} lr_start_transaction("DownloadPDF");
web_link("PDF version",
"Text=PDF version",
"Snapshot=t2.inf",
LAST );
j = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("The download size of the PDF file was: %d",j); if(j > 10000)
{
lr_end_transaction("DownloadPDF", LR_PASS);
}
else
{
lr_end_transaction("DownloadPDF", LR_FAIL);
}
return 0;
}Example: Sample Output:
Action.c(41): The download size of the URL was: 148480
Action.c(45): Notify: Transaction "DownloadUrL" ended with "Pass" status (Duration: 13.2097).
...
...
...
Action.c(64): The download size of the PDF file was: 257381
Action.c(68): Notify: Transaction "DownloadPDF" ended with "Pass" status (Duration: 17.9892).
The following example uses the web_get_int_property function to calculate the traffic in an action, and for a single step.
Action()
{
int initial_byte_request_ct, before_submit_request_ct, after_submit_request_ct, submit_byte_request_ct, final_request_ct;
int initial_byte_response_ct, before_submit_response_ct, after_submit_response_ct, submit_byte_response_ct, final_response_ct;
initial_byte_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT);
initial_byte_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT);
web_submit_data("com.webtours.servlet.ReservationServlet",
"Action=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet?procSub=1&pg=1",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet",
"Snapshot=t7.inf",
"Mode=HTML",
ITEMDATA,
"Name=tripType", "Value=roundtrip", ENDITEM,
"Name=passCount", "Value=2", ENDITEM,
"Name=fromPort", "Value=San Francisco", ENDITEM,
"Name=fromMonth", "Value=12", ENDITEM,
"Name=fromDay", "Value=10", ENDITEM,
"Name=toPort", "Value=Acapulco", ENDITEM,
"Name=toMonth", "Value=12", ENDITEM,
"Name=toDay", "Value=14", ENDITEM,
"Name=servClass", "Value=Business", ENDITEM,
"Name=airline", "Value=Pangea Airlines", ENDITEM,
"Name=findFlights.x", "Value=63", ENDITEM,
"Name=findFlights.y", "Value=10", ENDITEM,
LAST );
before_submit_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT);
before_submit_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT);
lr_message("Before Submit:Request = %d, Response = %d",
before_submit_request_ct,before_submit_response_ct);/* Before Submit:Request = 1182, Response = 14177 */
web_submit_data("com.webtours.servlet.PurchaseServlet",
"Action=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet?procSub=1&pg=1",
"Snapshot=t9.inf",
"Mode=HTML",
ITEMDATA,
"Name=outFlight", "Value=Pangea Airlines$612$356$9:23$", ENDITEM,
"Name=inFlight", "Value=Pangea Airlines$162$364$16:43$", ENDITEM,
"Name=reserveFlights.x", "Value=61", ENDITEM,
"Name=reserveFlights.y", "Value=9", ENDITEM,
LAST ); after_submit_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT);
submit_byte_request_ct = after_submit_request_ct - before_submit_request_ct ;
after_submit_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT);
submit_byte_response_ct = after_submit_response_ct - before_submit_response_ct ;
lr_message("After Submit:Request = %d, Response = %d",
after_submit_request_ct,after_submit_response_ct);
/* After Submit:Request = 2695, Response = 58681*/
lr_message("Submit Net traffic:Request = %d, Response = %d",
submit_byte_request_ct,submit_byte_response_ct);/*Submit Net traffic:Request = 1513, Response = 44504 */
web_url("search_5",
"URL=http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;66.102.11.99;240&ie=UTF-8&oe=UTF-8&features=Rank:&q=info:http%3A%2F%2Fnewtours%2Eabc%2Ecom%2Fservlets%2Fcom%2Ewebtours%2Eservlet%2EPurchaseServlet&ch=762475275111",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t10.inf",
"Mode=HTML",
LAST );
web_submit_data("com.webtours.servlet.PurchaseServlet_2",
"Action=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet?procSub=1&pg=1",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet",
"Snapshot=t22.inf",
"Mode=HTML",
ITEMDATA,
"Name=passFirst0", "Value=Fitzwilliam", ENDITEM,
"Name=passLast0", "Value=Darcy", ENDITEM,
"Name=pass.1.meal", "Value=VGML", ENDITEM,
"Name=passFirst1", "Value=Elizabeth", ENDITEM,
"Name=passLast1", "Value=Darcy", ENDITEM,
"Name=pass.1.meal", "Value=LCML", ENDITEM,
"Name=creditCard", "Value=CB", ENDITEM,
"Name=creditnumber", "Value=123456789", ENDITEM,
"Name=cc_exp_dt_mn", "Value=01", ENDITEM,
"Name=cc_exp_dt_yr", "Value=2008", ENDITEM,
"Name=cc_frst_name", "Value=Catherine", ENDITEM,
"Name=cc_mid_name", "Value=", ENDITEM,
"Name=cc_last_name", "Value=DeBourgh", ENDITEM,
"Name=ticketLess", "Value=checkbox", ENDITEM,
"Name=billAddress1", "Value=Rosings Park", ENDITEM,
"Name=billAddress2", "Value=", ENDITEM,
"Name=billCity", "Value=Lambton", ENDITEM,
"Name=billState", "Value=Derbyshire", ENDITEM,
"Name=billZip", "Value=94089", ENDITEM,
"Name=billCountry", "Value=214", ENDITEM,
"Name=ticketLess", "Value=checkbox", ENDITEM,
"Name=delAddress1", "Value=1325 Borregas Ave.", ENDITEM,
"Name=delAddress2", "Value=", ENDITEM,
"Name=delCity", "Value=Sunnyvale", ENDITEM,
"Name=delState", "Value=CA", ENDITEM,
"Name=delZip", "Value=94089", ENDITEM,
"Name=delCountry", "Value=215", ENDITEM,
"Name=buyFlights.x", "Value=51", ENDITEM,
"Name=buyFlights.y", "Value=15", ENDITEM,
LAST ); web_url("com.webtours.servlet.SignonServlet_2",
"URL=http://newtours.abc.com/servlets/com.webtours.servlet.SignonServlet",
"Resource=0",
"RecContentType=text/html",
"Referer=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet?procSub=1&pg=1",
"Snapshot=t24.inf",
"Mode=HTML",
LAST ); web_url("search_6",
"URL=http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;216.239.59.99;701&ie=UTF-8&oe=UTF-8&features=Rank:&q=info:http%3A%2F%2Fnewtours%2Eabc%2Ecom%2Fservlets%2Fcom%2Ewebtours%2Eservlet%2ESignonServlet&ch=722304523644",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t25.inf",
"Mode=HTML",
LAST ); final_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT);
lr_message("REQUEST: Initial = %d, before submit = %d, after_submit = %d, submit size = %d, total = %d",
initial_byte_request_ct, before_submit_request_ct, after_submit_request_ct, submit_byte_request_ct, final_request_ct);
/*REQUEST: Initial = 0, before submit = 1182, after_submit = 2695, submit size = 1513, total = 7911 */ final_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT);
lr_message("RESPONSE: Initial = %d, before submit = %d, after_submit = %d, submit size = %d, total = %d",
initial_byte_response_ct, before_submit_response_ct, after_submit_response_ct, submit_byte_response_ct, final_response_ct); /* RESPONSE: Initial = 0, before submit = 14177, after_submit = 58681, submit size = 44504, total = 86444 */
return 0;
}
Sample Output:Before Submit:Request = 1846, Response = 5488
...
...
...
After Submit:Request = 3559, Response = 9273
Submit Net traffic:Request = 1713, Response = 3785
...
...
...
REQUEST: Initial = 0, before submit = 1846, after_submit = 3559, submit size = 1713, total = 8503
RESPONSE: Initial = 0, before submit = 5488, after_submit = 9273, submit size = 3785, total = 68086
Java Example
The following example uses web.get_int_property to check if the script successfully accessed the my_home home page.
try
{
int HttpRetCode;
web.url("my_home",
"URL=http://www.yahoo.com",
new String [] {"TargetFrame=_TOP", "LAST"});
// Note that the constant requires the class specification lrapi.web
HttpRetCode =
web.get_int_property( web.HTTP_INFO_RETURN_CODE );
System.out.println(HttpRetCode);
if (HttpRetCode == 200)
lr.log_message("The Vuser successfully accessed yahoo");
else
lr.log_message("The Vuser failed to access yahoo");
}
catch (Exception e) {}HTTP_INFO_RETURN_CODE = 200
HTTP_INFO_DOWNLOAD_SIZE = 53685
HTTP_INFO_DOWNLOAD_TIME = 2204

