예제 #1
0
 public Reddit(IListingFilter listingFilter, UserState userState, IActionDeferralSink deferalSink, ICaptchaProvider captchaProvider, string appId = null, string appSecret = null, string redirectUrl = null, ICachingProvider cacheProvider = null, INetworkLayer networkLayer = null)
 {
     _cacheProvider   = cacheProvider;
     _networkLayer    = networkLayer ?? new NetworkLayer(userState, appId, appSecret, redirectUrl);
     _listingFilter   = listingFilter;
     _userState       = userState ?? new UserState();
     _deferalSink     = deferalSink;
     _captchaProvider = captchaProvider;
     _appId           = appId;
     _appSecret       = appSecret;
     _redirectUrl     = redirectUrl;
 }
예제 #2
0
        public Reddit(IListingFilter listingFilter, UserState userState, IActionDeferralSink deferalSink, ICaptchaProvider captchaProvider, string appId = null, string appSecret = null, string redirectUrl = null)
        {
            _listingFilter   = listingFilter;
            _userState       = userState;
            _deferalSink     = deferalSink;
            _captchaProvider = captchaProvider;
            _appId           = appId;
            _appSecret       = appSecret;
            _redirectUrl     = redirectUrl;
            _cookieContainer = new CookieContainer();
            var handler = new HttpClientHandler {
                CookieContainer = _cookieContainer
            };

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = DecompressionMethods.GZip |
                                                 DecompressionMethods.Deflate;
            }
            _httpClient = new HttpClient(handler);
            //_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "SnooStream");
            //_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Cache-Control", "no-cache");
        }