Question

Is there a way to work with the ResponseStream property of WinHttp.WinHttpRequest.5.1 in VBScript/ASP? At least the IStream interface (to which ResponseStream is related) is integrated into ASP to a certain degree.

Or is that the limit of what you can achieve in script? Requiring you to roll your own COM component if you want to go any further?

<html><body><h1>WinHttp</h1>
<%
Dim req, url, o
Set req = CreateObject( "WinHttp.WinHttpRequest.5.1" )
url = "http://www.google.de"
req.Open "GET", url, False
req.Send
Response.Write "<p>Hier kommt <code>" & url & "</code> :</p>"
Response.Write "<pre>"
Response.Write req.Status & " " & req.StatusText & VbNewLine
Response.Write req.GetAllResponseHeaders
Response.Write "</pre>"
' Response.Write Mid( req.ResponseText, InStr( req.ResponseText, "<div" ) )

' Set o = req.ResponseStream
' o = req.ResponseStream
' Same result for Write and BinaryWrite:
' VarType = 13, TypeName = Unknown
' ASP 0106 : 80020005; Typkonflikt; Unbehandelter Datentyp
' o = req.ResponseStream

' o = req.ResponseBody ' mit BinaryWrite
o = req.ResponseText ' mit Write
Response.Write "<p><code>IsObject " & IsObject(o)  & "</code></p>"
Response.Write "<p><code>IsNull "   & IsNull(o)    & "</code></p>"
Response.Write "<p><code>VarType "  & VarType(o)
Response.Write                  " " & TypeName(o)  & "</code></p>"
Response.Write o
' Response.BinaryWrite o
%>

Note that I know I can use either req.ResponseText or req.ResponseBody. The interest is in knowing whether you can go further in script using stuff that's only documented for C but maybe (speculating) accessible to script. I'm not knowledgeable about COM.

Was it helpful?

Solution

There is nothing you can do with an IStream directly in script code. All you could do is pass it to a COM object that might use it.

The IStream is very alien to Vbscript even in VB6 one has to jump through some fiery hoops to work with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top