LoadRunner not accepting cookies on HTTP 302 redirect

Posted on May 25th 2010 by Joel Deutscher

cookiesI recently came across a problem with trying to record a login to a website. After posting my login credentials, I received a 302 redirect that contained several Authentication cookies. Unfortunately, LoadRunner was not recognising the cookies and the subsequent page redirected me back to the login page.

As login was obviously working in the browser, I recorded a clean session using the fabulous Firebug. Now that I was able to directly compare the HTTP headers. It quickly became evident that the reason was that LoadRunner wasn’t reading the entire 302 Header. Time to pull out Firebug.

The full header in Firebug is as follows:

HTTP/1.1 302 Moved Temporarily
Server: Sun-ONE-Web-Server/6.1
Date: Thu, 04 May 2010 06:01:34 GMT
Content-Type: text/html
Content-Encoding: gzip
Vary: accept-encoding
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: https://www.headwired.com/application/home.php
Set-Cookie: _SSO=SsoTicket=0YrWdtoyI18iOZwkH1Hu4y4qszAT13H6AftF5VnbnfcVCpnWb
3DuAI++d5dVdVeU1ERXdMVEF6TFRBMFZESXdPakl5T2pRM0v6S7QiitZFYvTjIWICZctZIYcYH1G
t4k0GSrLEYFyHgqqL8NzthI14ct1hlpsQ8P0u0Xi8xR3i4cusqlYEEFbGnMcFjdm4YyO1cgGp02G
kALEOyCdMNPLCAMF1b1WPzrJqyThk9ZT7SSEsUD8MNwC/ecRwbiwPBztJqTDZo51q7SfnJfnTYDX
IE/L5d8mKMFDSEQ5Pchm4OJXoKPXWyylysq4zTMF+l6OEoiKEywGvVn0dueuMwL1smQ54XUQN/k2
KpFkBbTS5qIWKN/28qPMqajzfVK1czi9sdAskBOaJKksJwXd+LQKUHYy82NedEV2UzfV3NAMfzN2
/lrRnxOFPC0IPB1ZXnT6to3zGv3J6aaFkyOaqef8hPKCltFaTrrZ5g6ZCXOGqpDItnU52Ihw0Uue
DgrQWx6WitDaUVtSWZqbnhzNnNnU29kbmNzNnVvbG1JNXMwcFVGaW96cTlTd0JVR3/O1hpjHpLD8
oh0eeJEUgWKXc/oQYZPzjNmjtRtOL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QfHiC8Gd68JXaKQcEv4bCJSkxd+7Kt5KcC3
QOXh1FMKr80qnk3VDXcXlkZ0nk9ryYoHcDwC1qo8TfIYHZMurfQZa4dETrgpBWOOq/t4s5s4YzYK
ZjpGwa3QeyOTeJdAEiqPXN8NPDLqzqMNjkwAExyPJM0fMM+Nh8hgFDBW8aAuTyEx5yqtfVXEFcMn
mEDeJXgp0ZlksZpQq/BPgQkzbJEFBj6wGe+UchGTRD5e5lXg7fQklZLoPrDEE4LJoiUqD5RZNsN+
bi5soy5wSQoeqNmmblqI09NhN78fF22CH9mS2wMVEdEouFrNR0g3fRsdpDtM4wAXCBI2pz710eQX
5YdJR6JWnS2/kpXbh2CAHCRLSxuSqQWFfyzfqeg4AAndW9SFTpBipTjcCHNsjKBDAxALZRMPqH1v
ktCFWZuHkV0cZ1e48+7ycS46dC96IAonK1VaifKlFeH5q0rGjIoxf12Yisytk/oihGgJw==&
IsModified=NB;Domain=.headwired.com;Path=/application
Transfer-Encoding: chunked

This looked very different to the partially downloaded header I was receiving in LoadRunner

HTTP/1.1 302 Moved Temporarily
Server: Sun-ONE-Web-Server/6.1
Date: Thu, 04 May 2010 21:38:32 GMT
Content-length: 0
Content-type: text/html
If-modified-since : Wed, 01 Jan 2009 16:00:00 GMT
Cache-control: no-store, no-cache, must-revalidate
Cache-control: post-check=0, pre-check=0
Pragma: no-cache
Location: https://www.headwired.com/application/home.php
Set-Cookie:_SSO=SsoTicket=EtVrITfBuCHlAaSIqdXYS8whmpj51ej/oElCw4A2JBAF6PNKx0
ZJIY6n515WQiVrIu7uoAmn8O61XBREcmjnLZcEQrkAec4HBoSHDOdg6AsXSg3JTEyug9NzfC9GEB
Arny2wyUx3CEzWOTF5niqB1lPTMr69HgPWToBQWFlbl3X94XseP2fs2IWTgDPywKuklEdlAIQymf
XToOXPTkP0hsJeEhHkHKAIVVym6apMiDP6ZOxKTqskEYoRbO9bgScJN9S/lXPNKU2JekG2Ve/GZD
GOf/AF7HmS2IULN0Ma1OqjeHmZHox7lLZAOfZoOi9Nm3WbKyHTkeYjp/5jIFoLNvPJ8loJ/QDsKX
QDmao1lQfHiC8Gd68JX/aKQcEv4bCJSkxd+7Kt5KcC3AZoq2qQOXh1FMKr80qnk3VDXcXlkZ0nk9
ryYoHcDwC1qo8TfIYHZMurfQZa4dETrgpBWOOq/t4s5s4YzYKhJPZjpGwa3QeyOTeJdAEiqPXN8N
PDLqzqMNjkwAExyPJM0fMM+Nh8hgFDBW8aAuTyEx5yqtfVXEFcMnKmEDeJXgp0ZlksZpQq/BPgQk
zbJEFB46dC96IASHDOdg6AsXSg

So what was the main differentiating factor? Perhaps chunking? Cookies and 302 redirects? Well, in this case it turns out its gzip:

Content-Encoding: gzip
Vary: accept-encoding

You can manually force LoadRunner to add “Accept-Encoding: gzip” to all subsequent HTTP requests using the following command:

web_add_auto_header("Accept-Encoding", "gzip");

It turns out that this is all it takes to ensure that LoadRunner downloads the entire headers from the HTTP 302 response.  While I am happy to have a solution to this rather annoying problem, two things bother me about it:

  1. Why is LoadRunner only reading the first frame of the response?
  2. LoadRunner recorded this script and it should have picked up the header issue.

Alternatively, you can also use the following command:

web_add_auto_header("Accept-Encoding", "*");

Hopefully, this quick tip will help out next time LoadRunner isn’t downloading the full  response.

About the Author

Joel Deutscher is an experienced performance test consultant, passionate about continuous improvement. Joel works with Planit's Technical Testing Services as a Principal Consultant in Sydney, Australia. You can read more about Joel on LinkedIn.

1 Comment

  1. Dhananjey says:

    I would say that this is a superb finding.