コード例 #1
0
        private HttpRequestMessage PrepareRequest(HttpMethod method, object body, string path,
                                                  Dictionary <string, string> customHeaders = null)
        {
            var url = $"{_configuration.BasePath}{path}";

            var request = new HttpRequestMessage(method, url);

            request.Headers.Add("User-Agent", UserAgent);

            request.Headers.Add("Accept", "application/json");

            if (customHeaders != null)
            {
                foreach (var header in customHeaders)
                {
                    request.Headers.Add(header.Key, header.Value);
                }
            }

            if (body != null)
            {
                var content        = new JsonRequestContent(body, _configuration.Serializer);
                var requestContent = content.GetContent();
                request.Content = requestContent;
            }

            return(request);
        }
コード例 #2
0
ファイル: HttwrapClient.cs プロジェクト: liu2510865/Httwrap
        private HttpRequestMessage PrepareRequest(HttpMethod method, object body, string path)
        {
            var url = $"{_configuration.BasePath}{path}";

            var request = new HttpRequestMessage(method, url);

            request.Headers.Add("User-Agent", UserAgent);

            request.Headers.Add("Accept", "application/json");

            if (body != null)
            {
                var content        = new JsonRequestContent(body, _configuration.Serializer);
                var requestContent = content.GetContent();
                request.Content = requestContent;
            }

            return(request);
        }