Advertisement
Guest User

Untitled

a guest
Oct 15th, 2021
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net.Http;
  4. using System.Threading.Tasks;
  5.  
  6. namespace BackendYandex
  7. {
  8. class Program
  9. {
  10. static async Task Main(string[] args)
  11. {
  12. var url = "http://127.0.0.1:7777/";
  13. var names = new List<string>();
  14. var values = new List<string>() {"","","",""};
  15. var responses = new List<IList<string>>();
  16.  
  17. for(int i = 0; i < 4; i++)
  18. {
  19. names.Add(Console.ReadLine());
  20. }
  21.  
  22. using var client = new HttpClient();
  23.  
  24. for(int i = 0; i < 2; i++)
  25. {
  26. var request = new HttpRequestMessage(new HttpMethod("MEW"), url);
  27. request.Headers.Add("X-Cat-Variable", names[i]);
  28. request.Headers.Add("X-Cat-Variable", names[i + 1]);
  29. var response = await client.SendAsync(request);
  30. var lst = new List<string>();
  31. foreach(var header in response.Headers)
  32. {
  33. if(header.Key.ToLower() == "x-cat-value")
  34. {
  35. responses.Add(new List<string>(header.Value));
  36. }
  37. }
  38. }
  39. if(responses[0][0] == responses[1][0])
  40. {
  41. values[0] = responses[0][1];
  42. values[1] = responses[0][0];
  43. values[2] = responses[1][1];
  44. }
  45.  
  46. if (responses[0][0] == responses[1][1])
  47. {
  48. values[0] = responses[0][1];
  49. values[1] = responses[0][0];
  50. values[2] = responses[1][0];
  51. }
  52.  
  53. if (responses[0][1] == responses[1][0])
  54. {
  55. values[0] = responses[0][0];
  56. values[1] = responses[0][1];
  57. values[2] = responses[1][1];
  58. }
  59.  
  60. if (responses[0][1] == responses[1][1])
  61. {
  62. values[0] = responses[0][0];
  63. values[1] = responses[0][1];
  64. values[2] = responses[1][0];
  65. }
  66.  
  67. if (responses[0][0] == responses[1][0])
  68. {
  69. values[0] = responses[0][1];
  70. values[1] = responses[0][0];
  71. values[2] = responses[1][1];
  72. }
  73.  
  74. if (responses[0][0] == responses[1][1])
  75. {
  76. values[0] = responses[0][1];
  77. values[1] = responses[0][0];
  78. values[2] = responses[1][0];
  79. }
  80.  
  81. if (responses[0][1] == responses[1][0])
  82. {
  83. values[0] = responses[0][0];
  84. values[1] = responses[0][1];
  85. values[2] = responses[1][1];
  86. }
  87.  
  88. if (responses[0][1] == responses[1][1])
  89. {
  90. values[0] = responses[0][0];
  91. values[1] = responses[0][1];
  92. values[2] = responses[1][0];
  93. }
  94. var req = new HttpRequestMessage(new HttpMethod("MEW"), url);
  95. req.Headers.Add("X-Cat-Variable", names[3]);
  96. var res = await client.SendAsync(req);
  97. for(int i = 0; i < 3; i++)
  98. {
  99. Console.WriteLine(values[i]);
  100. }
  101. foreach (var header in res.Headers)
  102. {
  103. if (header.Key.ToLower() == "x-cat-value")
  104. {
  105. bool f = false;
  106. foreach (var v in header.Value)
  107. {
  108. Console.WriteLine(v);
  109. f = true;
  110. break;
  111. }
  112. if (f)
  113. break;
  114. }
  115. }
  116. }
  117. }
  118. }
  119.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement