Skip to content

WinHttp.WinHttpRequest.5.1 usage #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mlipok
Copy link
Contributor

@mlipok mlipok commented Feb 27, 2024

Pull request

Proposed changes

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

Checklist

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

Types of changes

  • 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

@sven-seyfert
Copy link
Contributor

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
Copy link
Contributor Author

mlipok commented Feb 28, 2024

I expected such request.
Will do it ASAP.

@sven-seyfert
Copy link
Contributor

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

@mlipok
Copy link
Contributor Author

mlipok commented Feb 29, 2024

Done: added _WD_DownloadAsBinary

@sven-seyfert
Copy link
Contributor

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 🤝 .

Comment on lines +2474 to +2475
; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_DownloadAsBinary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function header should be ; #INTERNAL_USE_ONLY# ====== and the function should be __WD_DownloadAsBinary instead of _WD_DownloadAsBinary. Actually it does not matter, but it would fulfill the consistency 😇 .

Copy link
Contributor Author

@mlipok mlipok Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have any reason to change _WD_DownloadAsBinary into internal usage only then you should try to apply the same reason to _WD_DownloadFile and see if this reason also makes sense here.

If you say that _WD_DownloadFile save data to file I would say that the destination does not matter here as I always try to avoid writing data to files on disk. Instead, I process the data in memory and write to database.

This is because of security reason (i.e. GDPR law) - I simply try to minimize the number of places where data leaves a trace (files on disc).

Summary: if any user of this UDF needs to use the function for download and writing data to a file, then the function of writing data to memory without writing it to disk is equally necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood and fair enough @mlipok 👍 .

Then at least the README.md file also has to be adjusted, right?
I mean the additional function should be described in the README like the other functions too.
Is this usually made by @Danp2 ? I believe he do a "Prep release" commit which will contain such things, right? Or do we as PR authors also adjust these files 🤔 ?

Best regards
Sven

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this usually made by @Danp2 ? I believe he do a "Prep release" commit which will contain such things, right? Or do we as PR authors also adjust these files 🤔 ?

@Danp2
What you think about ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Danp2 can you look here ?

Copy link
Owner

@Danp2 Danp2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't yet read through the past discussions on this PR, but I do have a few questions to add --

  • Do we need to support both InetRead and WinHttp downloads?
  • Is there functionality from WinHttp.au3 that could be used here instead of WinHttp.WinHttpRequest.5.1?

@sven-seyfert
Copy link
Contributor

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
Copy link
Contributor Author

mlipok commented Mar 2, 2024

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

Do not know.

@mlipok
Copy link
Contributor Author

mlipok commented Mar 2, 2024

  • 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
Copy link
Contributor Author

mlipok commented Mar 3, 2024

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

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

@mlipok
Copy link
Contributor Author

mlipok commented Mar 3, 2024

Copy link
Owner

@Danp2 Danp2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Yes, that is what I was wanting you to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants