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

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

            this.ravenClient = ravenClient;
            this.packet      = ravenClient.PreparePacket(packet);
            this.data        = new RequestData(this);

            this.webRequest                  = (HttpWebRequest)System.Net.WebRequest.Create(ravenClient.CurrentDsn.SentryUri);
            this.webRequest.Timeout          = (int)ravenClient.Timeout.TotalMilliseconds;
            this.webRequest.ReadWriteTimeout = (int)ravenClient.Timeout.TotalMilliseconds;
            this.webRequest.Method           = "POST";
            this.webRequest.Accept           = "application/json";
            this.webRequest.Headers.Add("X-Sentry-Auth", PacketBuilder.CreateAuthenticationHeader(ravenClient.CurrentDsn));
            this.webRequest.UserAgent = PacketBuilder.UserAgent;

            if (ravenClient.Compression)
            {
                this.webRequest.Headers.Add(HttpRequestHeader.ContentEncoding, "gzip");
                this.webRequest.AutomaticDecompression = DecompressionMethods.Deflate;
                this.webRequest.ContentType            = "application/octet-stream";
            }
            else
            {
                this.webRequest.ContentType = "application/json; charset=utf-8";
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Requester"/> class.
        /// </summary>
        /// <param name="packet">The <see cref="JsonPacket"/> to initialize with.</param>
        /// <param name="ravenClient">The <see cref="RavenClient"/> to initialize with.</param>
        public Requester(JsonPacket packet, RavenClient ravenClient)
        {
            if (packet == null)
            {
                throw new ArgumentNullException("packet");
            }

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

            this.ravenClient = ravenClient;
            this.packet      = ravenClient.PreparePacket(packet);
            this.data        = new RequestData(this);

            this.webRequest = CreateWebRequest(ravenClient.CurrentDsn.SentryUri);

            if (ravenClient.Compression)
            {
                this.webRequest.Headers.Add(HttpRequestHeader.ContentEncoding, "gzip");
                this.webRequest.AutomaticDecompression = DecompressionMethods.Deflate;
                this.webRequest.ContentType            = "application/octet-stream";
            }

            else
            {
                this.webRequest.ContentType = "application/json; charset=utf-8";
            }
        }