New topic: problem with simple HTTP(S) webproxy
<http://forums.realsoftware.com/viewtopic.php?t=39783> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message spacewalker Post subject: problem with simple HTTP(S) webproxyPosted: Mon Jul 11, 2011 4:23 am Joined: Thu Nov 08, 2007 4:59 am Posts: 359 Location: Germany Hello, I try to write a simple webproxy. It works for HTTP connections, but not for HTTPS However, a HTMLViewer-Control that I use for testing does display the HTTPS-page correctly - so I get a response from the Webserver I just can't send the server-response to the client (browser) I do the following: For the serversocket : Code: server= new HTTPServerSocket server.port = 80 //8080 server.MinimumSocketsAvailable =200 'server.MinimumSocketsConnected =100 server.MaximumSocketsConnected =600 server.Listen Then I have a TCPSocket named "HTTPConnection" In it's dataAvailabe event I have this code: Code:Sub DataAvailable(): if instrb (Lookahead(), chr(13)+chr(10)) = 0 then Return '** wait til CRLF is in Buffer sBuffer = ReadAll() sBuffer = trim (sBuffer) sURL = NthField(sBuffer," ",2) '** Buffer: "GET http://www.google.com/ HTTP/1.1" ---> URL: "http://www.google.com" if instr (sURL,":443")>0 then '**fetch data from website using SSL / HTTPS surl = "https://" + surl dim myHTTP as new HTTPSecureSocket //use Secure Socket myHTTP.Secure = true //use SSL myHTTP.yield=true 'myHTTP.SetRequestHeader("User-Agent" , "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8") sHTMLData = myHTTP.Get (sURL,15) 'sHTMLData = myHTTP.Get ("https://mail.googlemail.com:443", 15 ) '**as a test: display server-response in a HTMLViewer window1.HTMLViewer1.LoadPage sHTMLData,NIL // <-- this does work, I see the page else **fetch data from website using HTTP dim myHTTP as HTTPSocket //use "normal" Socket myHTTP = new HTTPSocket myHTTP.yield=true sHTMLData = myHTTP.Get (sURL,15) // eg. ("http://www.google.com",5) '**as a test: display server-response in a HTMLViewer window1.HTMLViewer1.LoadPage sHTMLData,NIL end 'when here sHTMLData contains the server's-response (HTML code) - send this now to the client (browser) '** send data to browser write sHTMLData //<-- it seems that this part doesnt work for HTTPS.. at least the browser displays nothing I use Windows and IE7 Thanks, Heinz 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]
