Search Issue Tracker
By Design
Votes
0
Found in
5.6.5f1
Issue ID
999578
Regression
No
[Windows] UnityWebRequest and WWW not handling Content-Encoding header
How to reproduce:
1. Download attached project and open "Launcher" Scene
2. Enter Play mode and hit "Start Request" button with "Use GZIP" checkbox checked (You can see a log with Content-Encoding: gzip, but "Received content" is still gzipped. (Start with 0x1f 0x8b ...) )
3. Uncheck "Use GZIP" and request again (you can see right data content print in the log)
Expected result: Get uncompressed data in log whether or not you check/uncheck "Use GZIP".
Actual result: UnityWebRequest and WWW cannot handle Content-Encoding header in Windows, but works in macOS.
Note: If use macOS, you can see right data content in log (uncompressed) with/without "Use GZIP" checked
Reproduced with: 5.6.5f1, 2017.1.3p1, 2017.2.1p3, 2017.3.1p1, 2018.1.0b6
By Design: Supported content encodings are platform specific.
WWW is a wrapper on top of UnityWebRequest, which has it documented here: https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.SetRequestHeader.html
Comments (5)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Render Pipeline Converter selected asset counter reports one fewer item when using manual selection
- [Android] [Adreno] [WebGL] A light cookie is not rendered with shader compile error when WebGL build is launched on a device with Adreno GPU
- Rigibody sliding over a flat surface that is made of several GameObjects detects false collisions when Collision Detection is set to "Continuous" or "Continuous Dynamic"
- UI Toolkit Label height is incorrectly calculated when using max-width with percentage value
- Visual Effect Material causes Scene view to update continuously when both Scene and Game views are open, despite "Always Refresh" being disabled
tiz777
Jun 14, 2021 20:00
@DOCTORPANGLOSS you saved me! Thank you!!
shubhamswaraj2021
Aug 18, 2020 16:36
good one <a href="https://www.lyricsauto.com">lyricsauto</a>
doctorpangloss
Jan 26, 2019 19:01
I just want to point out that:
1. You say it's documented, and provided a link, and the letters "gzip" do not appear in your link, so clearly the behavior that everyone's observing with gzip only being supported on some platforms is not documented.
2. On your latest scripting runtime, there is gzip compression written in C#:
UnityWebRequest www;
string text;
if (www.GetResponseHeader("Content-Encoding") == "gzip"
&& Application.platform == RuntimePlatform.WindowsPlayer)
{
// GZipStream is from System.IO.Compression in .Net 4.5+
var stream = new StreamReader(new GZipStream(new MemoryStream(www.downloadHandler.data),
CompressionMode.Decompress));
text = stream.ReadToEnd();
stream.Close();
}
else
{
text = www.downloadHandler.text;
}
// Do what you need to do with the text
Debug.Log(text);
// Don't forget to dispose the download handler
www.downloadHandler.Dispose();
splash5
Feb 09, 2018 03:37
Or maybe you can have a callback that letting developers to handle content-encoding which you can not handle.
splash5
Feb 09, 2018 03:30
Ok but some CDN server send Content-Encoding back with gzip even you did not set Accept-Encoding and UnityWebRequest.GetAssetBundle will go wrong.