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
- Crash on mono_dump_native_crash_info when changing a Particle System Renderer’s Material Shader to Standard Unlit
- VFX Prefab doesn’t have Preview icon in Project window and Preview window is empty in Inspector window
- “RenderSettings customReflection texture has invalid type” error keeps getting thrown even when Environment Reflections was set back to Skybox from Custom with an invalid texture
- Particle System with the custom Material breaks the Scene view when the material is using a Shader Graph with the Texture with the power of negative value
- Invalid asset path & Invalid value for font MissingAssetReference Warnings are spammed when deleting a Font used by any Element in UI Builder
tiz777
Jun 14, 2021 20:00
@DOCTORPANGLOSS you saved me! Thank you!!
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.