Sign in to follow this  
Followers 0
Spider001

WinHTTP

6 posts in this topic




hey,

Look up the syntax for #include.  That should give you a hint.

Your Welcome,

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Download / extract the file and put it wherever you run your script from...


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

kylomas, he means something else.

Spider one, you can do it like this:

#include "WinHttp.au3"

Global Const $sDomain = "https://addons.mozilla.org"
Global $sPage = "firefox/downloads/latest/231203/addon-231203-latest.xpi?src=dp-btn-primary"
Global $sFileName = StringRegExpReplace($sPage, ".*/", "")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$sFileContent = GetTheFileContent($sFileName)

ConsoleWrite($sFileName & @CRLF)
MsgBox(4096, "File Name", $sFileName)

; See what's returned (it's ZIP format so you'll see only first few characters in messagebox)
MsgBox(4096, "Content", $sFileContent)

; The End
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Func GetTheFileContent(ByRef $sWEB_FileName)
    ; Initialize and get session handle
    Local $hOpen = _WinHttpOpen()

    ; Get connection handle
    Local $hConnect = _WinHttpConnect($hOpen, $sDomain)
    ; Register Callback function
    Local Const $hREDIRECT_CALLBACK = DllCallbackRegister(__RedirectFunc, "none", "handle;dword_ptr;dword;ptr;dword")
    ; Set callback
    _WinHttpSetStatusCallback($hConnect, $hREDIRECT_CALLBACK, $WINHTTP_CALLBACK_FLAG_REDIRECT)

    Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect, Default, $sPage)

    ; Get content disposition
    Local $sDispositionFileName = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION)

    ; Check if file name is specified inside the header
    If $sDispositionFileName Then $sWEB_FileName = StringReplace(StringRegExpReplace($sDispositionFileName, 'attachment.*=', ""), '"', "")

    ; Read file
    Local $sReturned = _WinHttpSimpleReadData($hRequest)

    ; Close handles
    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)
    ; Free callback
    DllCallbackFree($hREDIRECT_CALLBACK)

    ; All done
    Return $sReturned
EndFunc
; Define callback function
Func __RedirectFunc($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength)
    Local $sStatus = DllStructGetData(DllStructCreate("wchar[" & $iStatusInformationLength & "]", $pStatusInformation), 1)
    Dim $sFileName = StringRegExpReplace($sStatus, ".*/", "")
EndFunc
1 person likes this

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Thanks trancexx thats exactly what i need looking for that the whole day

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0