Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 414-请求的uri太长-url长度为70个字符_C#_Sockets_Http_Authentication_Http Get - Fatal编程技术网

C# 414-请求的uri太长-url长度为70个字符

C# 414-请求的uri太长-url长度为70个字符,c#,sockets,http,authentication,http-get,C#,Sockets,Http,Authentication,Http Get,我试图用C#进行身份验证 它在尝试登录时发送HTTPGET请求,如下所示: 这只有70个字符。但是我得到了一个“请求URI太长”的错误 编辑:这看起来像是模拟工作,但不是当通过TcpClient发送时 客户经理: 使用系统; Net系统; 使用System.Net.Sockets; 使用System.Threading.Tasks; 使用System.IO; 使用系统文本; 使用系统诊断; 使用System.Security.Cryptography.X509证书; 使用System.Ne

我试图用C#进行身份验证

它在尝试登录时发送HTTP
GET
请求,如下所示:

这只有70个字符。但是我得到了一个“请求URI太长”的错误

编辑:这看起来像是模拟工作,但不是当通过TcpClient发送时

客户经理:

使用系统;
Net系统;
使用System.Net.Sockets;
使用System.Threading.Tasks;
使用System.IO;
使用系统文本;
使用系统诊断;
使用System.Security.Cryptography.X509证书;
使用System.Net.Security;
公共类客户端管理器
{
专用静态TcpListener侦听器;
公共静态void Main()
{
ServicePointManager.ServerCertificateValidationCallback=MyRemoteCertificateValidationCallback;
侦听器=新的TcpListener(IPAddress.Any,10250);
listener.Start();
Console.WriteLine(“***客户端管理器已启动***”);
WriteLine(“监听端口10250,确保未使用”);
startacept();
while(true)
{
系统线程线程睡眠(1000);
string cmd=Console.ReadLine();
如果(cmd.Equals(“exit”))
{
Console.WriteLine(“***正在停止cman…***”);
环境。退出(0);
}
if(cmd.StartsWith(“auth”))
{
WriteLine(“[“+”模拟“+”]使用auth cred进行身份验证。”);
字符c=“|”;
字符串[]args=cmd.Split(c);
如果(!(参数长度>2))
{
Console.WriteLine(“提供的数据无效”);
}
字符串username=args[1];
字符串密码=args[2];
Console.WriteLine(“[“+”模拟“+”),使用凭据:“+用户名+”和“+密码);
字符串响应=GetAsync(“https://goldenarmy.eu/studios/id/cman/clogin.php?name=“+username+”&password=“+password+”&test=1”);
控制台写入线(“https://goldenarmy.eu/studios/id/cman/clogin.php?name=“+username+”&password=“+password”);
控制台写入线(响应);
if(response.Equals(“ERROR\u FAILED\u CONNECTION”))
{
Console.WriteLine(“ERROR_SERVERERROR”);
}
else if(response.Equals(“无效的_用户名”))
{
Console.WriteLine(“提供的数据无效”);
}
else if(response.Equals(“无效的_密码”))
{
Console.WriteLine(“提供的数据无效”);
}
else if(响应等于(“无效的信任”))
{
Console.WriteLine(“错误验证无效”);
}
else if(response.Equals(“被禁止”))
{
Console.WriteLine(“错误授权被禁止”);
}
其他的
{
Console.WriteLine(“[“+”模拟“+”]登录确定|响应:“+响应”);
}
}
}
}
私有静态void startacept()
{
BeginAcceptSocket(HandleAsyncConnection,listener);
}
专用静态无效HandleAsyncConnection(IAsyncResult res)
{
startacept();
TcpClient client=listener.EndAcceptTcpClient(res);
字符串clientSession=“NULL”;
字符串ip=((IPEndPoint)client.client.RemoteEndPoint).Address.ToString();
Console.WriteLine(“[”+ip+“]传入连接”);
while(true)
{
尝试
{
系统线程线程睡眠(250);
Console.WriteLine(“尝试从“+ip”读取数据);
NetworkStream=null;
字节[]数据=新字节[8192];
String responseData=String.Empty;
Int32字节=0;
stream=client.GetStream();
字节=stream.Read(数据,0,数据.长度);
WriteLine(“字节:“+Bytes+”数据:“+System.Text.Encoding.ASCII.GetString(数据));
responseData=System.Text.Encoding.ASCII.GetString(数据);
Console.WriteLine(“[”+ip+“]”+responseData);
如果(响应数据开始(“关闭”))
{
Console.WriteLine(“[”+ip+“]连接关闭”);
打破
}else if(responseData.StartsWith(“useauthtoken”))
{
Console.WriteLine(“[”+ip+“]使用身份验证令牌进行身份验证。”);
字符c=“|”;
字符串[]args=responseData.Split(c);
如果(!(参数长度>1))
{
SendMessage(流,“提供的数据无效”);
}
字符串响应=GetAsync(“http://goldenarmy.eu/studios/id/cman/cauthtokencheck.php?auth=“+args[1]);
如果(响应等于(“是”))
{
clientSession=args[1];
发送消息(流,“OK”);
}
其他的
{
SendMessage(流,“错误验证无效”);
}
}
else if(responseData.StartsWith(“auth”))
{
Console.WriteLine(“[”+ip+“]使用auth-cred进行身份验证。”);
字符c=“|”;
字符串[]args=responseData.Split(c);
Console.WriteLine(“数据拆分”);
如果(!(参数长度>2))
{
SendMessage(流,“提供的数据无效”);
}
字符串username=args[1];