Hi All!.
I have a link to download, It needs to be downloaded with a HTTPSecureSocket.
I know that is possible to catch the cookie of the session loaded on my HTMLViewer (User and Password).
Now the question is, how can I use it in order to get the cookies and download the requested link?
Regards
I want to do this, because If I download the file as normal I get another thing instead of the file
Maybe you should ask the website owner for api access.
I’m investigating, but windows users that Access to this website to download file in VB.net uses Cache to preserve the credentials and then download the file.
A cookie is just a HTTP header. So if you have the cookie name and value then you can just append it as a header to your HTTPSecureSocket.
To get Cookie Name: // query list of all cookies in shared storage
dim cookies(-1) as NSHTTPCookieMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage.cookies
// pick first one
dim cookie as NSHTTPCookieMBS = cookies(0)
// display name:
MsgBox "name: "+Cookie.name
Now the Issue is How Can I get the cookie value?
Regards
I think I know hot to get the value of the cookie:
// query list of all cookies in shared storage
dim cookies(-1) as NSHTTPCookieMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage.cookies
// we collect values
dim list(-1) as string
for each cookie as NSHTTPCookieMBS in cookies
List.Append cookie.value
next
// and display them
MsgBox join(list, EndOfLine)
Pls. Correct me if I’m wrong
Assuming thats true then you would do something like.
myHttp.SetRequestHeader(“Set-Cookie”, cookie.name + “=” + cookie.value)
[quote=231731:@Phillip Zedalis]Assuming thats true then you would do something like.
myHttp.SetRequestHeader(“Set-Cookie”, cookie.name + “=” + cookie.value)[/quote]
But you put three arguments and method only has two arguments.
By the way, This is the way. Now I need to get the correct cookies for the present URL, Instead of global cookies.
And I get a different file:
[b]
Bad Request
Bad Request - Invalid Header
HTTP Error 400. The request has an invalid header name.
[/b]