Diagnosing Proxy Server Problems 
by Russ Ethington


Figure 1:

GET http://www.yahoo.com/ HTTP/1.0
Accept: image/gif, image/jpeg, image/pjpeg, */* 
Accept-Language: en-us 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) 
Host: www.yahoo.com 
Proxy-Connection: Keep-Alive 
Cookie: B=c5tdn55nvdmeb 

Figure 2:

HTTP/1.1 200 OK 
Via: 1.0 MSPROXY1 
Proxy-Connection: Keep-Alive 
Content-length: 11835 
Content-type: text/html
[...actual HTML for the page follows...]

Figure 3:
GET http://www.yahoo.com/ HTTP/1.0
Proxy-Connection: Keep-Alive 
User-Agent: Mozilla/4.7 [en]C-LBv3  (WinNT; U) 
Host: www.yahoo.com 
Accept: image/gif, image/jpeg, image/pjpeg, image/png, */* 
Accept-Encoding: gzip 
Accept-Language: en 
Accept-Charset: iso-8859-1,*,utf-8 
Cookie: B=058bhjdt8pqau 

Figure 4:
"Proxy-Authenticate: Basic".
HTTP/1.1 407 Proxy authentication required 
Proxy-Authenticate: NTLM 
Content-Length: 503 
Content-Type: text/html 
[...Netscape 4.7 goes into an infinite loop here, retrying...]


Figure 5:
HTTP/1.1 407 Proxy authentication required
Proxy-Authenticate: NTLM
Proxy-Authenticate: Basic realm="www.yahoo.com" 
[...]


Figure 6:
my-pc> java TCPMapper 8080 my-proxy:80

Figure 7:
(a)
public class TCPMapper extends ConcurrentServer

(b)
public void handleSession(Socket socketFromClient)

(c)
socketToServer = new Socket(proxyHost, proxyPort);


Listing One
clientIn = new DataInputStream(socketFromClient.getInputStream());
clientOut = new DataOutputStream(socketFromClient.getOutputStream());

socketToServer = new Socket(proxyHost, proxyPort);
serverIn = socketToServer.getInputStream();
serverOut = socketToServer.getOutputStream();

ByteCopier copier1 = null;
ByteCopier copier2 = null;
DataLogger logger1 = null;
DataLogger logger2 = null;

if (logging)
{
    logger1 = new DataLogger(uniqueId, "To");
    logger2 = new DataLogger(uniqueId, "From");
    copier1 = new ByteCopier(clientIn, serverOut, logger1);
    copier2 = new ByteCopier(serverIn, clientOut, logger2);
}
else 
{
    copier1 = new ByteCopier(clientIn, serverOut);
    copier2 = new ByteCopier(serverIn, clientOut);
}
copier1.start();
copier2.start();
while (copier1.isAlive() && copier2.isAlive()) waitHere(100);

Listing Two
public interface LineListener
{
    public void dataAlert(int data);
    public void dataAlert(String data);
}





1

