Adding headers to Get request///

How can I add header information to make the GET request from Unity www class. I use headers in POST method as below and it works.. WWWForm form = new WWWForm(); form.AddField("email", email); form.AddField("password", password); byte[] rawData = form.data;

    Hashtable headers = form.headers;
    headers["Game-Key"] = "549efcadf98";
    headers["Game-Secret"] = "b6dc5%aa7b%a1ff#3696$";

    WWW www = new WWW(url, rawData, headers);

Now, I am trying to get the gamer information with GET request and I've no idea of how to make it... I tried the same as before and WWWForm is for POST only.

The key is leaving “postData” parameter to null. From Unity3D WWW reference

The WWW class will use GET by default
and POST if you supply a postData
parameter.

So this one works for me:

var form = new WWWForm();
var headers = new Hashtable();
headers.Add("Header_key", "Header_val");
www = new WWW("http://localhost/getpostheaders", null, headers);
yield return www;
Debug.Log("2. " + www.text);

Here’s a hacky suggestion.

C# code executed from the editor

string url = "http://mydomain.com/myphpscript.php?param1=value1&param2=value2";
Hashtable headers = new Hashtable();
headers.Add("Cookie", "PHPSESSID=qo62537o8djtojba7f05pu8u83");
WWW www = new WWW(url, new byte[] {(byte) 0}, headers);
yield return www;
Debug.Log(www.text);

PHP back-end script

<?php

print_r(getallheaders());
print_r($_GET);

?>

Output in console

Array
(
  [User-Agent] => UnityPlayer/3.5.2f2 (http://unity3d.com)
  [Host] => mydomain.com
  [Accept] => */*
  [Content-Length] => 1
  [Cookie] => PHPSESSID=qo62537o8djtojba7f05pu8u83
  [Content-Type] => application/x-www-form-urlencoded
)
Array
(
  [param1] => value1
  [param2] => value2
)

The request method is POST, but PHP seems to retrieve the GET parameters anyway.

This may depend on your server-side setting (language and configuration). However this is worth trying.