VBA-tools / VBA-Web

VBA-Web: Connect VBA, Excel, Access, and Office for Windows and Mac to web services and the web
http://vba-tools.github.io/VBA-Web/
MIT License
2.01k stars 494 forks source link

Decoding GZIP web response #61

Closed ststreck closed 9 years ago

ststreck commented 10 years ago

Hi Tim, I really apreciate your effort in keeping Excel-Rest up-to-date. Hope that my issue is a simple one.

I use a Web-Service returning a JSON String, but for performance it is GZIP encoded. So I add a Header: Request.AddHeader "Accept-Encoding", "gzip, deflate"

This works fine, so I get an gzip encoded response. Now Im searching for a way how to decode this before it is handed over to the parser.

Regards Stephan

timhall commented 9 years ago

@ststreck I've looked into gzip decoding, but that is quite a task and I couldn't find a cross-platform approach. This can be added with a custom converter (with your own gzip decoder) in v4.0.0

' GzipConverter.bas
Public Function ConvertToGzip(Value As Variant) As String
    ' (Not implemented)
End Function
Public Function ParseGzip(Value As String) As Object
    ' Parse GZIP...
End Function

' Before request
WebHelpers.RegisterConverter "gzip", "your-response-type", _
  "GzipConverter.ConvertToGzip", "GzipConverter.ParseGzip"

' With request
Request.CustomResponseFormat = "gzip"