Пример #1
0
        internal HttpJsonRequest(CreateHttpJsonRequestParams requestParams, HttpJsonRequestFactory factory)
        {
            this.url         = requestParams.Url;
            this.conventions = requestParams.Convention;
            this.factory     = factory;
            webRequest       = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(new Uri(url));
            noopWaitForTask  = new CompletedTask();
            WaitForTask      = noopWaitForTask;

            webRequest.Headers["Raven-Client-Version"] = ClientVersion;

            WriteMetadata(requestParams.Metadata);
            webRequest.Method = requestParams.Method;
            if (requestParams.Method != "GET")
            {
                webRequest.ContentType = "application/json; charset=utf-8";
            }

            if (factory.DisableRequestCompression == false && requestParams.DisableRequestCompression == false)
            {
                if (requestParams.Method == "POST" || requestParams.Method == "PUT" ||
                    requestParams.Method == "PATCH" || requestParams.Method == "EVAL")
                {
                    webRequest.Headers["Content-Encoding"] = "gzip";
                }
            }
        }
Пример #2
0
        internal HttpJsonRequest(CreateHttpJsonRequestParams requestParams, HttpJsonRequestFactory factory)
        {
            _credentials     = requestParams.Credentials;
            Url              = requestParams.Url;
            this.conventions = requestParams.Convention;
            this.factory     = factory;

            noopWaitForTask = new CompletedTask();
            WaitForTask     = noopWaitForTask;

            handler = new HttpClientHandler
            {
            };
            httpClient = new HttpClient(handler);
            httpClient.DefaultRequestHeaders.Add("Raven-Client-Version", ClientVersion);

            WriteMetadata(requestParams.Metadata);
            Method = requestParams.Method;
            if (requestParams.Method != "GET")
            {
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")
                {
                    CharSet = "utf-8"
                });
            }

            if (factory.DisableRequestCompression == false && requestParams.DisableRequestCompression == false)
            {
                if (requestParams.Method == "POST" || requestParams.Method == "PUT" ||
                    requestParams.Method == "PATCH" || requestParams.Method == "EVAL")
                {
                    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Encoding", "gzip");
                }
            }
        }
Пример #3
0
        public HttpJsonRequest CreateHttpJsonRequest(CreateHttpJsonRequestParams createHttpJsonRequestParams)
        {
            var request = new HttpJsonRequest(createHttpJsonRequestParams, this);

            ConfigureRequest(createHttpJsonRequestParams.Owner, new WebRequestEventArgs {
                Request = request.webRequest, JsonRequest = request
            });
            return(request);
        }
Пример #4
0
        public HttpJsonRequest CreateHttpJsonRequest(CreateHttpJsonRequestParams createHttpJsonRequestParams)
        {
            var request = new HttpJsonRequest(createHttpJsonRequestParams, this);

            ConfigureRequest(createHttpJsonRequestParams.Owner, new WebRequestEventArgs {
                Client = request.httpClient, JsonRequest = request, Credentials = createHttpJsonRequestParams.Credentials
            });
            return(request);
        }
Пример #5
0
        /// <summary>
        /// Creates the HTTP json request.
        /// </summary>
        public HttpJsonRequest CreateHttpJsonRequest(CreateHttpJsonRequestParams createHttpJsonRequestParams)
        {
            var request = new HttpJsonRequest(createHttpJsonRequestParams.Url, createHttpJsonRequestParams.Method, createHttpJsonRequestParams.Metadata, createHttpJsonRequestParams.Convention, this);

            ConfigureRequest(createHttpJsonRequestParams.Self, new WebRequestEventArgs {
                Request = request.webRequest, JsonRequest = request
            });
            return(request);
        }