Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using System.Threading.Tasks;
- namespace BackendYandex
- {
- class Program
- {
- static async Task Main(string[] args)
- {
- var url = "http://127.0.0.1:7777/";
- var names = new List<string>();
- var values = new List<string>() {"","","",""};
- var responses = new List<IList<string>>();
- for(int i = 0; i < 4; i++)
- {
- names.Add(Console.ReadLine());
- }
- using var client = new HttpClient();
- for(int i = 0; i < 2; i++)
- {
- var request = new HttpRequestMessage(new HttpMethod("MEW"), url);
- request.Headers.Add("X-Cat-Variable", names[i]);
- request.Headers.Add("X-Cat-Variable", names[i + 1]);
- var response = await client.SendAsync(request);
- var lst = new List<string>();
- foreach(var header in response.Headers)
- {
- if(header.Key.ToLower() == "x-cat-value")
- {
- responses.Add(new List<string>(header.Value));
- }
- }
- }
- if(responses[0][0] == responses[1][0])
- {
- values[0] = responses[0][1];
- values[1] = responses[0][0];
- values[2] = responses[1][1];
- }
- if (responses[0][0] == responses[1][1])
- {
- values[0] = responses[0][1];
- values[1] = responses[0][0];
- values[2] = responses[1][0];
- }
- if (responses[0][1] == responses[1][0])
- {
- values[0] = responses[0][0];
- values[1] = responses[0][1];
- values[2] = responses[1][1];
- }
- if (responses[0][1] == responses[1][1])
- {
- values[0] = responses[0][0];
- values[1] = responses[0][1];
- values[2] = responses[1][0];
- }
- if (responses[0][0] == responses[1][0])
- {
- values[0] = responses[0][1];
- values[1] = responses[0][0];
- values[2] = responses[1][1];
- }
- if (responses[0][0] == responses[1][1])
- {
- values[0] = responses[0][1];
- values[1] = responses[0][0];
- values[2] = responses[1][0];
- }
- if (responses[0][1] == responses[1][0])
- {
- values[0] = responses[0][0];
- values[1] = responses[0][1];
- values[2] = responses[1][1];
- }
- if (responses[0][1] == responses[1][1])
- {
- values[0] = responses[0][0];
- values[1] = responses[0][1];
- values[2] = responses[1][0];
- }
- var req = new HttpRequestMessage(new HttpMethod("MEW"), url);
- req.Headers.Add("X-Cat-Variable", names[3]);
- var res = await client.SendAsync(req);
- for(int i = 0; i < 3; i++)
- {
- Console.WriteLine(values[i]);
- }
- foreach (var header in res.Headers)
- {
- if (header.Key.ToLower() == "x-cat-value")
- {
- bool f = false;
- foreach (var v in header.Value)
- {
- Console.WriteLine(v);
- f = true;
- break;
- }
- if (f)
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement