Sign in to follow this  
Followers 0
MvGulik

[solved] WinHttpRequest Object, ResponseStream, Crash.

2 posts in this topic

#1 ·  Posted (edited)

Not familiar with "winhttp.winhttprequest.5.1" Object, Ergo: Just experimenting a bit with it.

When using the 'ResponseStream' option ... AutoIt crashes.

- Anything I'm doing wrong (or missed) ? (or potential issue/bug)

Don't know much about a 'IStream', other than that 'ResponseStream' is supposed to return a pointer to it.

msdn: WinHttpRequest Object

main()
 
Func main()
    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    Local $sType = 'GET'
    Local $sUrl = 'http://www.autoitscript.com/site/'
    Local $sData = '' ;; optional parm.
    _HTTPRequest($oHTTP, $sType, $sUrl, $sData)
EndFunc
 
Func _HTTPRequest($oHTTP, $oMethod, $oURL, $oData = "")
    ;; http://msdn.microsoft.com/en-us/library/aa384106
    Local $iResult = 0 ;; debug
 
    $oHTTP.Open($oMethod, $oURL, False) ;; empty -> ok.
    $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5") ;; empty -> ok.
    If $oMethod = "POST" Then
        $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;; empty -> ok.
    EndIf
    $oHTTP.Send($oData) ;; empty -> ok.
 
;~  ;; options: ResponseBody, ResponseStream, ResponseText, Status, StatusText
;~  $iResult = $oHTTP.StatusText ;; "OK" -> ok.
;~  $iResult = $oHTTP.Status ;; 200 -> ok.
;~  $iResult = $oHTTP.ResponseBody ;; binary(ResponseText) -> ok.
;~  $iResult = $oHTTP.ResponseText ;; html page/content -> ok.
 
    $iResult = $oHTTP.ResponseStream ;; crash with 3.3.6.1 & 3.3.7.14 (Win.Xp.32b)
EndFunc
Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Lets put is down to trying to using a feature(IStream) in the wrong mode. (just presuming)

Don't think it should crash AutoIt ... but don't see any other direct downside's to it either. So I leave it at that.

Solved as far I'm concerned.

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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

  • Similar Content

    • Luigi
      By Luigi
      Greetings,
      I want use WinHttpRequest to access a OpenShift API server, it use a self signed certificate.
      Does now work...
      I never try with a self signed certificate, how do this?
      Best regards
      Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://openshift.domain:1234/api/", False) $oHttp.Option(4) = 0x0100 + 0x0200 + 0x1000 + 0x2000 $oHTTP.Option(9) = 0x0080 ;WinHttpRequestOption_SecureProtocols ;~ $oHttp.SetClientCertificate("LOCAL_MACHINE\\Personal\\certificado.crt") $oHttp.Send() $oHttp.WaitForResponse() Local $oAllHeaders = $oHttp.GetAllResponseHeaders() $oReceived = $oHttp.ResponseText $oStatusCode = $oHttp.Status $oHttp = 0 If $oStatusCode = 200 Then ConsoleWrite("$oAllHeaders--------------------" & @LF & $oAllHeaders & "$oAllHeaders--------------------" & @LF) Else ConsoleWrite("< error = " & $oReceived & @LF & $oAllHeaders & @LF) EndIf  
    • YellowLab
      By YellowLab
      I am having a very unique, but repeatable problem with ImageMagick COM interface. Here are the applicable lines of code:
      $oIM=ObjCreate("ImageMagickObject.MagickImage.1")
      and then later on...
      $oIM.Convert(String($arFileList[$nFileIndex])&'[0]',"-alpha", "remove",@TempDir&"\temp.jpg")
      the array points to a pdf file with the "convert" command converting the first page of the pdf to a jpg with any alpha layer removed.
      Every time, without fail, the first time I run the script on a freshly booted machine it crashes on the $oIM.Convert command. It does this if it isn't compiled and says there is an error executing the command on the object. If compiled, i get an error that autoit has stopped responding. Anytime I run the script, compiled or not, after this initial crash everything works perfectly fine.
      I am totally at a loss as to why this is occurring and how to correct it.
    • Rampantshadow
      By Rampantshadow
      Hi Guys,
      I am having an issue with multiple Windows 10 systems (actually all systems running Windows 10 running the same script have this issue) I have a script which calls the winhttp.winhttprequest.5.1 object and allows me to get sites HTML source, I am using multiple Open commands on the same object which I didn't assume would be an issue.
      The issue I am getting is quite often the Send command to the object will fail (in fact I have not been able to finish running the script because it fails everytime) with an Error
      Now this exact code was working fine in Windows 8/8.1 and Windows 7 before I upgraded the systems to Windows 10, anybody know what's going on here?
      P.S when I say I use multiple Open and Send commands I mean I have two instances of winhttprequest objects open and it probably does a total of about 600 Open and Sends but as I mentioned this had never been an issue until Windows 10.
    • UEZ
      By UEZ
      One web created Excel sheet is crashing when calling the _Excel_BookOpen function.
      "C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (227) : ==> Variable must be of type "Object".: $oExcel.Windows($oWorkbook.Name).Visible = $bVisible $oExcel.Windows($oWorkbook.Name)^ ERROR Local $oWorkbook = $oExcel.Workbooks.Open($sFilePath, $bUpdateLinks, $bReadOnly, Default, $sPassword, $sWritePassword) in line 225 seems to load the file but no error is set.
      Is there any way to catch those errors to avoid app crash? ObjEvent("AutoIt.Error", "ErrFunc") doesn't catch it!
       
      Tested on 3.3.14.2 and 3.3.15.0 and Office 2013.
    • HelpfulToasty
      By HelpfulToasty
      So, I'm trying to make this autoit script, and there's a function and stuff, but I can't write a function, inside a function! It's just not working.
      Like;
      Func Function_A($para1) Local $thing = 1 Func Function_B() ;Stuff here EndFunc If Function_B($thing) Then ;Stuff Else ;Stuff EndIf EndFunc ; Something like that. I'm either doing it wrong, or I can't do it in autoit.
      Anyway, help me please!