Beispiel #1
0
        protected virtual HttpDispatch <TKey> AssembleHttpRequest(EventSettings <TKey> settings
                                                                  , SignalEvent <TKey> signalEvent, Subscriber <TKey> subscriber, string content)
        {
            var dispatch = new HttpDispatch <TKey>()
            {
                Url        = Url,
                HttpMethod = HttpMethod,
                Headers    = Headers,
                Content    = content
            };

            SetBaseProperties(dispatch, settings, signalEvent, subscriber);
            return(dispatch);
        }
Beispiel #2
0
        //methods
        public virtual async Task <ProcessingResult> Send(SignalDispatch <TKey> item)
        {
            HttpDispatch <TKey> httpDispatch = (HttpDispatch <TKey>)item;

            HttpRequestMessage request = BuildRequest(httpDispatch);

            using (HttpClient httpClient = new HttpClient())
            {
                HttpResponseMessage response = await httpClient.SendAsync(request);

                HandleResponse(item, response);
            }

            return(ProcessingResult.Success);
        }
Beispiel #3
0
        protected virtual HttpRequestMessage BuildRequest(HttpDispatch <TKey> httpDispatch)
        {
            var request = new HttpRequestMessage
            {
                Method     = httpDispatch.HttpMethod,
                RequestUri = new Uri(httpDispatch.Url)
            };

            if (httpDispatch.Content != null)
            {
                request.Content = new StringContent(httpDispatch.Content);
            }

            if (httpDispatch.Headers != null)
            {
                foreach (KeyValuePair <string, string> header in httpDispatch.Headers)
                {
                    request.Headers.Add(header.Key, header.Value);
                }
            }

            return(request);
        }