1

There is one java sun.Applet embeded inside a HTTPS webpage. After entering valid profile and password, I can access to that applet, request data of the Http headers captured by Fiddler when my login to that applet is showed in the image below.

what I need is the cookie set from its response text, the cookie is useful in the following actions. I tried codes below with WinHttpRequest.5.1, but I do not know how to emulate the postdata, as you can see in the image, a few characters appear as black squares. And also I tried document.cookie but failed, it returns nothing.

Dim objHTTP As Object
Dim URL As String
Dim PostData as String
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "Https://xxxxxx"
PostData = ""
With objHTTP 
    .Open "POST", URL, False
    .setRequestHeader "User-Agent", "Mozilla/4.5 [en] (winNT; I)"
    .setRequestHeader "companyID", "CN"
    .setRequestHeader "Auth_Mode", "2"
    .setRequestHeader "CONTENT_TYPE", "application/octet-stream"
    .setRequestHeader "Cache-Control", "no-cache"
    .setRequestHeader "Pragma", "no-cache"
    .setRequestHeader "Host", "XXXXX.com"
    .setRequestHeader "Accept", "text/html, image/jpeg, *; q=.2, */*; q=.2"
    .setRequestHeader "Proxy-Connection", "Keep-alive"
    .setRequestHeader "Content-type", "application/x-www-form-urlencode"
    .setRequestHeader "Content-Length", "419"

    .Send PostDate
End With

Codes in Fiddler request headers

Jim
  • 35
  • 1
  • 8
  • Try an initial GET request and extract headers with method: GetAllResponseHeaders . Then parse that for cookie info. https://learn.microsoft.com/en-us/windows/desktop/winhttp/winhttprequest. Or use GetResponseHeader to retrieve a specific header. E.g. https://stackoverflow.com/a/19303041/6241235, https://stackoverflow.com/search?q=vba+winhttp+cookie – QHarr Jun 19 '19 at 06:40
  • @QHarr thank you for you help, but GET request is not proper here, since it returns only one short line "java.null", as displayed in my image uploaded, there are some characters appears in some queer format, I do not know how to wirte those queer characters as postdata. – Jim Jun 19 '19 at 14:46
  • Is there any other solutions that may help me on this? See the attached image, how to emulate that request header? – Jim Jun 21 '19 at 13:52

0 Answers0