public byte[] data ;

Description

(只读)发送表单时要作为 POST 请求主体传递的原始数据。

通常,只需将 WWWForm 对象直接传递给 WWW 构造函数,但如果要 更改发送到 Web 服务器的请求标头,则需要使用此变量。

另请参阅:headers 变量。

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ExampleClass : MonoBehaviour { IEnumerator Start() { WWWForm form = new WWWForm(); form.AddField( "name", "value" ); Dictionary<string, string> headers = form.headers; byte[] rawData = form.data; string url = "www.myurl.com";

// Add a custom header to the request. // In this case a basic authentication to access a password protected resource. headers["Authorization"] = "Basic " + System.Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes("username:password"));

// Post a request to an URL with our custom headers using (WWW www = new WWW(url, rawData, headers)) { yield return www; //.. process results from WWW request here... } } }