Serious Bug UnityWebRequest.SetRequestHeader is not working in non development mode on Android


I have an android app with the following

post.SetRequestHeader("Authorization", authorizationHeader);

Which works perfectly when I build with ‘Development Build’ option, but the header is not set when I run the same exact code on device with ‘Development Build’ off.

The following code also runs with development build option on, but doesn’t work with the option off.

MethodInfo dynMethod = post.GetType().GetMethod("InternalSetRequestHeader", BindingFlags.NonPublic | BindingFlags.Instance);
dynMethod.Invoke(post, new object[] { "Authorization", authorizationHeader });

I am using Unity 5.4.0f3
Any help is greatly appreciated.


The same problem happens with iOS build with ‘development build’ option off.

It seems to be a mistake from the production server hosting which seems to strip down the authorization header for some reason, but unity seems to send the authorization header.