Exemple #1
0
        private void HandleResponse(HttpClientResponse response)
        {
            string responseData = String.Empty;

            response.SetEncoding(Encoding.UTF8);
            response.Data += delegate(string chunk) {
                responseData += chunk;
            };
            response.End += delegate() {
                _webResponse.StatusCode   = response.StatusCode;
                _webResponse.Headers      = response.Headers;
                _webResponse.ResponseText = responseData;

                if (response.Headers["Content-Type"] == "application/json")
                {
                    _webResponse.Response = Json.Parse(responseData);
                }
                else
                {
                    _webResponse.Response = responseData;
                }

                _commandCallback(null, _webResponse.Response);
            };
        }