DownloadStringAsync() public static méthode

public static DownloadStringAsync ( Uri address, X509Certificate2 clientCert, int millisecondsTimeout, DownloadProgressEventHandler downloadProgressCallback, RequestCompletedEventHandler completedCallback ) : HttpWebRequest
address System.Uri
clientCert System.Security.Cryptography.X509Certificates.X509Certificate2
millisecondsTimeout int
downloadProgressCallback DownloadProgressEventHandler
completedCallback RequestCompletedEventHandler
Résultat System.Net.HttpWebRequest
Exemple #1
0
        public void BeginGetResponse(byte[] postData, string contentType, int millisecondsTimeout)
        {
            _PostData    = postData;
            _ContentType = contentType;

            if (_Request != null)
            {
                _Request.Abort();
                _Request = null;
            }

            if (postData == null)
            {
                // GET
                //Logger.Log.Debug("[CapsClient] GET " + _Address);
                _Request = CapsBase.DownloadStringAsync(_Address, _ClientCert, millisecondsTimeout, DownloadProgressHandler,
                                                        RequestCompletedHandler);
            }
            else
            {
                // POST
                //Logger.Log.Debug("[CapsClient] POST (" + postData.Length + " bytes) " + _Address);
                _Request = CapsBase.UploadDataAsync(_Address, _ClientCert, contentType, postData, millisecondsTimeout, null,
                                                    DownloadProgressHandler, RequestCompletedHandler);
            }
        }
Exemple #2
0
        public void StartRequest(byte[] postData, string contentType)
        {
            _PostData    = postData;
            _ContentType = contentType;

            if (_Client.IsBusy)
            {
                _Client.CancelAsync();
            }

            _Client.Headers.Clear();

            // Proxy
            if (Proxy != null)
            {
                _Client.Proxy = Proxy;
            }

            // Content-Type
            if (!String.IsNullOrEmpty(contentType))
            {
                _Client.Headers.Add(HttpRequestHeader.ContentType, contentType);
            }
            else
            {
                _Client.Headers.Add(HttpRequestHeader.ContentType, "application/xml");
            }

            if (postData == null)
            {
                _Client.DownloadStringAsync(_Client.Location);
            }
            else
            {
                _Client.UploadDataAsync(_Client.Location, postData);
            }
        }