Ejemplo n.º 1
0
        public void StartRequest(byte[] postData, string contentType)
        {
            _PostData    = postData;
            _ContentType = contentType;

            if (_Client.IsBusy)
            {
                Logger.Log("New CAPS request to " + _Client.Location +
                           " initiated, closing previous request", Helpers.LogLevel.Warning);
                _Client.CancelAsync();
            }
            else
            {
                Logger.DebugLog("New CAPS request to " + _Client.Location + " initiated");
            }

            _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);
            }
        }
Ejemplo n.º 2
0
        public void Stop(bool immediate)
        {
            _Dead = true;

            if (immediate)
            {
                _Running = false;
            }

            if (_Client.IsBusy)
            {
                Logger.DebugLog("Stopping a running event queue");
                _Client.CancelAsync();
            }
            else
            {
                Logger.DebugLog("Stopping an already dead event queue");
            }
        }