Exemplo n.º 1
0
    private static void BuilderPost(string uri, Hashtable data)
    {
        var statusUrl = EnvironmentUtils.Get("BUILD_STATUS_URL", string.Empty);

        if (!string.IsNullOrEmpty(statusUrl))
        {
            var jsonData = EB.Encoding.GetBytes(EB.JSON.Stringify(data));
            var url      = statusUrl + uri;

            //Hashtable headers = new Hashtable();
            //headers["Content-Type"] = "application/json";
            System.Collections.Generic.Dictionary <string, string> headers = new System.Collections.Generic.Dictionary <string, string>();
            headers.Add("Content-Type", "application/json");

            //headers["Content-Length"] = jsonData.Length;	// moko: unity 4.3 will handle www raw data lenght for you
            //EB.Debug.Log("Headers: {0}", headers);

            var www = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST);
            www.uploadHandler   = (UploadHandler) new UploadHandlerRaw(jsonData);
            www.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            www.SetRequestHeader("Content-Type", "application/json");

            //var www = new WWW(url, jsonData, headers);
            //EB.Debug.Log("Status: " + www.url);
            WWWUtils.WaitOnWWW(www, false);
            //EB.Debug.Log("result: " + www.text);
        }
        else
        {
            Debug.LogWarning("Can not fetch env var 'BUILD_STATUS_URL' for posting builder email");
        }
    }