Exemplo n.º 1
0
 public Page Extract(HttpResponseObject httpResponse)
 {
     return(new NotFoundPage(httpResponse.RequestUrl.ToString())
     {
         Reason = httpResponse?.ExceptionThrown?.Message ?? "Unknown"
     });
 }
Exemplo n.º 2
0
 public HttpResponseObject Message(long baseTick)
 {
     var messages = _interChatMessageLock.DoRead(() => _lastMessages.Reverse().Take(LastWebMessageCount)
                                                           .Where(e => e.Ticks > baseTick)
                                                           .Select(e => new { name = e.Name, message = e.Message, time = new DateTime(e.Ticks).ToString("HH:mm:ss"), tick = e.Ticks }));
     return HttpResponseObject.FromJson(messages);
 }
Exemplo n.º 3
0
 private ActionResult RequestHandler(HttpResponseObject response)
 {
     if (response == null || string.IsNullOrEmpty(response.contentType))
     {
         return(Content("wms response is emtpy"));
     }
     return(new FileStreamResult(response.responseStream, response.contentType));
 }
Exemplo n.º 4
0
        public HttpResponseObject SendMessage(string userName, string message)
        {
            if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(message))
                return HttpResponseObject.FromJson(new { result = "error" });

            message = HttpUtility.UrlDecode(message);
            BroadcastChatMsgWithLock(userName, message);
            return HttpResponseObject.FromJson(new { result = "ok" });
        }
 public Page Extract(HttpResponseObject httpResponse)
 {
     return(new NotAuthorizedPage(GetPageId(httpResponse.RequestUrl, httpResponse.Headers))
     {
         Url = httpResponse.RequestUrl,
         Status = (int)httpResponse.StatusCode,
         Reason = httpResponse.ExceptionThrown?.Message,
     });
 }
Exemplo n.º 6
0
        public Page Extract(HttpResponseObject httpResponse)
        {
            var html = httpResponse.Encoding.GetString(httpResponse.Response);

            return(new WebPage(GetPageId(httpResponse.RequestUrl, httpResponse.Headers))
            {
                Url = httpResponse.RequestUrl,
                Html = html,
                ContentType = httpResponse.ContentType,
                VerifyDate = GetVerifyDate(httpResponse.Headers, httpResponse.ConfigUsed)
            });
        }
Exemplo n.º 7
0
        private ActionResult RequestHandler(string requestURI, string contentType = "", string referer = "", string userName = "", string password = "")
        {
            HttpRequestObject requestObject = new HttpRequestObject();

            requestObject.requestURI  = requestURI;
            requestObject.contentType = contentType;
            requestObject.referer     = referer;
            requestObject.userName    = userName;
            requestObject.password    = password;

            HttpResponseObject responseObject = SendHttpRequest.WmsRequest(requestObject);

            return(new FileStreamResult(responseObject.responseStream, responseObject.contentType));
        }
Exemplo n.º 8
0
        private static void ProcessJsonResponse(CallRequestContainer reqContainer)
        {
            try
            {
                HttpResponseObject httpResponseObject = JsonWrapper.DeserializeObject <HttpResponseObject>(reqContainer.JsonResponse);
                if (httpResponseObject == null || httpResponseObject.code != 200)
                {
                    PlayFabWebRequest.QueueRequestError(reqContainer);
                }
                else
                {
                    reqContainer.JsonResponse = JsonWrapper.SerializeObject(httpResponseObject.data);
                    reqContainer.DeserializeResultJson();
                    reqContainer.ApiResult.Request    = reqContainer.ApiRequest;
                    reqContainer.ApiResult.CustomData = reqContainer.CustomData;
                    SingletonMonoBehaviour <PlayFabHttp> .instance.OnPlayFabApiResult(reqContainer.ApiResult);

                    object resultQueue = PlayFabWebRequest.ResultQueue;
                    lock (resultQueue)
                    {
                        PlayFabWebRequest.ResultQueue.Enqueue(delegate
                        {
                            PlayFabDeviceUtil.OnPlayFabLogin(reqContainer.ApiResult);
                        });
                    }
                    object resultQueue2 = PlayFabWebRequest.ResultQueue;
                    lock (resultQueue2)
                    {
                        PlayFabWebRequest.ResultQueue.Enqueue(delegate
                        {
                            try
                            {
                                PlayFabHttp.SendEvent(reqContainer.ApiEndpoint, reqContainer.ApiRequest, reqContainer.ApiResult, ApiProcessingEventType.Post);
                                reqContainer.InvokeSuccessCallback();
                            }
                            catch (Exception ex2)
                            {
                            }
                        });
                    }
                }
            }
            catch (Exception innerException)
            {
                string text = "Unhandled exception in ProcessJsonResponse : " + reqContainer.FullUrl;
                reqContainer.JsonResponse = (reqContainer.JsonResponse ?? text);
                Exception ex = new Exception(text, innerException);
                PlayFabWebRequest.QueueRequestError(reqContainer);
            }
        }
Exemplo n.º 9
0
 private bool ValidateResponse(HttpResponseObject httpResponseObject)
 {
     if (httpResponseObject != null && !httpResponseObject.contentType.Contains("text"))
     {
         return(true);
     }
     else
     {
         if (httpResponseObject != null)
         {
             using (StreamReader reader = new StreamReader(httpResponseObject.responseStream))
                 Loggers.ApplicationLogger.ErrorFormat(reader.ReadToEnd());
         }
     }
     return(false);
 }
Exemplo n.º 10
0
        public Page Extract(HttpResponseObject httpResponse)
        {
            var id = GetPageId(httpResponse.RequestUrl, httpResponse.Headers);

            if (httpResponse.ConfigUsed.PageFilter.ExcludeBinaryPages)
            {
                return new IgnoredPage(id, $"Binary page of content type '{httpResponse.ContentType}' (PageFilter.ExcludeBinaryPages is enabled)")
                       {
                           Url         = httpResponse.RequestUrl,
                           ContentType = httpResponse.ContentType
                       }
            }
            ;
            return(new BinaryPage(id)
            {
                Url = httpResponse.RequestUrl,
                ContentType = httpResponse.ContentType,
                Data = httpResponse.Response,
                VerifyDate = GetVerifyDate(httpResponse.Headers, httpResponse.ConfigUsed)
            });
        }
Exemplo n.º 11
0
        private HttpResponseObject CreateResponseObject(HttpResponseMessage response, WebConnectorJobConfiguration config)
        {
            Encoding encoding       = GetEncoding(response);
            var      responseObject = new HttpResponseObject()
            {
                RequestUrl  = response.RequestMessage.RequestUri,
                ConfigUsed  = config,
                ContentType = response.Content.Headers.ContentType.MediaType,
                Encoding    = encoding,
                Headers     = response.Content.Headers,
                StatusCode  = response.StatusCode,
            };

            using (var sr = response.Content.ReadAsStreamAsync().Result)
            {
                responseObject.Response = ReadFully(sr, response.Content.Headers.ContentLength);
            }


            return(responseObject);
        }
Exemplo n.º 12
0
        public void OnResponse(string response, CallRequestContainer reqContainer)
        {
            try
            {
                HttpResponseObject httpResponseObject = JsonWrapper.DeserializeObject <HttpResponseObject>(response);
                if (httpResponseObject.code == 200)
                {
                    reqContainer.JsonResponse = JsonWrapper.SerializeObject(httpResponseObject.data);
                    reqContainer.DeserializeResultJson();
                    reqContainer.ApiResult.Request    = reqContainer.ApiRequest;
                    reqContainer.ApiResult.CustomData = reqContainer.CustomData;
                    SingletonMonoBehaviour <PlayFabHttp> .instance.OnPlayFabApiResult(reqContainer.ApiResult);

                    PlayFabDeviceUtil.OnPlayFabLogin(reqContainer.ApiResult);
                    try
                    {
                        PlayFabHttp.SendEvent(reqContainer.ApiEndpoint, reqContainer.ApiRequest, reqContainer.ApiResult, ApiProcessingEventType.Post);
                    }
                    catch (Exception ex)
                    {
                    }
                    try
                    {
                        reqContainer.InvokeSuccessCallback();
                    }
                    catch (Exception ex2)
                    {
                    }
                }
                else if (reqContainer.ErrorCallback != null)
                {
                    reqContainer.Error = PlayFabHttp.GeneratePlayFabError(reqContainer.ApiEndpoint, response, reqContainer.CustomData);
                    PlayFabHttp.SendErrorEvent(reqContainer.ApiRequest, reqContainer.Error);
                    reqContainer.ErrorCallback(reqContainer.Error);
                }
            }
            catch (Exception ex3)
            {
            }
        }
 public bool CanHandle(HttpResponseObject httpResponse)
 {
     return(httpResponse.StatusCode == HttpStatusCode.Unauthorized || httpResponse.StatusCode == HttpStatusCode.Forbidden);
 }
Exemplo n.º 14
0
 public bool CanHandle(HttpResponseObject httpResponse)
 {
     return(StatusCodeIsGreen(httpResponse.StatusCode) &&
            ValidContentTypes.Any(valid => httpResponse.ContentType.Contains(valid)));
 }
Exemplo n.º 15
0
 public bool CanHandle(HttpResponseObject httpResponse)
 {
     return(httpResponse.StatusCode == HttpStatusCode.NotFound);
 }
Exemplo n.º 16
0
 public bool CanHandle(HttpResponseObject httpResponse)
 {
     return(StatusCodeIsGreen(httpResponse.StatusCode) && httpResponse.ContentType.Contains("application/"));
 }
Exemplo n.º 17
0
 public HttpHeaderObject()
 {
     Type     = "http";
     request  = new();
     response = new();
 }
Exemplo n.º 18
0
        public void MakeApiCall(CallRequestContainer reqContainer)
        {
            reqContainer.RequestHeaders["Content-Type"] = "application/json";
            if (PlayFabSettings.CompressApiData)
            {
                reqContainer.RequestHeaders["Content-Encoding"] = "GZIP";
                reqContainer.RequestHeaders["Accept-Encoding"]  = "GZIP";
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, Ionic.Zlib.CompressionLevel.BestCompression))
                    {
                        gzipStream.Write(reqContainer.Payload, 0, reqContainer.Payload.Length);
                    }
                    reqContainer.Payload = memoryStream.ToArray();
                }
            }
            WWW             www = new WWW(reqContainer.FullUrl, reqContainer.Payload, reqContainer.RequestHeaders);
            Action <string> wwwSuccessCallback = delegate(string response)
            {
                try
                {
                    HttpResponseObject httpResponseObject = JsonWrapper.DeserializeObject <HttpResponseObject>(response);
                    if (httpResponseObject.code == 200)
                    {
                        reqContainer.JsonResponse = JsonWrapper.SerializeObject(httpResponseObject.data);
                        reqContainer.DeserializeResultJson();
                        reqContainer.ApiResult.Request    = reqContainer.ApiRequest;
                        reqContainer.ApiResult.CustomData = reqContainer.CustomData;
                        SingletonMonoBehaviour <PlayFabHttp> .instance.OnPlayFabApiResult(reqContainer.ApiResult);

                        PlayFabDeviceUtil.OnPlayFabLogin(reqContainer.ApiResult);
                        try
                        {
                            PlayFabHttp.SendEvent(reqContainer.ApiEndpoint, reqContainer.ApiRequest, reqContainer.ApiResult, ApiProcessingEventType.Post);
                        }
                        catch (Exception ex)
                        {
                        }
                        try
                        {
                            reqContainer.InvokeSuccessCallback();
                        }
                        catch (Exception ex2)
                        {
                        }
                    }
                    else if (reqContainer.ErrorCallback != null)
                    {
                        reqContainer.Error = PlayFabHttp.GeneratePlayFabError(reqContainer.ApiEndpoint, response, reqContainer.CustomData);
                        PlayFabHttp.SendErrorEvent(reqContainer.ApiRequest, reqContainer.Error);
                        reqContainer.ErrorCallback(reqContainer.Error);
                    }
                }
                catch (Exception ex3)
                {
                }
            };
            Action <string> wwwErrorCallback = delegate(string errorCb)
            {
                reqContainer.JsonResponse = errorCb;
                if (reqContainer.ErrorCallback != null)
                {
                    reqContainer.Error = PlayFabHttp.GeneratePlayFabError(reqContainer.ApiEndpoint, reqContainer.JsonResponse, reqContainer.CustomData);
                    PlayFabHttp.SendErrorEvent(reqContainer.ApiRequest, reqContainer.Error);
                    reqContainer.ErrorCallback(reqContainer.Error);
                }
            };

            SingletonMonoBehaviour <PlayFabHttp> .instance.StartCoroutine(this.PostPlayFabApiCall(www, wwwSuccessCallback, wwwErrorCallback));
        }
Exemplo n.º 19
0
 public HttpResponseObject UserList()
 {
     var users = _interChatLock.DoRead(() => _interChatUserMap.Values);
     return HttpResponseObject.FromJson(users);
 }