headers
Request headers to use when posting the form.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.UnityWebRequestModule
public Dictionary<string, string> headers { get; }
Remarks
This field only contains one header, , which is set to the correct "MIME type" for the form: for normal forms and for forms containing data added using WWWForm.AddBinaryData.
Content-Typeapplication/x-www-form-urlencodedmultipart/form-dataUnityWebRequest.PostExamples
using System.Collections.Generic;using UnityEngine;public class Example : MonoBehaviour { void Start () { WWWForm form = new WWWForm(); form.AddField("name", "value"); // Logs "Content-Type: application/x-www-form-urlencoded". foreach (KeyValuePair<string, string> header in form.headers) Debug.Log(header.Key + ": " + header.Value); form.AddBinaryData("file", new byte[] { 1, 2, 3 }, "data.bin"); // The form now contains a file, so this logs // "Content-Type: multipart/form-data; boundary=..." instead. foreach (KeyValuePair<string, string> header in form.headers) Debug.Log(header.Key + ": " + header.Value); }}