Hi, all
I have been doing some dev work using jmeters proxy server (I am using the
proxy from jmeter beta 2). i have noticed that there is a newer version out,
but that one changes completely the way the whole thing works and it is
dependent on a lot of other classes as well, which i really dont want to add
to my project.
so here it is:
When trying to do a POST from the browser through the proxy i get an error,
which is basically caused by the fact that there are NO bytes in the
client's socket.inputsream to read (i can verify that by calling the
ClientSocket.getInputStream().available() method. The thing is that i know
the browser is posting data e.g the browser sends an intial request such as:
POST
blah blah
.....
CONTENT-LENGTH 254
.....
which means that the browser is supposed to post 254 bytes of data.
is it possible that the post bytes are read with the initial request for an
uknown reason ?
Below you can see (red highlighted code) where i am trying to read the the
post bytes from the inputstream.
thanx a lot in advance
Nick
try
{
//
// Read HTTP Request from client
//
ClientSocket.setSoTimeout(6000);
request.parse(ClientSocket.getInputStream());
config.increaseFilesCached();
url = new URL(request.url);
requestBuffer.append(url.toString());
config.hasChanged();
config.notifyObservers();
// for debug purposes print the parsed request in text area
output.set("\nRequest " + request.toString());
serverName = url.getHost();
config.increaseMisses();
SrvrSocket = new
Socket(request.serverName(),request.serverPort());
DataOutputStream srvOut = new
DataOutputStream(SrvrSocket.getOutputStream());
request.url = request.serverUrl();
//
// Send the url to web server (or father proxy)
//
srvOut.writeBytes(request.toString(true));
srvOut.flush();
// Send data to server (needed for post method)
//**************** Does not work properly*******************
StringBuffer buff = new StringBuffer();
int readValue;
for (int i = 0; i < request.contentLength; i++)
{
try
{
readValue = ClientSocket.getInputStream().read();
buff.append((char)readValue);
SrvrSocket.getOutputStream().write(readValue);
}
catch(InterupptedException e)
{
output.set(e.getMessage());
break;
}
}
SrvrSocket.getOutputStream().flush();
}