dfmatt Posted January 14, 2009 Share Posted January 14, 2009 I am trying to use InetGetSize to return the size of a file on my server. I have checked the page headers and they are HTTP/1.x 200 OK Date: Wed, 14 Jan 2009 13:31:44 GMT Server: Apache X-Powered-By: PHP/5.2.4-2ubuntu5.4 Content-Length: 117 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html so it should be returning something, but it always gives me 0 and sets @error to 1. The code is this, $size_groups = InetGetSize ( 'https://mydomain.net/index.php' ) MsgBox ( 0 , "" , $size_groups ) Does anyone know what might be going wrong? Thanks Link to comment Share on other sites More sharing options...
Zedna Posted January 14, 2009 Share Posted January 14, 2009 (edited) There are two possible problems: - https - proxy You can take a look at HTTP UDF and its API functions Edited January 14, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 It wouldn't be a proxy because there isn't one on my machine or on the server. How could HTTPS cause a problem? The HTTP UDF doesn't seem to have a way to monitor progress of download which is the whole reason I want to use InetGetSize the function to just get a file (InetGet I think) works fine for my file. Link to comment Share on other sites More sharing options...
Zedna Posted January 14, 2009 Share Posted January 14, 2009 How could HTTPS cause a problem?I don't see any info in AutoIt helpfile about support for https at InetGetSize() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 Ah ok. But wouldn't the fact that InetGet supports HTTPS mean that InetGetSize would too? Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 I see you are pointing to a php file, what type of output does it generate? Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 The page just says "Hello world" there is no PHP there at the moment. Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 Try this: expandcollapse popup$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;$oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP = ObjCreate("MSXML2.XMLHTTP") $oHTTP.Open('GET', 'http://www.google.com/intl/en_ALL/images/logo.gif', FALSE) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.1)") $oHTTP.Send() ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEADERS" & @CRLF) $Headers = $oHTTP.GetAllResponseHeaders() ConsoleWrite($Headers & @CRLF) ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Content-Length" & @CRLF) $ContentLength = $oHTTP.GetResponseHeader("Content-Length") ConsoleWrite($ContentLength & @CRLF) ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Status" & @CRLF) $Status = $oHTTP.Status ConsoleWrite($Status & @CRLF) ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< StatusText" & @CRLF) $StatusText = $oHTTP.StatusText ConsoleWrite($StatusText & @CRLF) exit ;If status OK then save file If $Status = 200 Then $oBinaryStream = ObjCreate("ADODB.Stream") $filename = @DesktopDir & "\test.gif" $adTypeBinary = 1 $adSaveCreateOverWrite = 2 FileDelete($filename) $oBinaryStream.Type = $adTypeBinary $oBinaryStream.Open $oBinaryStream.Write($oHttp.ResponseBody) $oBinaryStream.SaveToFile($filename, $adSaveCreateOverWrite) EndIf ;-------------------------------- ;COM Error Handler ;-------------------------------- Func MyErrFunc() Local $HexNumber $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Error ","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 Thanks for the replies. Well it works for that first file, but now I'm trying it on a real file. It's a Perl script being executed by the server and the output is blank. The header I put in my original post is from that same Perl script. Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 Did you try the script I just posted? If it works then Content-Length will have the file size in bytes. Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 Yes that was what I was referring to. Your scripts gave me the content-length for the hello world file, but not for the executed perl script. Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 Yes that was what I was referring to.Your scripts gave me the content-length for the hello world file, but not for the executed perl script.Does you perl script redirect or does it directly output the header? Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 Directly outputs the header Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 When I run the test script using the "MSXML2.XMLHTTP" object I get the correct value for the test link. When I use it on a PHP file its empty. If I switch to the "winhttp.winhttprequest.5.1" object it works. Link to comment Share on other sites More sharing options...
dfmatt Posted January 14, 2009 Author Share Posted January 14, 2009 That was what I was doing wrong, I hadn't tried using the winhttp.winhttprequest.5.1 object. Am now and its working for me too. Thanks a lot! Link to comment Share on other sites More sharing options...
CaptainGadget Posted February 23, 2009 Share Posted February 23, 2009 That was what I was doing wrong, I hadn't tried using the winhttp.winhttprequest.5.1 object.Am now and its working for me too.How did you end up resolving the problem with InetGetSize? Were you able to get it to work with an https link? I have no problems with InetGet, only InetGetSize. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now