Exemple #1
0
        private (HttpClient, HttpContent) Create(HttpClient _client, HClientCookie _clientCookie, HClientHeader _clientHeader, string _json = null)
        {
            HttpClient  client   = null;
            HttpContent hContent = null;

            client = HClientService.Create(_client, _clientCookie, _clientHeader);
            if (_json != null)
            {
                hContent = HContentService.Create(_json);
            }
            else
            {
                hContent = HContentService.Create(_clientHeader);
            }
            return(client, hContent);
        }
Exemple #2
0
        public async Task <HClientResponse> Post(string _requestUrl, HClientCookie _clientCookie = null, HClientHeader _clientHeader = null, HMultipart multipart = null)
        {
            try
            {
                var instance = Create(client, _clientCookie, _clientHeader, multipart);
                client = instance.Item1;
                var content       = instance.Item2;
                var resultMessage = await client.PostAsync(_requestUrl, content);

                hResponse = new HClientResponse(resultMessage);
            }
            catch (Exception ex)
            {
                hResponse = null;
                throw new Exception(ex.Message);
            }
            return(hResponse);
        }