Description
(Read Only) Returns the correct request headers for posting the form using the WWW class.
This field only contains one header, /"Content-Type"/,
which is set to the correct mime type for the form: "application/x-www-form-urlencoded" for normal
forms and "multipart/form-data" for forms containing data added using AddBinaryData.
var form =
new WWWForm();
form.AddField(
"name",
"value");
var headers = form.headers;
var rawData = form.data;
var url =
"www.myurl.com";
headers[
"Authorization"]=
"Basic " + System.Convert.ToBase64String(
System.Text.Encoding.ASCII.GetBytes(
"username:password"));
var www =
new WWW(url, rawData, headers);
yield www;
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
public WWWForm form =
new WWWForm();
public System.Collections.
Hashtable headers = form.headers;
public byte[] rawData = form.data;
public string url =
"www.myurl.com";
public WWW www =
new WWW(url, rawData, headers);
IEnumerator
Awake() {
form.AddField(
"name",
"value");
headers[
"Authorization"] =
"Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(
"username:password"));
yield return www;
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
public form as WWWForm = WWWForm()
public headers as System.Collections.
Hashtable = form.headers
public rawData as (byte) = form.data
public url as
string = 'www.myurl.com'
public www as
WWW =
WWW(url, rawData, headers)
def
Awake() as IEnumerator:
form.AddField('name', 'value')
headers['Authorization'] = ('Basic ' + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes('username:password')))
yield www