public KiiTestHttpResponse SendRequest()
        {
            try
            {
                HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse();

                KiiTestHttpResponse res = new KiiTestHttpResponse();
                // status
                res.Status = (int)httpResponse.StatusCode;
                // Etag
                res.ETag = httpResponse.Headers ["ETag"];
                // ContentType
                res.ContentType = httpResponse.ContentType;
                // read body
                res.Body = ReadBodyFromResponse(httpResponse);

                return(res);
            } catch (System.Net.WebException e)
            {
                Console.Write("Exception " + e.Message);
                System.Net.HttpWebResponse err = (System.Net.HttpWebResponse)e.Response;
                // read body
                string body = ReadBodyFromResponse(err);

                throw new KiiTestHttpException((int)err.StatusCode, body);
            }
        }
Esempio n. 2
0
        public static string get(string url, string appId, string appKey, string token)
        {
            KiiTestHttpClient client = new KiiTestHttpClientImpl(url, appId, appKey, KiiTestHttpMethod.GET);

            client.Headers["Authorization"] = "Bearer " + token;
            KiiTestHttpResponse response = client.SendRequest();

            return(response.Body);
        }