The Web_custom_request of LoadRunner function

Source: Internet
Author: User


definition: allows users to customize HTTP requests in any way that is supported by HTTP
function form: web_custom_request (const char *requestname,
[Extrares,,] last);



Example 1:body can use the properties of the demo



Web_custom_request (...
") Bodyunicode=reprice "
" bodybinary=\\x08\\x00\\xcc\\x02\\x00\\x00 "" body=.\r\n ""
-dxjjtbw/(. tp?eg:ch /6--\r\n ", last
);


Note: In the above code, 3 parameters are used to divide the request body, one is Unicode, one is binary, and the last is a regular string. The final request body is the value that these 3 parameters are concatenated in the order in which they are in the function. There is also a seldom used parameter, Binary. It can also describe the binary request body, but only one request body parameter is allowed in the function. All the request bodies are ASCII characters, ending with null.


Example 2: In the following recorded script, the user starts recording from http://lazarus/html/forms/file.html. When the user submits his request to you, Vugen inserts the Web_add_header function, and then calls the Web_custom_request function.



Web_url ("file.html", "url=http://lazarus/html/forms/file.html", 
    "Targetframe=_top", last); 
Web_add_header ("Content–type", 
"Multipart/form–data; boundary=–––––––––––––––––––––––––––292742461228954"); 
Web_custom_request ("Post_query.exe", "Method=post", 
    "Url=http://lazarus/cgi–bin/post_query.exe", 
    "Body= –––––––––––––––––––––––––––––292742461228954\r\ncontent–disp " 
    " Osition:form–data; name=\ "Entry\" \r\n\r\ ntext\r\n–––––––––– "" –––––––––––––––––––292742461228954\r\ncontent–disposition:f "" 
    ––––––––––– 292742461228954––\r\n ", 
    " Targetframe= ", last 
    );


Example 3:raw Body usage Demo


Char *abc= .../* Pointer to the raw data * 
/Web_custom_request ("Stepname", 
"Url=http://some.url", 
" Method=post ", 
Raw_body_start, 
" abc ", 
3, 
raw_body_end, 


Note: In an app, even if you set the length of the data to 0, the pointer must also have a value and cannot be empty. In "Binary=1", you cannot use the syntax above to pass raw data. Data in the data buffer cannot be parameterized. That is, any parameter in the buffer (for example, "{Myparam}") cannot be correctly substituted for the corresponding value, but will only be sent in literal values.



Example 4: Using binary code in the Body property


You can use the following format to add a binary string to the "Body" property of the Web_custom_request function.



\X[CHAR1][CHAR2]



The hexadecimal value is represented by a 2-character [char1][char2].



For example: \x24 represents 16*2+4=36, which represents the "$" symbol, and \x2b represents the "+" symbol.



If it is less than 2 characters and is not a valid hexadecimal character, Vugen is treated as ASCII text. So be aware that for hexadecimal less than 2 characters, you need to fill 0 in front. For example, "\X2" is an invalid hexadecimal string and requires an edge of "\x02".



Note that the binary value appears in the script as "\x", which means that there are 2 backslashes before "X". This is determined by the escape syntax of the C language. However, when you use Vugen to generate the Web_custom_request function, you only need to enter a backslash.



If you use parameterization in Web_custom_request, you only need to include a backslash when defining the parameter because the syntax conversion of C is not considered when the parameter is replaced.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.