New topic: Writing a simple web proxy in RealBasic
<http://forums.realsoftware.com/viewtopic.php?t=30491> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message motorollin Post subject: Writing a simple web proxy in RealBasicPosted: Thu Oct 15, 2009 6:44 am Joined: Mon Jun 16, 2008 4:53 pm Posts: 22 For complicated reasons I won't go in to right now, I need to write a simple web proxy. Here's what I've come up with so far: 1. ServerSocket1: Listens on port 8080. This accepts incoming web requests from the browser. 2. ServerSocket1.AddSocket: Code:return new ClientSocket 3. ClientSocket: Custom Class whose super is TCPSocket 4. ClientSocket.DataAvailable: Code: //Get the HTTP request sent by the browser Dim data as string = Me.ReadAll //Filtering stuff will go here //... //Create the socket which will connect to the proxy server Me.Web = new WebSocket //Give the proxy socket a reference back to this socket so it can send the data back to the browser Me.Web.ReturnSocket = Me //Connect to the proxy Me.Web.Address = "localhost" Me.Web.Port = 8081 Me.Web.Connect //Forward the browser's request to the proxy Me.Web.Write(data) 5. WebSocket = Custom Class whose super is TCPSocket 6. WebSocket.DataAvailable: Code: //Read the response from the proxy Dim data as string = Me.ReadAll //Write the response back to the browser Me.ReturnSocket.Write(data) 7. WebSocket.ReturnSocket: TCPSocket to refer back to the socket to write the response from the proxy This works perfectly well for simple sites like Google. The problem is with more complicated sites, in which cases most of the page fails to load and I get errors in Safari's Activity window. Is there a better way to do this? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
