Danp2 / au3WebDriver

Web Driver UDF for AutoIt
MIT License
107 stars 21 forks source link

WinHttp.WinHttpRequest.5.1 usage #512

Open mlipok opened 6 months ago

mlipok commented 6 months ago

Pull request

Proposed changes

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

Checklist

Types of changes

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

Sven-Seyfert commented 6 months ago

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

mlipok commented 6 months ago

I expected such request. Will do it ASAP.

Sven-Seyfert commented 6 months ago

No pressure @mlipok , thanks for your stable contribution actions on this project πŸ‘Œ .

mlipok commented 6 months ago

Done: added _WD_DownloadAsBinary

Sven-Seyfert commented 6 months ago

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 commented 6 months ago

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.

mlipok commented 6 months ago
  • Do we need to support both InetRead and WinHttp downloads?

Do not know.

mlipok commented 6 months ago
  • 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 commented 6 months ago
  • Do we need to support both InetRead and WinHttp downloads?

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

mlipok commented 6 months ago
  • 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