UrlDownloadToFile User-Agent bug

Propose new features and changes
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

UrlDownloadToFile User-Agent bug

12 Jun 2022, 17:34

[Moderator's note: Topic moved from Bug Reports.]

Why do We use "AutoHotkey" as user agent?

Code: Select all

HINTERNET hInet = InternetOpen(_T("AutoHotkey"), INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
https://github.com/Lexikos/AutoHotkey_L/blob/master/source/script_autoit.cpp#L1024
With such user agent We cannot download some pages correctly.
Compare: this

Code: Select all

UrlDownloadToFile, https://www.google.com/search?q=banana&tbm=isch, test.txt
and this

Code: Select all

HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", "https://www.google.com/search?q=banana&tbm=isch", true)
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36 OPR/87.0.4390.45")
HTTP.Send()
HTTP.WaitForResponse()
msgbox % HTTP.ResponseText
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: UrlDownloadToFile User-Agent bug

13 Jun 2022, 00:14

A valid question, but why do you call it a bug? Is there some claim in the documentation that you will be able to download from servers that are particular about the user agent?

How do we know what default user agent is "correct"?

The answer to your question is likely that whoever wrote the code wasn't knowledgeable about user agent strings, and it hasn't been changed because it almost never matters.

I would suggest that someone come up with a better value and submit a pull request for the change, explaining the new value.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: UrlDownloadToFile User-Agent bug

13 Jun 2022, 18:12

May be just use any common browser user agent like this?

Code: Select all

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36 OPR/87.0.4390.45

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 32 guests