예제 #1
0
        public async static Task <HttpWinResponse <T> > FromMessage(HttpResponseMessage message)
        {
            string result = await message.Content.ReadAsStringAsync();

            HttpWinResponse <T> response = new HttpWinResponse <T>(message.StatusCode, result);

            return(response);
        }
예제 #2
0
        public async Task <HttpWinResponse <T> > GetAsync <T>(HttpWinGetRequest request)
        {
            UriBuilder builder = new UriBuilder(this._uri);

            builder.Path  = request.Path;
            builder.Query = request.QueryString;

            HttpWinResponse <T> response = null;

            using (HttpResponseMessage message = await _client.GetAsync(builder.Uri))
            {
                response = await HttpWinResponse <T> .FromMessage(message);
            }
            return(response);
        }
예제 #3
0
        public HttpWinResponse <T> Get <T>(HttpWinGetRequest request)
        {
            UriBuilder builder = new UriBuilder(this._uri);

            builder.Path  = request.Path;
            builder.Query = request.QueryString;

            HttpWinResponse <T> response = null;

            using (HttpResponseMessage message = _client.GetAsync(builder.Uri).Result)
            {
                response = new HttpWinResponse <T>(message);
            }
            return(response);
        }
예제 #4
0
        public HttpWinResponse <T> Post <T>(HttpWinPostRequest request)
        {
            UriBuilder builder = new UriBuilder(this._uri);

            builder.Path = request.Path;

            HttpWinResponse <T> response = null;

            using (HttpContent content = request.GetPostContent())
            {
                HttpResponseMessage message = _client.PostAsync(builder.Uri, content).Result;
                response = new HttpWinResponse <T>(message);
            }

            return(response);
        }
예제 #5
0
        public async Task <HttpWinResponse <T> > PostAsync <T>(HttpWinPostRequest request)
        {
            UriBuilder builder = new UriBuilder(this._uri);

            builder.Path = request.Path;

            HttpWinResponse <T> response = null;

            using (HttpContent content = request.GetPostContent())
            {
                HttpResponseMessage message = await _client.PostAsync(builder.Uri, content);

                response = await HttpWinResponse <T> .FromMessage(message);
            }

            return(response);
        }