Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Requester"/> class.
        /// </summary>
        /// <param name="feedback">The <see cref="SentryUserFeedback"/> to initialize with.</param>
        /// <param name="ravenClient">The <see cref="RavenClient"/> to initialize with.</param>
        internal Requester(SentryUserFeedback feedback, RavenClient ravenClient)
        {
            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

            if (ravenClient == null)
            {
                throw new ArgumentNullException("ravenClient");
            }

            this.ravenClient = ravenClient;
            this.feedback    = feedback;

            var feedbackString = string.Format("{0}?dsn={1}&{2}",
                                               ravenClient.CurrentDsn.FeedbackUri,
                                               ravenClient.CurrentDsn.Uri,
                                               feedback.ToString());

            this.webRequest         = CreateWebRequest(new Uri(feedbackString));
            this.webRequest.Referer = ravenClient.CurrentDsn.Uri.DnsSafeHost;

            this.webRequest.ContentType = "application/x-www-form-urlencoded";
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequester"/> class.
        /// </summary>
        /// <param name="feedback">The <see cref="SentryUserFeedback"/> to initialize with.</param>
        /// <param name="dsn">The DSN used in this request</param>
        internal HttpRequester(SentryUserFeedback feedback, Dsn dsn)
        {
            if (dsn == null)
            {
                throw new ArgumentNullException(nameof(dsn));
            }
            this.feedback = feedback ?? throw new ArgumentNullException(nameof(feedback));

            var feedbackUri = new Uri($"{dsn.FeedbackUri}?dsn={dsn.Uri}&{feedback}");

            this.webRequest         = CreateWebRequest(feedbackUri, dsn);
            this.webRequest.Referer = dsn.Uri.DnsSafeHost;

            this.webRequest.ContentType = "application/x-www-form-urlencoded";
        }
        /// <summary>
        /// Creates a <see cref="BackgroundRequester"/> that upon invoked, enqueues the event to a background worker thread
        /// </summary>
        /// <param name="feedback">The feedback to send via background worker.</param>
        /// <param name="dsn">The DSN to be used.</param>
        /// <returns></returns>
        public IRequester Create(SentryUserFeedback feedback, Dsn dsn)
        {
            var actualRequester = this.actualRequesterFactory.Create(feedback, dsn);

            return(new BackgroundRequester(actualRequester, this.queue));
        }
 /// <summary>
 /// Creates a Requester that initiates an HTTP request when invoked.
 /// </summary>
 /// <param name="feedback">The feedback.</param>
 /// <param name="dsn">The DSN.</param>
 /// <returns></returns>
 public IRequester Create(
     SentryUserFeedback feedback,
     Dsn dsn)
 => new HttpRequester(feedback, dsn);