Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityWebRequest and gzip

Discussion in 'Scripting' started by Claytonious, Dec 10, 2015.

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
  2. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    We really want to be able to set gzip as encoding, but we can't customize the Accept-Encoding header. Why ? It doesn't seem to set to gzip by default :\
     
  3. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    up ? Any Unity dev in charge of the UnityWebRequest ?
     
  4. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Up ?

    No answer from Unity team :\
     
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    Unity has confirmed that gzip is not currently handled on Android with UnityWebRequest but that they were hoping to support that someday soon. Can anyone at Unity chime in on whether this is on a roadmap yet, or maybe already done for an upcoming release, or will never come, or whatever the status may be?

    Thanks!
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    If need be, you can handle it manually for now. If you know the content coming back is gzipped, then use a GZipStream to decompress the contents.

    https://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=vs.90).aspx

    Make certain it is GZip though. 99% of cases, it should be gzip if it's compressed, but there are a few places out there that may still use Deflate, in which case you'd need the DeflateStream instead so I'm linking it for reference, but it's not very likely:

    https://msdn.microsoft.com/en-us/library/system.io.compression.deflatestream(v=vs.90).aspx
     
  7. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    I already know that but it is not the problem. The problem is that it is forbidden to set the "accept-encoding" header in UnityWebRequest, so the server will never respond with a compressed content.
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Ahh, yeah that sounds like a bug.
     
  9. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
  10. pcpaukm

    pcpaukm

    Joined:
    Jul 9, 2015
    Posts:
    9
    Anyone got workaround on this problem?
    Is there anyway to request compressed content from the server?
     
  11. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Still no answer from Unity Team :\
     
  12. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Unity support is pretty efficiency ....
     
  13. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    You need to file a bug report or send an email to support@umity3d.com. This is a community driven forum, not a support forum. Unity devs do occasionally participate but it's not an official channel.
     
    Claytonious likes this.