- It's not be able to redirect to different domain.
For example, the url http://alturl.com/it3jp will redirect to http://example.com/Code: Select all
req := ComObjCreate("Msxml2.XMLHTTP") req.open("GET", "http://alturl.com/it3jp", False) req.Send() MsgBox, % req.responseText "`n" req.getAllResponseHeaders() ; Get nothing
- It's not be able to set Referer header.
req.SetRequestHeader("Referer", "http://example.com/") just doesn't work, you can try it yourself. - It will caching the contents of the URL page.
Which means if you request the same URL more than once, you always get the same responseText even the website changes text every time.
Example:With some Googling, I found two solutions.Code: Select all
req := ComObjCreate("Msxml2.XMLHTTP") Loop, 3 { req.open("GET", "http://tmplinshi.sinaapp.com/test/time.php", False) req.Send() MsgBox, % req.responseText ; You'll get the same time each time. }
- Add a random parameter to the url.
Code: Select all
req := ComObjCreate("Msxml2.XMLHTTP") Loop, 3 { r := ComObjCreate("Scriptlet.TypeLib").Guid req.open("GET", "http://tmplinshi.sinaapp.com/test/time.php?r=" r, False) req.Send() MsgBox, % req.responseText }
- Set cache related headers.
Code: Select all
req := ComObjCreate("Msxml2.XMLHTTP") Loop, 3 { req.open("GET", "http://tmplinshi.sinaapp.com/test/time.php", False) ;req.SetRequestHeader("Pragma", "no-cache") ;req.SetRequestHeader("Cache-Control", "no-cache") req.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") req.Send() MsgBox, % req.responseText }
- Add a random parameter to the url.
3 big problems of Msxml2.XMLHTTP
3 big problems of Msxml2.XMLHTTP
Msxml2.XMLHTTP is similar to WinHttp.WinHttpRequest.5.1, BUT there are 3 big problems you should know:
Last edited by tmplinshi on 03 Mar 2017, 23:31, edited 1 time in total.
Re: 3 big problems of Msxml2.XMLHTTP
But what the advantages to use Msxml2.XMLHTTP instead of WinHttp.WinHttpRequest.5.1?
And where I can read about it. Here?
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
If yes, Could You please give example how to use:
1) addEventListener: Registers an event handler for the specified event type.
2) dispatchEvent: Sends an event to the current element.
And where I can read about it. Here?
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
If yes, Could You please give example how to use:
1) addEventListener: Registers an event handler for the specified event type.
2) dispatchEvent: Sends an event to the current element.
Re: 3 big problems of Msxml2.XMLHTTP
Msxml2.XMLHTTP uses the IE Browser's cookies. That's the main reason I use it. But most of the time I use WinHttp.WinHttpRequest.5.1.
Msxml2.XMLHTTP is not same as XMLHttpRequest(). There's no addEventListener and dispatchEvent methods in Msxml2.XMLHTTP.
Msxml2.XMLHTTP is not same as XMLHttpRequest(). There's no addEventListener and dispatchEvent methods in Msxml2.XMLHTTP.