Esempio n. 1
0
        private void BeginRequest(string url, byte[] data, Dictionary <string, string> headers)
        {
            // Got to run on the main thread:
            Callback.MainThread(delegate(){
                                #if UNITY_2017_1_OR_NEWER
                WWWRequest = UnityEngine.Networking.UnityWebRequest.Get(url);

                if (data != null)
                {
                    WWWRequest.method  = "POST";
                    var handler        = new UnityEngine.Networking.UploadHandlerRaw(data);
                    string contentType = null;
                    if (headers == null || !headers.TryGetValue("content-type", out contentType))
                    {
                        contentType = "application/json";
                    }
                    handler.contentType = contentType;

                    if (headers != null)
                    {
                        foreach (var headerPair in headers)
                        {
                            var key = headerPair.Key;

                            if (
                                key == "accept-charset" || key == "access-control-request-headers" ||
                                key == "access-control-request-method" || key == "connection" || key == "date" ||
                                key == "dnt" || key == "expect" || key == "host" || key == "keep-alive" ||
                                key == "origin" || key == "referer" || key == "te" || key == "trailer" ||
                                key == "transfer-encoding" || key == "upgrade" || key == "via"
                                )
                            {
                                continue;
                            }

                            WWWRequest.SetRequestHeader(headerPair.Key, headerPair.Value);
                        }
                    }

                    WWWRequest.uploadHandler = handler;
                }
                                #else
                // Create the request:
                if (headers == null)
                {
                    WWWRequest = new WWW(url, data);
                }
                else
                {
                    WWWRequest = new WWW(url, data, headers);
                }
                                #endif
            });
        }
Esempio n. 2
0
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Byte[] data = (System.Byte[]) typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = new UnityEngine.Networking.UploadHandlerRaw(data);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Esempio n. 3
0
        private void SendMessage(string message)
        {
            try
            {
                var request             = UnityEngine.Networking.UnityWebRequest.Post("https://api.raygun.com/entries", message);
                var customUploadHandler = new UnityEngine.Networking.UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(message));
                customUploadHandler.contentType = "application/json";
                request.uploadHandler           = customUploadHandler;

                request.SetRequestHeader("X-ApiKey", _apiKey);

                request.SendWebRequest();
            }
            catch (Exception ex)
            {
                RaygunClient.Log(string.Format("Error Logging Exception to Raygun {0}", ex.Message));
            }
        }