There is a task - to write a simple proxy server. Well, this task is 'almost' completed. I think i'm re-inventing the wheel but I don't mind, my proxy works like this:
There's a HttpListener that listens and launches a processing thread at web request of a client. Then the processing thread forms a WebRequest to the necessary site, downloads its contents, removes all the flash, tops, counters and adclicks and returns it all to the client.
As I said this 'almost' works. The problems start when I need to get an authorization on some resource (web mail or forum or whatever).
So, the first question is whether am I doing everything right with cookies:
The second question - I'm not sure if I process POST requests right:vb Code:
Dim CookieCont As CookieContainer = Nothing If DownStream_Request.Cookies.Count <> 0 Then CookieCont = New CookieContainer Dim c As Cookie For Each c In DownStream_Request.Cookies If c.Domain = "" Then c.Domain = UB.Host End If CookieCont.Add(c) Next End If UpStream_Request.CookieContainer = CookieCont
vb Code:
If DownStream_Request.HttpMethod.ToLower = "post" Then UpStream_Request_Stream = UpStream_Request.GetRequestStream DownStream_Request_Stream = DownStream_Request.InputStream Do bytesRead = DownStream_Request_Stream.Read(buffer, 0, buffer.Length) UpStream_Request_Stream.Write(buffer, 0, bytesRead) If bytesRead = 0 Then UpStream_Request_Stream.Flush() UpStream_Request_Stream.Close() DownStream_Response.Redirect(requested_uri.ToString) DownStream_Response.Close() ThreadCol.Remove(mythread) Exit Sub End If Loop End If
Anyway, I don't understand what else should I do in order to get authorizations on forums and mail work properly.


Reply With Quote