Hello all. I have to add headers to a webclient async request and everything seems to work in the editor, but whenever I create a build for a device (iOS) the header don’t seem to “stick” for the native requests. For example I do this:
private static readonly string headerKey = "123456789";
public static WebClient client;
public static void DownloadString()
{
using(client = new WebClient())
{
client.Headers.Add("Authorization", headerKey);
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback);
client.DownloadStringAsync(new Uri(nextURL));
}
}
public static void DownloadStringCallback(object sender, DownloadStringCompletedEventArgs args)
{
//Do stuff
}
And this all works fine in the editor. I can get a response to the DownloadStringCallback function and the args parameter contains a valid args.Result
I know this is a problem with the headers being added because I get a response on device but it is a null result. The headers act as a key for a reverse proxy that we have set-up, and when I hit our endpoint directly with a device build I get valid responses just like in the editor.
Is this just a problem with Unity’s translation of a WebClient request into a native iOS request?
If so can I accomplish the same async functionality with another request class? I’m thinking of HttpWebRequest but I don’t know if I am going to have the same problems.