Action function -web_custom_request

web_custom_request("get_login",
                       "URL=http://10.1.102.75:8000/login?user=Milton&pwd=Loveyp",
                       "Method=GET",
                       "Resource=0",
                       "Mode=HTML",
                       "RecContentType=application/json",
                       LAST );
URL-   request address 

Method - Request method GET or POST. 

TargetFrame: contains the current link or resource frame name 

EncType - encoding type, specify the Content -Type, such as " text / HTML " , " the Application / json " and so on, will rewrite web_add_ [auto_] header defined Content- the Type. 

RecContentType - in response to the first encoding type (the Content-the Type) EG, text / HTML, file application / X-JavaScript. 

The Referer: pages referenced this page 

Body - the request body, different applications, the request body respectively Body, BodyBinary or BodyUnicode parameter to pass 

Raw body: request message bodies indicated with the pointer to the data in the form of 

resource - indicates whether the resource URL. 1 is; 0 not. After setting this parameter, RecContentType parameter is ignored.
" Resource = 1 ": Success means that the current operation and location of the script or not has little to do. If an error occurs while downloading resources, as warnings rather than errors are handled; 

whether the URL has been downloaded by "the Run - -Time Setting the Download-Browser Emulation NON- impact HTML resources" for this option. Response information of this operation is not as HTML to parse.
" Resource = 0 " : indicates that this URL is important, not affected by the request to send (RTS), will parse it when needed. 

ResourceByteLimit: the size of the resource constraints 

Snapshot: to name a snapshot .inf extension will be applied in the iteration 

Mode - record levels:. HTML or HTTP 

UserAgent - User Agent, which is the name of a HTTP header that identifies the application , usually a web browser, it presents the interactive user and the server.

This function will create an HTTP client request, it supports all the HTTP request methods protocol. By default, the web request only when other functions can not be interpreted application, with which only the LoadRunner creation request function, and this function and other functions normally with the application, such as the first function of using the additive HHTTP web_add_header request message header, and then use this function sends the client request and the like.

Action()
{  
    //GET 请求
    web_custom_request("get_login",
                       "URL=http://10.1.102.75:8000/login?user=Milton&pwd=Loveyp",
                       "Method=GET",
                       "Resource=0",
                       "Mode=HTML",
                       "RecContentType=application/json",
                       LAST );
 
    //POST 请求提交form数据
    web_custom_request("post_form_login",
                       "URL=http://10.1.102.75:8000/login",
                       "Method=POST",
                       "Resource=0",
                       "Mode=HTML",
                       "Body=user=Milton&pwd=Loveyp",
                       LAST );
    //POST 请求提交json数据
    web_custom_request("post_json_login",
                       "URL=http://10.1.102.75:8000/json_login",
                       "Method=POST",
                       "Resource=0",
                       "Mode=HTML",
                       "EncType=application/json",
                       "Body={\"user\":\"Milton\",\"pwd\":\"Loveyp\"}",
                       LAST );
 
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/lvchengda/p/12626018.html