private async Task <HttpResponseMessage> RequestV1(AbstractModel request, string actionName) { Dictionary <string, string> param = BuildParam(request, actionName); string endpoint = this.Endpoint; if (!string.IsNullOrEmpty(this.Profile.HttpProfile.Endpoint)) { endpoint = this.Profile.HttpProfile.Endpoint; } HttpConnection conn = new HttpConnection( $"{this.Profile.HttpProfile.Protocol }{endpoint}", this.Profile.HttpProfile.Timeout, this.Profile.HttpProfile.WebProxy, this.HttpClient); try { if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_GET) { return(await conn.GetRequestAsync(this.Path, param)); } else if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_POST) { return(await conn.PostRequestAsync(this.Path, param)); } return(null); } catch (Exception ex) { throw new TencentCloudSDKException($"The request with exception: {ex.Message }"); } }
private async Task <HttpResponseMessage> RequestV3(AbstractModel request, string actionName) { 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, this.HttpClient); try { if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_GET) { return(await conn.GetRequestAsync(this.Path, canonicalQueryString, headers)); } else if (this.Profile.HttpProfile.ReqMethod == HttpProfile.REQ_POST) { return(await conn.PostRequestAsync(this.Path, requestPayload, headers)); } return(null); } catch (Exception e) { throw new TencentCloudSDKException($"The request with exception: {e.Message}"); } }