Search Issue Tracker

Fixed in future release

Votes

5

Found in

2017.1.0f3

Issue ID

932312

Regression

Yes

[WWW][UnityWebRequest] InvalidOperationException when User-Agent header contains parenthesis

Networking

-

-

Priority: 2Necessary for shipping a final release

-

Severity: 3Workaround is possible

Steps to reproduce:
1. Open project
2. Enter play mode
3. Observe the console

Result:
InvalidOperationException: Header value contains invalid characters
UnityEngine.Networking.UnityWebRequest.SetRequestHeader (System.String name, System.String value) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/UnityWebRequest/WebRequestBindings.gen.cs:479)

Reproduced on: 2017.1.0f3, 2017.2.0b2
Did not reproduce on: 5.5.4p1, 5.6.2p4

Note: Removing parenthesis "(" and ")" eliminates the error

Comments (2)

  1. E8095658fd38fcea440a74a560c5f954?d=mm

    Hosnkobf

    Aug 28, 2017 13:23

    Thanks EILIOMM,

    It seems to be really only the brackets... I first tried to escape it in different ways without success.
    In the end I just replaced the brackets and it works.

    [code]
    string Escape(string s)
    {
    s = s.Replace("(", "&#40");
    s = s.Replace(")", "&#41");
    return s;
    }
    [/code]

  2. F2d5a94c2bb9f4bc453198d4c093fd3a?d=mm

    emiliomm

    Aug 09, 2017 10:52

    I found a way to bypass the issue for those who need the header to work and are stuck with the 2017.x version.

    Simply replace the characters "(" for "&#40" and ")" for "&#41". These are the html escape characters and seem to work fine for me.

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.