簡體   English   中英

HTTP / 1.1 401未經授權在LoadRunner的響應標頭中進行GET請求

[英]HTTP/1.1 401 Unauthorized in Response Headers in Load runner for GET Requests

我是LoadRunner的新手,播放腳本時面臨問題

LR 12.50

操作系統Windows 7 SP2

協議是移動HTTP / HTML

記錄方式為代理

讓我解釋一下我的情況

執行以下功能時:

  web_custom_request("authenticate", 

        "URL=https://ws-xx.xxx.com/tcs/rest/authenticate?include=user,company",     
        "Method=POST", 
        "Resource=0", 
        "RecContentType=application/json", 
        "Referer=", 
        "Snapshot=t1.inf", 
        "Mode=HTTP", 
        "EncType=application/json",
        "Body={\"password\":\"xxx\",\"username\":\"xxx\",\"version\":\"1.0.40\"}", 
        LAST);

對於上述POST方法,正在獲得如下響應

   HTTP/1.1 200 OK\r\n
   Date: Tue, 13 Oct 2015 19:19:21 GMT\r\n
   Server: Apache-Coyote/1.1\r\n
   Content-Type: application/json\r\n
   Set-Cookie: dtCookie=DBE9311E44E5C47902702DC762030583|TXlBcHB8MQ; Path=/;
   Domain=.xxx.com\r\n    
   Connection: close\r\n
   Transfer-Encoding: chunked\r\n

很好,現在第二個自定義請求如下所示

  web_custom_request("profiles", 
        "URL=https://ws-test.xxx.com/tcs/rest/profiles", 
        "Method=GET", 
        "Resource=1", 
        "RecContentType=application/json", 
        "Referer=", 
        "Snapshot=t2.inf", 
        LAST);

對於重播日志中的上述GET請求,正在獲取:

401未經授權的錯誤。

 GET /tcs/rest/profiles HTTP/1.1\r\n

     User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)\r\n

    Accept: */*\r\n

    Connection: Keep-Alive\r\n

     Host: ws-test.xxx.com\r\n

   Cookie: dtCookie=DBE9311E44E5C47902702DC762030583|TXlBcHB8MQ\r\n
\r\n
 t=5921ms: 172-byte response headers for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)

    HTTP/1.1 401 Unauthorized\r\n

   Date: Tue, 13 Oct 2015 19:19:22 GMT\r\n

   Server: Apache-Coyote/1.1\r\n

   Content-Type: application/json\r\n

    Connection: close\r\n

    Transfer-Encoding: chunked\r\n
   \r\n

t=5922ms: 4-byte chunked response overhead for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)
    8b\r\n

 t=5923ms: 139-byte chunked response body for "https://ws-test.xxx.com/tcs/rest/profiles" (RelFrameId=1, Internal ID=2)
     {"errors":[{"message":"Authentication required to access endpoint","status":"401","code":"



 NotAuthenticated","header":"Not Authenticated"}]}

我引用了此鏈接

從上面的自定義請求,我的理解是登錄成功,但是下一個后續請求失敗。

我使用過web_cleanup_cookies()函數,但沒有解決問題。

我嘗試使用以下功能捕獲Cookie ID

web_reg_save_param("COOKIE_ID",
                        "LR= Cookie: dtCookie=" ,
                        "RB= |TXlBcHB8MQ\r\n",
                        "Ord=All",
                        "RelFrameId=1",
                        "Search=All",
                        LAST);

web_add_header("Cookie",lr_eval_string("{COOKIE_ID}"));

現在的問題是,在有腳本的情況下將參數“ COOKIE_ID”放在我的腳本中的位置

腳本中沒有COOKIE_ID的值?

如何處理這個問題? 有人能幫我嗎?

請在腳本下方添加以下標題

web_set_sockets_option("SSL_VERSION","TLS");
web_set_user("username", "password", "domain:portno" );
web_set_sockets_option("INITIAL_BASIC_AUTH","1");
  1. 在Vugen中,選擇快照視圖並比較記錄請求和重播請求,懷疑重播請求中可能缺少標題。
  2. 如果僅更改cookie,則可以使用web_add_cookie函數將其添加。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM