示例#1
0
        private async Task DownloadUpdate(HttpPackageIndex index)
        {
            if (!Directory.Exists(updateDirectory))
            {
                Directory.CreateDirectory(updateDirectory);
            }

            try {
                var url = NetPath.Combine(Configuration.DownloadUrl, "CLI", index.Version, index.MsiFilename);

                using (var client = HttpClientEx.Get(url)) {
                    await client.Send();

                    using (var fileStream = File.Open(updateFilename, FileMode.Create, FileAccess.Write))
                        using (var responseStream = client.ResponseBase.GetResponseStream()) {
                            if (responseStream != null)
                            {
                                await responseStream.CopyToAsync(fileStream);
                            }
                        }
                }
            }
            catch (HttpStatusCodeException error) {
                throw new ApplicationException("Failed to download CLI update!", error);
            }
        }
示例#2
0
        public AlipayClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayClient> logger)
        {
            Options = optionsAccessor?.Value ?? new AlipayOptions();
            Logger  = logger;

            Client = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.AppId))
            {
                throw new ArgumentNullException(nameof(Options.AppId));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            RSAPrivateParameters = AlipaySignature.GetPrivateParameters(Options.RsaPrivateKey);
            RSAPublicParameters  = AlipaySignature.GetPublicParameters(Options.RsaPublicKey);
        }
示例#3
0
        protected override bool GetInfomationPriv(HttpClientEx hc, ref int count)
        {
            // Short uri 검증용 페이지
            Uri newUri = null;

            var succ = Utility.Retry((retries) => Utility.ResolvUri(hc, this.Uri, out newUri));

            if (succ && newUri != null)
            {
                Comic comic = null;

                if (DaruUriParser.Detail.CheckUri(newUri))
                {
                    comic = new DetailPage(this.AddNewonly, newUri, null, false);
                }

                else if (DaruUriParser.Manga.CheckUri(newUri))
                {
                    comic = new MangaPage(this.AddNewonly, newUri, null, null);
                }

                if (comic != null)
                {
                    MainWindow.Instance.InsertNewComic(this, new Comic[] { comic }, true);
                }
                else
                {
                    this.State = MaruComicState.Error_3_NotSupport;
                }
            }

            // 항상 실패로 전달해서 기록등 기타 작업을 하지 않도록 한다
            return(false);
        }
示例#4
0
        public QPayClient(
            IOptions <QPayOptions> optionsAccessor,
            ILogger <QPayClient> logger)
        {
            Options = optionsAccessor.Value;
            Logger  = logger;
            Client  = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.MchId))
            {
                throw new ArgumentNullException(nameof(Options.MchId));
            }

            if (string.IsNullOrEmpty(Options.Key))
            {
                throw new ArgumentNullException(nameof(Options.Key));
            }

            if (!string.IsNullOrEmpty(Options.Certificate))
            {
                var clientHandler = new HttpClientHandler();
                clientHandler.ClientCertificates.Add(File.Exists(Options.Certificate) ? new X509Certificate2(Options.Certificate, Options.MchId) :
                                                     new X509Certificate2(Convert.FromBase64String(Options.Certificate), Options.MchId, X509KeyStorageFlags.MachineKeySet));
                CertificateClient = new HttpClientEx(clientHandler);
            }
        }
示例#5
0
        protected override bool GetInfomationPriv(HttpClientEx hc, ref int count)
        {
            MangaInfomation mangaInfo  = null;
            HttpStatusCode  statusCode = 0;

            var retrySuccess = Utility.Retry((retries) => (mangaInfo = this.GetInfomationWorker(hc, retries, out statusCode)) != null);

            if (!retrySuccess)
            {
                this.SetStatusFromHttpStatusCode(statusCode);
                return(false);
            }

            this.Uri = mangaInfo.NewUri;

            this.ProgressValue   = 0;
            this.ProgressMaximum = mangaInfo.Images.Count;

            this.m_images = mangaInfo.Images.ToArray();

            // 다운로드 시작
            this.State = MaruComicState.Working_2_WaitDownload;

            count = 1;

            return(true);
        }
示例#6
0
        public async Task <T> ExecuteAsync <T>(IWeChatPayRequest <T> request) where T : WeChatPayResponse
        {
            // 字典排序
            var sortedTxtParams = new WeChatPayDictionary(request.GetParameters())
            {
                { APPID, Options.AppId },
                { MCH_ID, Options.MchId },
                { NONCE_STR, Guid.NewGuid().ToString("N") }
            };

            sortedTxtParams.Add(SIGN, WeChatPaySignature.SignWithKey(sortedTxtParams, Options.Key));
            var content = HttpClientEx.BuildContent(sortedTxtParams);

            Logger.LogInformation(0, "Request Content:{content}", content);

            var rspContent = await Client.DoPostAsync(request.GetRequestUrl(), content);

            Logger.LogInformation(1, "Response Content:{content}", rspContent);

            var parser = new WeChatPayXmlParser <T>();
            var rsp    = parser.Parse(rspContent);

            CheckResponseSign(rsp);
            return(rsp);
        }
示例#7
0
        private bool DownloadWorker(HttpClientEx hc, ImageInfomation e, int uriIndex)
        {
            using (var req = new HttpRequestMessage(HttpMethod.Get, e.ImageUri[uriIndex]))
            {
                req.Headers.Referrer = this.Uri;

                using (var res = hc.SendAsync(req).Exec())
                {
                    if ((int)res.StatusCode / 100 != 2)
                    {
                        return(false);
                    }

                    e.TempStream.SetLength(0);
                    using (var fileWriter = new StreamWithNotify(e.TempStream, count => Interlocked.Add(ref this.m_downloaded, count)))
                        res.Content.CopyToAsync(fileWriter).Wait();
                }

                e.TempStream.Flush();

                e.TempStream.Position = 0;
                e.Extension           = Signatures.GetExtension(e.TempStream);

                if (e.Extension == null)
                {
                    return(false);
                }

                // 이미지 암호화 푸는 작업
                this.m_decryptor.Decrypt(e.TempStream);
            }

            this.IncrementProgress();
            return(true);
        }
示例#8
0
        public AlipayClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayClient> logger)
        {
            Options = optionsAccessor.Value;
            Logger  = logger;

            Client = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.AppId))
            {
                throw new ArgumentNullException(nameof(Options.AppId));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            PrivateRSAParameters = RSAUtilities.GetRSAParametersFormPrivateKey(Options.RsaPrivateKey);
            PublicRSAParameters  = RSAUtilities.GetRSAParametersFormPublicKey(Options.RsaPublicKey);
        }
示例#9
0
        public async Task <T> ExecuteAsync <T>(IQPayRequest <T> request) where T : QPayResponse
        {
            // 字典排序
            var sortedTxtParams = new QPayDictionary(request.GetParameters())
            {
                { MCHID, Options.MchId },
                { NONCE_STR, Guid.NewGuid().ToString("N") }
            };

            if (string.IsNullOrEmpty(sortedTxtParams.GetValue(APPID)))
            {
                sortedTxtParams.Add(APPID, Options.AppId);
            }

            sortedTxtParams.Add(SIGN, QPaySignature.SignWithKey(sortedTxtParams, Options.Key));

            var content = HttpClientEx.BuildContent(sortedTxtParams);

            Logger?.LogTrace(0, "Request:{content}", content);

            var body = await Client.DoPostAsync(request.GetRequestUrl(), content);

            Logger?.LogTrace(1, "Response:{body}", body);

            var parser = new QPayXmlParser <T>();
            var rsp    = parser.Parse(body);

            CheckResponseSign(rsp);
            return(rsp);
        }
示例#10
0
        public JDPayClient(
            IOptions <JDPayOptions> optionsAccessor,
            ILogger <JDPayClient> logger)
        {
            Options = optionsAccessor.Value;
            Logger  = logger;
            Client  = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.Merchant))
            {
                throw new ArgumentNullException(nameof(Options.Merchant));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            if (string.IsNullOrEmpty(Options.DesKey))
            {
                throw new ArgumentNullException(nameof(Options.DesKey));
            }

            PrivateKey = RSAUtilities.GetKeyParameterFormPrivateKey(Options.RsaPrivateKey);
            PublicKey  = RSAUtilities.GetKeyParameterFormPublicKey(Options.RsaPublicKey);
            DesKey     = Convert.FromBase64String(Options.DesKey);
        }
示例#11
0
        public async Task <T> ExecuteAsync <T>(HttpRequest request) where T : LianLianPayNotifyResponse
        {
            if (request.HasFormContentType)
            {
                var parameters = await GetParametersAsync(request);

                var query = HttpClientEx.BuildQuery(parameters);
                Logger.LogInformation(0, "Request:{query}", query);

                var parser = new LianLianPayDictionaryParser <T>();
                var rsp    = parser.Parse(parameters);
                CheckNotifySign(parameters);
                return(rsp);
            }
            else if (request.HasTextJsonContentType())
            {
                var body = await new StreamReader(request.Body).ReadToEndAsync();
                Logger.LogInformation(0, "Request:{body}", body);

                var parser = new LianLianPayJsonParser <T>();
                var rsp    = parser.Parse(body);
                CheckNotifySign(rsp.Parameters);
                return(rsp);
            }
            else
            {
                throw new Exception("sign check fail: check Sign and Data Fail!");
            }
        }
示例#12
0
        public WeChatPayClient(
            IOptions <WeChatPayOptions> optionsAccessor,
            ILogger <WeChatPayClient> logger)
        {
            this.logger = logger;
            try
            {
                logger?.LogDebug($"{DateTime.Now} 微信支付初始化日志(1)");

                Options = optionsAccessor.Value;

                Client = new HttpClientEx();

                if (string.IsNullOrEmpty(Options.AppId))
                {
                    throw new ArgumentNullException(nameof(Options.AppId));
                }

                if (string.IsNullOrEmpty(Options.MchId))
                {
                    throw new ArgumentNullException(nameof(Options.MchId));
                }

                if (string.IsNullOrEmpty(Options.Key))
                {
                    throw new ArgumentNullException(nameof(Options.Key));
                }

                if (!string.IsNullOrEmpty(Options.Certificate))
                {
                    logger.LogInformation($"{DateTime.Now} 微信支付初始化日志(3) {Environment.CurrentDirectory}/{Options.Certificate}");

                    var certificate = $"{Environment.CurrentDirectory}/{Options.Certificate}";

                    logger.LogInformation($"{DateTime.Now} 微信支付初始化日志(4) {certificate}");

                    var clientHandler = new HttpClientHandler();

                    logger.LogInformation($"{DateTime.Now} 微信支付初始化日志(5) {Options.MchId}");

                    clientHandler.ClientCertificates.Add(
                        File.Exists(certificate) ? new X509Certificate2(certificate, Options.MchId, X509KeyStorageFlags.MachineKeySet) :
                        new X509Certificate2(Convert.FromBase64String(certificate), Options.MchId, X509KeyStorageFlags.MachineKeySet));

                    logger.LogInformation($"{DateTime.Now} 微信支付初始化日志(6)");

                    CertificateClient = new HttpClientEx(clientHandler);
                }

                logger.LogInformation($"{DateTime.Now} 微信支付初始化日志(7)");
                if (!string.IsNullOrEmpty(Options.RsaPublicKey))
                {
                    PublicKey = RSAUtilities.GetPublicKeyParameterFormAsn1PublicKey(Options.RsaPublicKey);
                }
            }
            catch (Exception ex)
            {
                logger.LogInformation($"{DateTime.Now} 微信支付初始化日志报错{ex.Message}", ex.Message);
            }
        }
示例#13
0
        public LianLianPayClient(
            IOptions <LianLianPayOptions> optionsAccessor,
            ILogger <LianLianPayClient> logger)
        {
            Options = optionsAccessor?.Value ?? new LianLianPayOptions();
            Logger  = logger;

            Client = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.OidPartner))
            {
                throw new ArgumentNullException(nameof(Options.OidPartner));
            }

            if (string.IsNullOrEmpty(Options.BusiPartner))
            {
                throw new ArgumentNullException(nameof(Options.BusiPartner));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            PrivateKey = RSAUtilities.GetKeyParameterFormPrivateKey(Options.RsaPrivateKey);
            PublicKey  = RSAUtilities.GetKeyParameterFormPublicKey(Options.RsaPublicKey);
        }
示例#14
0
        public Task <T> PageExecuteAsync <T>(IJDPayRequest <T> request, string reqMethod) where T : JDPayResponse
        {
            // 字典排序
            var sortedTxtParams = new JDPayDictionary(request.GetParameters());
            var encyptParams    = BuildEncryptDic(request, sortedTxtParams);
            var rsp             = Activator.CreateInstance <T>();

            var url = request.GetRequestUrl();

            if (reqMethod == "GET")
            {
                //拼接get请求的url
                var tmpUrl = url;
                if (encyptParams != null && encyptParams.Count > 0)
                {
                    if (tmpUrl.Contains("?"))
                    {
                        tmpUrl = tmpUrl + "&" + HttpClientEx.BuildQuery(encyptParams);
                    }
                    else
                    {
                        tmpUrl = tmpUrl + "?" + HttpClientEx.BuildQuery(encyptParams);
                    }
                }
                rsp.Body = tmpUrl;
            }
            else
            {
                //输出post表单
                rsp.Body = BuildHtmlRequest(url, encyptParams);
            }

            return(Task.FromResult(rsp));
        }
示例#15
0
        private async Task <HttpAgentUpdateResultResponse> GetResult(PhotonServerDefinition server, string sessionId)
        {
            HttpClientEx client = null;

            try {
                var url = NetPath.Combine(server.Url, "api/agent/update/result");

                client = HttpClientEx.Get(url, new {
                    session = sessionId,
                });

                await client.Send();

                return(client.ParseJsonResponse <HttpAgentUpdateResultResponse>());
            }
            catch (HttpStatusCodeException error) {
                if (error.HttpCode == HttpStatusCode.NotFound)
                {
                    throw new ApplicationException($"Photon-Server instance '{server.Name}' not found!");
                }

                throw;
            }
            finally {
                client?.Dispose();
            }
        }
示例#16
0
        public UnionPayClient(IOptions <UnionPayOptions> optionsAccessor)
        {
            Options = optionsAccessor?.Value ?? new UnionPayOptions();
            Client  = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.SignCert) || string.IsNullOrEmpty(Options.SignCertPassword))
            {
                throw new Exception("SignCert or SignCertPassword is Empty!");
            }
            SignCertificate = UnionPaySignature.GetSignCertificate(Options.SignCert, Options.SignCertPassword);

            if (string.IsNullOrEmpty(Options.EncryptCert))
            {
                throw new Exception("EncryptCert is Empty!");
            }
            EncryptCertificate = UnionPaySignature.GetCertificate(Options.EncryptCert);

            if (string.IsNullOrEmpty(Options.MiddleCert))
            {
                throw new Exception("MiddleCert is Empty!");
            }
            MiddleCertificate = UnionPaySignature.GetCertificate(Options.MiddleCert);

            if (string.IsNullOrEmpty(Options.RootCert))
            {
                throw new Exception("RootCert is Empty!");
            }
            RootCertificate = UnionPaySignature.GetCertificate(Options.RootCert);
        }
示例#17
0
        public Task <T> SdkExecuteAsync <T>(IAlipayRequest <T> request) where T : AlipayResponse
        {
            // 构造请求参数
            var requestParams = BuildRequestParams(request, null, null);

            // 字典排序
            var sortedParams    = new SortedDictionary <string, string>(requestParams);
            var sortedAlipayDic = new AlipayDictionary(sortedParams);

            // 参数签名
            var signContent = AlipaySignature.GetSignContent(sortedAlipayDic);
            var signResult  = AlipaySignature.RSASignContent(signContent, PrivateRSAParameters, Options.SignType);

            // 添加签名结果参数
            sortedAlipayDic.Add(SIGN, signResult);

            // 参数拼接
            var signedResult = HttpClientEx.BuildQuery(sortedAlipayDic);

            // 构造结果
            var rsp = Activator.CreateInstance <T>();

            rsp.Body = signedResult;
            return(Task.FromResult(rsp));
        }
示例#18
0
        public JdPayClient(
            IOptions <JdPayOptions> optionsAccessor,
            ILogger <JdPayClient> logger)
        {
            Options = optionsAccessor?.Value ?? new JdPayOptions();
            Logger  = logger;
            Client  = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.Merchant))
            {
                throw new ArgumentNullException(nameof(Options.Merchant));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            if (string.IsNullOrEmpty(Options.DesKey))
            {
                throw new ArgumentNullException(nameof(Options.DesKey));
            }

            RSAPrivateParameters = JdPaySignature.GetPrivateKeyParameters(Options.RsaPrivateKey);
            RSAPublicParameters  = JdPaySignature.GetPublicKeyParameters(Options.RsaPublicKey);
            DesKey = Convert.FromBase64String(Options.DesKey);
        }
示例#19
0
        public async Task <T> ExecuteAsync <T>(IWeChatPayRequest <T> request) where T : WeChatPayResponse
        {
            try
            {
                // 字典排序
                var sortedTxtParams = new WeChatPayDictionary(request.GetParameters())
                {
                    { mch_id, Options.MchId },
                    { nonce_str, Guid.NewGuid().ToString("N") },
                    { notify_url, Options.NotifyUrl }
                };

                if (string.IsNullOrEmpty(sortedTxtParams.GetValue(appid)))
                {
                    sortedTxtParams.Add(appid, Options.AppId);
                }

                sortedTxtParams.Add(sign, WeChatPaySignature.SignWithKey(sortedTxtParams, Options.Key));
                var content = HttpClientEx.BuildContent(sortedTxtParams);

                var body = await Client.DoPostAsync(request.GetRequestUrl(), content);

                var parser = new WeChatPayXmlParser <T>();
                var rsp    = parser.Parse(body);
                CheckResponseSign(rsp);
                return(rsp);
            }
            catch (Exception ex)
            {
                logger?.LogError($"{DateTime.Now} ExecuteAsync(1)", ex.Message);
                return(null);
            }
        }
示例#20
0
        public AlipayClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayClient> logger)
        {
            Options     = optionsAccessor.Value;
            this.logger = logger;
            try
            {
                Client = new HttpClientEx();

                if (string.IsNullOrEmpty(Options.AppId))
                {
                    throw new ArgumentNullException(nameof(Options.AppId));
                }

                if (string.IsNullOrEmpty(Options.RsaPrivateKey))
                {
                    throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
                }

                if (string.IsNullOrEmpty(Options.RsaPublicKey))
                {
                    throw new ArgumentNullException(nameof(Options.RsaPublicKey));
                }

                PrivateRSAParameters = RSAUtilities.GetRSAParametersFormPrivateKey(Options.RsaPrivateKey);
                PublicRSAParameters  = RSAUtilities.GetRSAParametersFormPublicKey(Options.RsaPublicKey);
            }
            catch (Exception ex)
            {
                logger?.LogError($"{DateTime.Now} 支付宝初始化日志报错", ex.Message);
            }
        }
示例#21
0
        public Task <T> PageExecuteAsync <T>(IUnionPayRequest <T> request, string reqMethod) where T : UnionPayResponse
        {
            var version = string.Empty;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                version = request.GetApiVersion();
            }
            else
            {
                version = Options.Version;
            }

            var txtParams = new UnionPayDictionary(request.GetParameters())
            {
                { VERSION, version },
                { ENCODING, Options.Encoding },
                { SIGNMETHOD, Options.SignMethod },

                { TXNTYPE, request.GetTxnType() },
                { TXNSUBTYPE, request.GetTxnSubType() },
                { BIZTYPE, request.GetBizType() },
                { CHANNELTYPE, request.GetChannelType() },

                { ACCESSTYPE, Options.AccessType },
                { MERID, Options.MerId },
            };

            UnionPaySignature.Sign(txtParams, SignCertificate.certId, SignCertificate.key, Options.SecureKey);

            var rsp = Activator.CreateInstance <T>();

            var url = request.GetRequestUrl(Options.TestMode);

            if (reqMethod == "GET")
            {
                //拼接get请求的url
                var tmpUrl = url;
                if (txtParams != null && txtParams.Count > 0)
                {
                    if (tmpUrl.Contains("?"))
                    {
                        tmpUrl = tmpUrl + "&" + HttpClientEx.BuildQuery(txtParams);
                    }
                    else
                    {
                        tmpUrl = tmpUrl + "?" + HttpClientEx.BuildQuery(txtParams);
                    }
                }
                rsp.Body = tmpUrl;
            }
            else
            {
                //输出post表单
                rsp.Body = BuildHtmlRequest(url, txtParams, reqMethod);
            }

            return(Task.FromResult(rsp));
        }
示例#22
0
 public void Dispose()
 {
     if(_httpClient != null)
     {
         _httpClient.Dispose();
         _httpClient = null;
     }
 }
 public ImageProxyService(IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem, IApplicationPaths appPaths)
 {
     client = new HttpClientEx();
     this.jsonSerializer = jsonSerializer;
     this.logger         = logger;
     this.fileSystem     = fileSystem;
     this.appPaths       = appPaths;
 }
示例#24
0
 public Danmaku()
 {
     RoomId       = "roomid".GetConfig().ToInt32();
     TcpClient    = new TcpClient();
     HttpClient   = new HttpClientEx();
     MusicClient  = new MusicClient(HttpClient.BaseHttpClient);
     DefaultHosts = new string[] { "livecmt-2.bilibili.com", "livecmt-1.bilibili.com" };
 }
示例#25
0
 public void Dispose()
 {
     if (this.client != null)
     {
         this.client.Dispose();
         this.client = null;
     }
 }
示例#26
0
 public AlipayClient(IOptions <AlipayOptions> optionsAccessor)
 {
     Options  = optionsAccessor?.Value ?? new AlipayOptions();
     Settings = new JsonSerializerSettings()
     {
         NullValueHandling = NullValueHandling.Ignore
     };
     Client = new HttpClientEx();
 }
示例#27
0
 public Client(SecureString token)
 {
     _httpClientEx = new HttpClientEx(token)
     {
         BaseUri = new Uri("https://ci.appveyor.com/")
     };
     BuildWorker = new BuildWorker(_httpClientEx);
     Project     = new ProjectClient(_httpClientEx);
 }
示例#28
0
        public async Task <Tuple <File, ContentRangeHeaderValue> > GetResumableFileRangeAsync(Uri sessionUri, long fileLength, CancellationToken cancellationToken)
        {
            var client  = GetClient();
            var content = HttpClientEx.GetEmptyContent();

            content.Headers.ContentRange = new ContentRangeHeaderValue(fileLength);
            var response = await client.PutAsync(sessionUri, content, cancellationToken);

            return(await ProcessResumableUploadResponse(response));
        }
示例#29
0
        public AlipayMobilePublicMultiMediaClient(AlipayOptions options)
        {
            Options = options;
            Client  = new HttpClientEx();

            if (!string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                RSAPrivateParameters = AlipaySignature.GetPrivateParameters(Options.RsaPrivateKey);
            }
        }
示例#30
0
        //Envoyer la question avec la méthode Patch
        private bool PasthJsonAsync(Patch patch)
        {
            var client   = new HttpClient();
            var response = HttpClientEx.PatchJsonAsync(client, "http://coreosjpg.cloudapp.net:80" + quizUri, patch).GetAwaiter().GetResult();;

            if (response.StatusCode == HttpStatusCode.NoContent)
            {
                return(true);
            }
            return(false);
        }
示例#31
0
        public static void SendPostRequestToKeycloak(string keycloakUrl, string content)
        {
            HttpClientEx client = new HttpClientEx(new CondensedJsonSerializer());

            client.PostUrlEncodedAsync(keycloakUrl, content)
            .ContinueWith(task =>
            {
                string a = task.Result.Response.Content.ReadAsStringAsync().Result;
                var b    = JsonConvert.DeserializeObject <KeycloakTokenResponseMessage>(a);
                Console.WriteLine(b.AccessToken);
            });
        }
示例#32
0
 /// <summary>
 /// 创建Client实例
 /// </summary>
 /// <param name="serverAddress">webApi的地址</param>
 public ClientApi(string serverAddress)
 {
     _httpClient = new HttpClientEx(serverAddress);
 }