Jump to content

InetGet Bug ?


Greek
 Share

Recommended Posts

Hi,

$user = _URIEncode("tester@bla.com"); // Only example
$password = _URIEncode("my:password");

; Advanced example - downloading in the background
Local $hDownload = InetGet("ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG", @ScriptDir&"\test.jpg", 1, 1)

Do
    Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.
MsgBox(0, "", "Bytes read: " & $nBytes)



Func _URIEncode($sData)
    ; Prog@ndy
    Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
    Local $nChar
    $sData=""
    For $i = 1 To $aData[0]
;~         ConsoleWrite($aData[$i] & @CRLF)
        $nChar = Asc($aData[$i])
        Switch $nChar
            Case 45, 46, 48-57, 65 To 90, 95, 97 To 122, 126
                $sData &= $aData[$i]
            Case 32
                $sData &= "+"
            Case Else
                $sData &= "%" & Hex($nChar,2)
        EndSwitch
    Next
    Return $sData
EndFunc

Func _URIDecode($sData)
    ; Prog@ndy
    Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%")
    $sData = ""
    For $i = 2 To $aData[0]
        $aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2)
    Next
    Return BinaryToString(StringToBinary($aData[1],1),4)
EndFunc

Shouldn't InetGet be able to download it? Seems like : and/or @ breaks it even when I escape it.

If I ClipPut the URL it works flawless in IE/Chrome

 

Greetings Greek

Edit: My bad, I edited the question

Edited by Greek
Link to comment
Share on other sites

And your problem/question is?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Greek,

And the problem is? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thought it would be clear now:

The problem is that you can't use special chars like : or @ as user name or password.

As you can see here:

$user = _URIEncode("tester@bla.com"); // Only example
$password = _URIEncode("my:password");

; Advanced example - downloading in the background
Local $hDownload = InetGet("ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG", @ScriptDir&"\test.jpg", 1, 1)

Edit: I don't know why my whole post doesn't show up, this editor trims always...

Edit2: Hope he keeps it now:

The URL in InetGet is a valid URL for IE, you get the image. With InetGet I don't get it.

Edited by Greek
Link to comment
Share on other sites

Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so I cant take a deeper look.
Anyway in case it is inetget function try this

$user = _URIEncode("tester@bla.com")
$password = _URIEncode("my:password")
 
Global $path = @ScriptDir & "\test.jpg"
Local $hDownload = "ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG"
ConsoleWrite($hDownload& @LF)

FileDownload($hDownload, $path)

Func FileDownload($url, $SavePath)
 Local $xml, $Stream
 $xml = ObjCreate("Microsoft.XMLHTTP")
 $Stream = ObjCreate("Adodb.Stream")
 $xml.Open("GET", $url, 0)
 $xml.Send
 $Stream.Type = 1
 $Stream.Open
 $Stream.write($xml.ResponseBody)
 $Stream.SaveToFile($SavePath)
 $Stream.Close
EndFunc
 

Func _URIEncode($sData)
    Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
    Local $nChar
    $sData=""
    For $i = 1 To $aData[0]
;~         ConsoleWrite($aData[$i] & @CRLF)
        $nChar = Asc($aData[$i])
        Switch $nChar
            Case 45, 46, 48-57, 65 To 90, 95, 97 To 122, 126
                $sData &= $aData[$i]
            Case 32
                $sData &= "+"
            Case Else
                $sData &= "%" & Hex($nChar,2)
        EndSwitch
    Next
    Return $sData
EndFunc
Func _URIDecode($sData)
    Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%")
    $sData = ""
    For $i = 2 To $aData[0]
        $aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2)
    Next
    Return BinaryToString(StringToBinary($aData[1],1),4)
EndFunc
Edited by AutID
Link to comment
Share on other sites

"Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so"

It works with with url and the right data. So I think there must be a problem with InetGet.

 

mh I get this:

test.au3 (16) : ==> The requested action with this object has failed.:
$xml.Send
$xml.Send^ ERROR
Edited by Greek
Link to comment
Share on other sites

 

"Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so"

It works with with url and the right data. So I think there but be a problem with InetGet.

 

mh I get this:

test.au3 (16) : ==> The requested action with this object has failed.:
$xml.Send
$xml.Send^ ERROR

Neither INetGet or Filedownload functions have problem. The problem is in the encode decode function, or somewhere else in you script.

$xml.Send fails because your data is wrong.

You provide the user like this: tester%40bla.com

And the password like this: my%3Apassword

which means the "@" gets replaced by "%40" and the ":" gets replaced by "%3A".

So something you are doing wrong. Either provide your entire script either your credentials for test(which I don't recommend) either get over it.

Link to comment
Share on other sites

The problem is in your password. Downloading something with INetGet you have to provide username:password like this :http://myuser:mypassword@www.somesite.com

Your password is like this "password:password" so this sigh ":" within your password is getting INetGet function confused. I don't know if it is a bug cuz it is not an udf so I cant take a look on it.

Try changing temporary your password without that sigh within it and try inetget function again.

Edit: When I navigate it manually the site navigates normally, using inetget doesn't seem to work even if I give the entire url with the credentials. The error though is your password. Or at least that's what error check says.

Try changing your password and try again.

Edited by AutID
Link to comment
Share on other sites

I posted you an answer with a debugger of the script explaining the extended of the inetget error since it contains credentials.
Try encoding your password with other chars besides those. Change it and encode other letters besides those on @ProgAndy's function.
It is easy if you read a bit the help files for the ASCII codes.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...