예제 #1
0
        private static async Task <HttpResponse> RequestAsync(HttpRequest request)
        {
            var settings    = new ProxySettings();
            var proxyClient = new NoProxyClient(settings);

            using var client = new RLHttpClient(proxyClient);
            return(await client.SendAsync(request));
        }
예제 #2
0
        private static void LogHttpRequestData(BotData data, RLHttpClient client)
        {
            for (var i = 0; i < client.RawRequests.Count; i++)
            {
                if (i > 0)
                {
                    data.Logger.Log($"Redirect {i}", LogColors.Beige);
                }

                data.Logger.Log(Encoding.UTF8.GetString(client.RawRequests[i]), LogColors.NonPhotoBlue);
            }
        }
예제 #3
0
        public async Task SendAsync_Get_Cookies()
        {
            var name  = "name";
            var value = "value";

            var cookies = new Dictionary <string, string>();

            var message = new HttpRequest
            {
                Method  = HttpMethod.Get,
                Uri     = new Uri($"http://httpbin.org/cookies/set?{name}={value}"),
                Cookies = cookies
            };

            var settings    = new ProxySettings();
            var proxyClient = new NoProxyClient(settings);

            using var client = new RLHttpClient(proxyClient);

            var response = await client.SendAsync(message);

            Assert.Single(cookies);
            Assert.Equal(value, cookies[name]);
        }