Sunday, November 11, 2007

winhttp GET request for xml gzip file, winhttp wont uncompress automagically

winhttp GET request for xml gzip file, winhttp wont uncompress automagically


Hi
Does anyone know what you have to do with a GET request for gzip file to un-compress automatically ?
I have a gzip xml file sitting on an iis 5 web server, & a client app
in side of a dhtml generrated asp page .. the vb script code snippet is like this

set oXMLDoc = createobject("Microsoft.XMLDOM")
'set oXMLHttp = createobject("Microsoft.XMLHTTP")
set oXMLHttp = createobject("WinHttp.WinHttpRequest.5")
sURL = http://localhost/spool/test.xml.gz
oXMLHttp.open "GET",sURL,false ' async
oXMLhttp.setRequestHeader "Content-Type", "text/xml"
oXMLhttp.setRequestHeader "Content-Encoding", "gzip"
oXMLHttp.setRequestHeader "Accept-Encoding", "gzip, deflate"
oXMLHttp.send ""
msgbox oXMLHttp.getallresponseheaders
if ((oXMLHttp.status <> 200) or len(oXMLHttp.responseXML.xml) =0) or
err.number <> 0 then
call msgbox(oXMLHttp.status & vbcrlf & "text: " &
oXMLHttp.responseText)
exit sub
end if
oXMLDoc.loadXML oXMLHttp.responseXML.xml

I get a oXMLHttp.status =200 back but the oXMLHttp.responseText is still
compressed
I have also tried the Microsoft.XMLHTTP object with the same results

--------------------------------------------------
GET request for xml gzip file, winhttp wont uncompress automagically
WinHttp does not support automatic decompression, you would have to feed the (compressed) response data to a decompression library.

--------------------------------------------------
Try using the XMLHTTP object from MSXML 4.0 instead; I think it might support decompression. The ProgID would be "Msxml2.XMLHTTP.4.0". Also, you should not need to set the "Accept-Encoding" request header, as XMLHTTP may do that for you.
There is no support in any of the WinHttp or MSXML components for compression (e.g., compress the body of a large POST request).