public void handleConnect(HttpServletRequest request,
HttpServletResponse response, String serverName) {
int length = request.getContentLength();
if (length > 0) {
HttpTunnelPacket p = null;
try {
ServletInputStream sis = request.getInputStream();
p = new HttpTunnelPacket();
p.readPacket(sis);
} catch (Exception e) {
return;
}
if (p == null) {
return;
}
if (serverName == null) {
serverName = linkTable.getDefaultServer();
}
if (serverName == null) {
return;
}
if (linkTable.getListenState(serverName) == false) {
return;
}
// Allocate a new connection ID and setup pullQ...
int connId = linkTable.createNewConn(serverName);
if (connId == -1) {
return;
}
p.setConnId(connId);
try {
p.setPacketBody(("ServerName=" + serverName).getBytes("UTF8"));
// Echo the connection request back to the client side
// driver with the correct connId, so that it can
// start sending the pull requests...
ServletOutputStream sos = response.getOutputStream();
p.writePacket(sos);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeUTF("ServerName=" + serverName);
dos.writeUTF(request.getRemoteAddr());
dos.flush();
bos.flush();
p.setPacketBody(bos.toByteArray());
// Forward the connection request to server side driver
// with the correct connId.
linkTable.sendPacket(p, serverName);
} catch (Exception e) {
servletContext.log(servletName + ": client connect: " +