au3WebDriver icon indicating copy to clipboard operation
au3WebDriver copied to clipboard

WinHttp.WinHttpRequest.5.1 usage

Open mlipok opened this issue 1 year ago • 10 comments

Pull request

Proposed changes

Today I hit a problem when trying to update geckodriver where InetRead() returns with error

Checklist

  • [x] I have read and noticed the CODE OF CONDUCT document
  • [x] I have read and noticed the CONTRIBUTING document
  • [ ] I have added necessary documentation or screenshots (if appropriate)

Types of changes

  • [x] Bugfix (change which fixes an issue)
  • [ ] Feature (change which adds functionality)
  • [ ] Code style update (formatting, renaming)
  • [ ] Refactoring (functional, structural)
  • [ ] Documentation content changes
  • [ ] Other (please describe)

What is the current behavior?

Sometimes InetRead and InetGet can return error thus there is no way to update driver with this udf.

What is the new behavior?

when InetRead returns error then WinHttp.WinHttpRequest.5.1 is used.

Influences and relationship to other functionality

none

Additional context

https://www.autoitscript.com/forum/topic/209621-inetget-alernative/ https://www.autoitscript.com/forum/topic/209610-inetget-dont-download-some-pages-since-ie11-is-no-longer-supported-by-some-sites https://www.autoitscript.com/forum/topic/209472-download-problem-with-inetget/

System under test

FireFox

mlipok avatar Feb 27 '24 10:02 mlipok

Hi @mlipok , since you use the same code block ...

If @error Then
	Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
	$oHTTP.Open("GET", $sURL, False)
	$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0")
	$oHTTP.Send("")
	$sName = $oHTTP.ResponseBody
EndIf

... three times (for $sResult, $sData and $sDriverLatest), it would maybe be a good improvement to extract this code into a separate "internal usage" function 😀 .

Best regards Sven

sven-seyfert avatar Feb 27 '24 18:02 sven-seyfert

I expected such request. Will do it ASAP.

mlipok avatar Feb 28 '24 20:02 mlipok

No pressure @mlipok , thanks for your stable contribution actions on this project 👌 .

sven-seyfert avatar Feb 28 '24 21:02 sven-seyfert

Done: added _WD_DownloadAsBinary

mlipok avatar Feb 29 '24 10:02 mlipok

Cool, thanks @mlipok . I try to test it in the next day(s). Because I believe, the @error marcro could be a problem - but it's only a wild guess and feeling, no real statement. Let me test it 🤝 .

sven-seyfert avatar Feb 29 '24 10:02 sven-seyfert

Is there functionality from WinHttp.au3 that could be used here instead of WinHttp.WinHttpRequest.5.1?

This is actually a really good question @Danp2. Interesting.

sven-seyfert avatar Mar 02 '24 17:03 sven-seyfert

  • Do we need to support both InetRead and WinHttp downloads?

Do not know.

mlipok avatar Mar 02 '24 18:03 mlipok

  • Is there functionality from WinHttp.au3 that could be used here instead of WinHttp.WinHttpRequest.5.1?

I think yes. But I'm not familiar with winhttp.au3 udf.

mlipok avatar Mar 02 '24 18:03 mlipok

  • Do we need to support both InetRead and WinHttp downloads?

Do you mean to stop using InetRead in favor of WinHTTP functions ?

mlipok avatar Mar 03 '24 19:03 mlipok

  • Is there functionality from WinHttp.au3 that could be used here instead of WinHttp.WinHttpRequest.5.1?

I think yes. But I'm not familiar with winhttp.au3 udf.

maybe from here: https://www.autoitscript.com/forum/topic/199088-download-a-zip-file-using-winhttp/?do=findComment&comment=1428601 https://www.autoitscript.com/forum/topic/174063-winhttp-download-an-exe-file/?do=findComment&comment=1259515

also some of my old attempts: https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/?do=findComment&comment=1490309

mlipok avatar Mar 03 '24 19:03 mlipok