views:

22

answers:

2

I wrote a Proxy in C# using sockets and a TCPListener listening to a particular port. Currently the listener gets the "GET" request from the clients browser, and then uses the Socket.Send() class to forward the request on behalf of of the client. The response is recieved using the Socket.Reveive() class and then forwarded onto the client using Socket.Send() once again.

This works lovely when the client requests a basic html website. However when the client requests a website that contains some javascript such as <body onload='doThis();', it fails to run the javascript.

In this specific scenario, the javasript function does a redirect. Do I need to change something in the socket settings to allow the javascript to run when it gets sent to the client?

A: 

Hard to say without a lot more informations.

Is the javascript function "doThis()" implemented inside the html file, or does it come from an includes .js file? If it comes from an included .js-file, make sure that "text/javascript" is send as content type in the header, otherwise some browsers will not run the js.

Is the JavaScript really not executed or does just the forward not work? Tried it with <body onload='alert('test');' ? Does it execute?

If yes: What does your redirect JS exactly looks like?

If not: What do you do after "Socket.Send()"? Do you in any way give the client a sign, that the page is ready? Some browsers won't execute the onLoad, until the page is said to be complete. Did you try to explicitly close the connection after the file was send to the client?

Alex
A: 

Problem solved. There issue was on the client PC. Restarted it, tried again and it worked like a bomb.

Yo Momma