fixed insert tokens

This commit is contained in:
2025-03-20 17:19:47 +01:00
parent f98de6504c
commit 163bbc72c3

View File

@@ -6,7 +6,6 @@
//Numero Thread(?)
using System.Diagnostics;
using System.Net.Sockets;
namespace LoadTest;
@@ -24,6 +23,7 @@ internal class Program
string? yn;
Stopwatch sw;
using var client = new HttpClient();
Console.WriteLine("Load Test");
do
{
@@ -49,22 +49,33 @@ internal class Program
do
{
Console.WriteLine("Is Authentication required? (Y/N)");
Console.WriteLine("Are Tokens required? (Y/N)");
yn = Console.ReadLine();
} while(string.IsNullOrEmpty(yn) && (yn?.ToLower() != ConsoleKey.Y.ToString().ToLower() || yn?.ToLower() != ConsoleKey.N.ToString().ToLower()));
if (yn?.ToLower() == "y")
{
ConsoleKey keyPressed;
do
{
Console.WriteLine("Header");
header = Console.ReadLine();
} while (string.IsNullOrEmpty(header));
do
do
{
Console.WriteLine("Header");
header = Console.ReadLine();
} while (string.IsNullOrEmpty(header));
do
{
Console.WriteLine("Token: ");
token = Console.ReadLine();
} while (string.IsNullOrEmpty(token));
Console.WriteLine("Press a key to insert another token, Press Q to stop inserting tokens.");
keyPressed = Console.ReadKey().Key;
} while (keyPressed == ConsoleKey.Q);
if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(header))
{
Console.WriteLine("Token: ");
token = Console.ReadLine();
} while (string.IsNullOrEmpty(token));
client.DefaultRequestHeaders.Add(header, token);
}
}
do
@@ -75,11 +86,6 @@ internal class Program
} while (string.IsNullOrEmpty(time));
lTime = long.Parse(time) * 1000;
using var client = new HttpClient() ;
if (yn == "y" && !string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(header))
{
client.DefaultRequestHeaders.Add(header, token);
}
switch (methodHttp.ToUpper())
{
case "GET":