- Home /
 
WWW Form upload with header not working
Hi, I am trying to upload an image file from Unity where the webserver need authorisation header from authentication.
 WWWForm  form = new WWWForm();
 form.AddBinaryData("file", data, fileName, contentType);
 WWW www = new WWW(url, form);
 
               it works fine.. But problems comes up when I use something like this even without header..
 byte[] rawData = form.data;
 WWW www = new WWW(url, rawData);
 
               and it doesn't.. I even added some header information like this is and doesn't work either.
 Hashtable headers = new Hashtable();
 Dictionary<string, string> parameters = new Dictionary<string, string>();
 string strHeader = "something";
 headers["Authorization"] = strHeader;
 byte[] rawData = form.data;
 WWW www = new WWW(url, rawData, headers);
 
              Answer by Simon Wittber · Feb 08, 2012 at 03:15 AM
The WWW class doesn't let you do many normal HTTP things. UniWeb provides complete support for HTTP. It should support everything you need.
yes, I know about Uniweb which is a TCPClient implementation. I am currently needing WWWForm for multi-part file upload as this kind of feature is not currently available in Uniweb.. Fortunately, the header thing is kinda work with WWWForm right now.. Thanks for answering the question.. :)
oops.. really.. I didn't know that.. Thanks for the info.
Answer by Sylafrs · May 18, 2015 at 08:03 PM
Just came with the same issue.
Using AddBinaryData clears added headers :/
Seen with wireshark.. with Unity 5.0.1f1 :/
We must use TCPClient or Uniweb (that uses TCPClient) or wait for Unity to fix this (will that ever happen?) ^^'
Your answer