Exemple #1
0
        private HttpWebResponse RequestV3Sync(AbstractModel request, string actionName)
        {
            string httpRequestMethod    = this.Profile.HttpProfile.ReqMethod;
            string canonicalQueryString = this.BuildCanonicalQueryString(request);
            string requestPayload       = this.BuildRequestPayload(request);
            string contentType          = this.BuildContentType();

            Dictionary <string, string> headers = this.BuildHeaders(contentType, requestPayload, canonicalQueryString);

            headers.Add("X-TC-Action", actionName);
            string endpoint = headers["Host"];

            HttpConnection conn = new HttpConnection(
                $"{this.Profile.HttpProfile.Protocol }{endpoint}",
                this.Profile.HttpProfile.Timeout,
                this.Profile.HttpProfile.WebProxy);

            try
            {
                if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_GET)
                {
                    return(conn.GetRequestSync(this.Path, canonicalQueryString, headers));
                }
                else
                {
                    return(conn.PostRequestSync(this.Path, requestPayload, headers));
                }
            }
            catch (Exception e)
            {
                throw new TencentCloudSDKException($"The request with exception: {e.Message}");
            }
        }
Exemple #2
0
        private HttpWebResponse RequestV1Sync(AbstractModel request, string actionName)
        {
            HttpWebResponse             response = null;
            Dictionary <string, string> param    = BuildParam(request, actionName);
            HttpConnection conn = this.BuildConnection();

            try
            {
                if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_GET)
                {
                    response = conn.GetRequestSync(this.Path, param);
                }
                else if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_POST)
                {
                    response = conn.PostRequestSync(this.Path, param);
                }
            }
            catch (Exception ex)
            {
                throw new TencentCloudSDKException($"The request with exception: {ex.Message }");
            }

            return(response);
        }