Search Unity

UnityWebRequest, Setting 'user-agent' is not allowed

Discussion in 'Scripting' started by srivello, Sep 15, 2016.

?

Do you recommend Unity change the UnityWebRequest API and allow custom values for 'user-agent'?

  1. Yes

    25 vote(s)
    96.2%
  2. No

    0 vote(s)
    0.0%
  3. No opinion

    1 vote(s)
    3.8%
  1. srivello

    srivello

    Joined:
    Jan 16, 2011
    Posts:
    16
    UnityWebRequest is meant as a replacement for WWW.

    According to UnityWebRequest Documentation;

    https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.SetRequestHeader.html

    "The user-agent and x-unity-version headers are automatically set by Unity and may not be set to custom values."

    This limits development options for our team. Historically, we populate 'user-agent' with a custom value.
    1. Is this limitation acceptable to the community in general?
    2. Any workarounds to recommend?
     
  2. undersun81

    undersun81

    Joined:
    Feb 15, 2013
    Posts:
    5
    If we don't have possibility to override or add data to User-Agent then we can't use GZip compression with Google Apps Engine.
    From GAE docs:
    "Custom clients can indicate that they are able to receive compressed responses by specifying both Accept-Encoding and User-Agent headers with a value of gzip."
     
  3. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    491
    The inflexible headers seem to be a problem if dealing with AWS authentication, too - where you're expected to have total control over the HTTP request, or at least total knowledge of what goes into it, in order to generate a signature.

    But if you bypass UnityWebRequest when downloading AssetBundles, and implement the HTTP download yourself, you're locked out from using the asset bundle caching functionality, as you can't manually put data in that cache.

    And you're also prevented from using the hashes in manifest bundles, as there's no documented way to compute a Hash128 from the data you've downloaded.

    (Edit: Turns out that there's multiple ways to authenticate with AWS, and this one looks like it should be fine in cases where you can't fully control the request headers)
     
    Last edited: Mar 31, 2017