Link to home
Start Free TrialLog in
Avatar of Crawler77
Crawler77

asked on

Reading HTTP packages to use with Winhttp

How can I read the HTTP packages that my browser send ?
(For example when I login to a site)
And can I use that info to use with winhhtp in VBA ?
Avatar of Inderjeetjaggi
Inderjeetjaggi
Flag of India image

YOu will heva to use a packet sniffing software to do so

have a look at below website:
http://en.wikipedia.org/wiki/Packet_sniffing
Avatar of Crawler77
Crawler77

ASKER

Can I do it from VBA using an Internet Explorer Reference ?
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Paul.

It seems to be the tool that I'm looking for. But I've encountered an interesting problem. The application runs smoothly on my home computer (which is running Vista), but not running properly on the work computer (which is running XP). I don't know the reason yet. So it will take some time to see if this solution works for me or not.

One of the other setbacks of the program (and also my code) is that it sends the http requests bypassing the browser (which is in fact an expected situation). So when you try to see the result in the browser, browser sends another request and it usually changes the previous one. So it's hard to test the code, and see the result. Do you have any idea on this ?
Fiddler acts as a proxy, so you might have to set up the proxy settings for your http access.  Fiddler is configured to listen on port 8888 by default.

If you are using winhttp you can do this like so:
Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0
Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0
Const HTTPREQUEST_PROXYSETTING_DIRECT = 1
Const HTTPREQUEST_PROXYSETTING_PROXY = 2

Dim http As WinHttpRequest
Set http = New WinHttpRequest

http.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "localhost:8888"
http.Open "GET", Url, False
http.Send
MsgBox http.ResponseText

Open in new window

This nice app partially solved my problem but I would be happy if it also had a VBA refence to use in my code. Anyway thanks for the help...
When I copied http requests from fiddler to my app source code it did not always work.