コード例 #1
0
ファイル: HttpClient.cs プロジェクト: zhuomingliang/WvsGlobal
        public void Post(Uri uri, logEvent item)
        {
            try
            {
                var httpWebRequest = RequestFor(uri);

                using (var streamWriter = GetRequestStream(httpWebRequest))
                {
                    streamWriter.Write(item.ToJson());
                    streamWriter.Flush();

                    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    httpResponse.Close();

                    if (httpResponse.StatusCode != HttpStatusCode.Created)
                    {
                        throw new WebException(
                                  "Failed to post {0} to {1}.".With(item.GetType().Name, uri));
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO this is a hotfix
            }
        }
コード例 #2
0
        public void Post(Uri uri, logEvent item)
        {
            var httpWebRequest = RequestFor(uri);

            using (var streamWriter = GetRequestStream(httpWebRequest))
            {
                streamWriter.Write(item.ToJson(resolver));
                streamWriter.Flush();

                using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                {
                    if (httpResponse.StatusCode != HttpStatusCode.Created)
                    {
                        throw new WebException("Failed to post {0} to {1}.".With(item.GetType().Name, uri));
                    }
                }
            }
        }