473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Proxy server between web browser and web server

Hey all, I'm trying to write a proxy server so that I can capture all data
sent from my web browser to any web server and then capture the response from
the server and send that back to the browser.

However, I've encountered a strange problem where the browser will not load
the data sent to it from my proxy server. I'm successfully able to capture
the data sent from the browser, then I'm able to capture the data sent back
from the web server, but when I try to send that data from the server to the
browser, the browser just sits there as if experiencing network lag.

However, if I just give the browser the first line or two of the data from
the server (and then tag on a carriage return) the browser gets it and stops
loading.

Here is the code that gets the response from the web server and sends it
back to web browser:
-----------------------
while (destStreamReader.Peek() != -1)
{
char [] charBuffer = new char[100];
int result = destStreamReader.Read(charBuffer, 0, 100);
currentInput = new String(charBuffer);
allTextFromInput += currentInput;

sourceStreamWriter.Write(currentInput);
currentInput = null;
}
sourceStreamWriter.Write("\r\n");
sourceStreamWriter.Flush();
sourceNetworkStream.Flush();
-----------------------

I used to just get the data via the WriteLine method, but I changed it to
this way because I thought there might be a problem with the quantity of data
that was being transmitted on each line.

If I only grab the first few 100 characters of data the browser at least
stops loading.

Any suggestions as to why this isn't working?

Thanks,
Novice
Nov 16 '05 #1
1 3690
Novice,

Are you using the correct encoding on the stream reader and writer?
Also, where are you getting the stream for the response? If you are not
getting the headers, and passing them along, then the browser might not know
what to do with the content you send back.

Also, you should be able to copy the byte stream back byte for byte,
there is no reason to convert it to a character array.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Novice" <6tc1ATqlinkDOTqueensuDOTca> wrote in message
news:C2**********************************@microsof t.com...
Hey all, I'm trying to write a proxy server so that I can capture all data
sent from my web browser to any web server and then capture the response
from
the server and send that back to the browser.

However, I've encountered a strange problem where the browser will not
load
the data sent to it from my proxy server. I'm successfully able to
capture
the data sent from the browser, then I'm able to capture the data sent
back
from the web server, but when I try to send that data from the server to
the
browser, the browser just sits there as if experiencing network lag.

However, if I just give the browser the first line or two of the data from
the server (and then tag on a carriage return) the browser gets it and
stops
loading.

Here is the code that gets the response from the web server and sends it
back to web browser:
-----------------------
while (destStreamReader.Peek() != -1)
{
char [] charBuffer = new char[100];
int result = destStreamReader.Read(charBuffer, 0, 100);
currentInput = new String(charBuffer);
allTextFromInput += currentInput;

sourceStreamWriter.Write(currentInput);
currentInput = null;
}
sourceStreamWriter.Write("\r\n");
sourceStreamWriter.Flush();
sourceNetworkStream.Flush();
-----------------------

I used to just get the data via the WriteLine method, but I changed it to
this way because I thought there might be a problem with the quantity of
data
that was being transmitted on each line.

If I only grab the first few 100 characters of data the browser at least
stops loading.

Any suggestions as to why this isn't working?

Thanks,
Novice

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Paul Sweeney | last post by:
Does anyone know of a working (python) https proxy which allows viewing of unencrypted data being sent from my browser to an https site? I've worked my way through most on the list at...
0
by: PeterJ | last post by:
I created some web pages in Visual Studio 2003 in VB and sent them to another fellow to be rolled up into an application. This was sent back to me and I could not open the whole application. Now...
3
by: Soul | last post by:
Hi, I am learning to code a WinForm application which will need to access a Web Service outside the University network. Our University require us to go through a proxy in order to access the...
9
by: Codex Twin | last post by:
I am re-sending this in the hope that it might illicit a response. I have a corporate client who forces their workstations to get the proxy server details using an automatic proxy discovery script....
0
by: Maroller | last post by:
I have a WiFi network comprising a Netgear router, a desktop and a laptop. An ASP web service is set up on the desktop IIS. But when I try to add a web reference to an ASP web application developed...
7
by: Pro1712 | last post by:
Hello, I need to write a simple proxy server. What I want to do is to use HttpListener to get requests from the browser, add some proxy information and some other stuff and send the request to...
0
by: Dan Lenski | last post by:
Hi all, I've recently written an HTTP proxy server for the Motorola E815 cell phone, based on Suzuki Hisao's "Tiny HTTP Proxy" (http:// www.okisoft.co.jp/esc/python/proxy/). This cell phone...
0
by: etnaelk | last post by:
Hi all, I have a real bugger of a problem that I just haven't been able to figure out. I am working on writing my own proxy server in C# using TcpListener, TcpClient, HttpWebRequest/Response and...
3
by: =?Utf-8?B?UmljaGFyZEBub3NwYW0ubm9zcGFt?= | last post by:
My webcam app runs OK on XP but not on Vista. Here's my code snippet that has been working up until now: System.Net.WebRequest request; System.Net.WebResponse response; request =...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.