好的,如果我有这个权利,我的代码可以在特定的 url 获取 cookie,但是一旦我将 cookie 获取到容器中,我如何通过套接字将它发送到客户端?就像下面直接用于常规 http 页面请求的代码一样。
byte[] buffer = new byte[bz];
rebu = responsestream.Read(buffer, 0, bz);
while (rebu != 0)
{
soket.Send(buffer, rebu, 0);
rebu = responsestream.Read(buffer, 0, bz);
}
我的请求/响应代码部分
System.Net.Configuration.HttpWebRequestElement wr = new System.Net.Configuration.HttpWebRequestElement();
wr.UseUnsafeHeaderParsing = true;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
CookieContainer cookieContainer = new CookieContainer();
request.CookieContainer = cookieContainer;
request.CookieContainer.Add(cookieContainer.GetCookies((Uri)url));
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responsestream = response.GetResponseStream();
byte[] buffer = new byte[bz];
rebu = responsestream.Read(buffer, 0, bz);
while (rebu != 0)
{
soket.Send(buffer, rebu, 0);
rebu = responsestream.Read(buffer, 0, bz);
}
这是我正在编码的代理服务器的一部分,我遇到了 cookie 问题。
C#.net3.5