Ejemplo n.º 1
0
        private async Task <string> UpdateCookie(string cookie)
        {
            using var handler = new NoCookieHttpMessageHandler();
            using var client  = new HttpClient(handler);
            using var request = new HttpRequestMessage(HttpMethod.Get, "https://exhentai.org/mytags ");
            request.Headers.Add("Cookie", $"{cookie};igneous=");
            using var response = await client.SendAsync(request);

            response.Headers.TryGetValues("Set-Cookie", out var cookies);
            return(cookies
                   .Select(item => item.Split(';').FirstOrDefault())
                   .Let(it => string.Join(";", it)));
        }
Ejemplo n.º 2
0
        public async Task Login(string userName, string password)
        {
            using var handler = new NoCookieHttpMessageHandler();
            using var client  = new HttpClient(handler);
            using var request = new HttpRequestMessage(HttpMethod.Post,
                                                       "http://forums.e-hentai.org/index.php?act=Login&CODE=01&CookieDate=1")
                  {
                      Content = new FormUrlEncodedContent(new[]
                {
                    KeyValuePair.Create("UserName", userName), KeyValuePair.Create("PassWord", password)
                })
                  };
            using var response = await client.SendAsync(request, completionOption : HttpCompletionOption.ResponseHeadersRead);

            response.Headers.TryGetValues("Set-Cookie", out var cookies);
            var cookie = cookies
                         .Select(item => item.Split(';').FirstOrDefault())
                         .Let(it => string.Join((string)";", (IEnumerable <string>)it));

            cookie += ";" + await UpdateCookie(cookie);

            SetCookie(cookie);
        }