src/share/classes/sun/rmi/transport/proxy/CGIHandler.java
Print this page
*** 31,40 ****
--- 31,41 ----
/**
* CGIClientException is thrown when an error is detected
* in a client's request.
*/
class CGIClientException extends Exception {
+ private static final long serialVersionUID = 8147981687059865216L;
public CGIClientException(String s) {
super(s);
}
}
*** 42,51 ****
--- 43,54 ----
/**
* CGIServerException is thrown when an error occurs here on the server.
*/
class CGIServerException extends Exception {
+ private static final long serialVersionUID = 6928425456704527017L;
+
public CGIServerException(String s) {
super(s);
}
}
*** 109,121 ****
new CGIPingCommand(),
new CGITryHostnameCommand()
};
/* construct table mapping command strings to handlers */
! private static Hashtable commandLookup;
static {
! commandLookup = new Hashtable();
for (int i = 0; i < commands.length; ++ i)
commandLookup.put(commands[i].getName(), commands[i]);
}
/* prevent instantiation of this class */
--- 112,124 ----
new CGIPingCommand(),
new CGITryHostnameCommand()
};
/* construct table mapping command strings to handlers */
! private static Hashtable<String, CGICommandHandler> commandLookup;
static {
! commandLookup = new Hashtable<>();
for (int i = 0; i < commands.length; ++ i)
commandLookup.put(commands[i].getName(), commands[i]);
}
/* prevent instantiation of this class */
*** 138,148 ****
else {
command = QueryString.substring(0, delim);
param = QueryString.substring(delim + 1);
}
CGICommandHandler handler =
! (CGICommandHandler) commandLookup.get(command);
if (handler != null)
try {
handler.execute(param);
} catch (CGIClientException e) {
returnClientError(e.getMessage());
--- 141,151 ----
else {
command = QueryString.substring(0, delim);
param = QueryString.substring(delim + 1);
}
CGICommandHandler handler =
! commandLookup.get(command);
if (handler != null)
try {
handler.execute(param);
} catch (CGIClientException e) {
returnClientError(e.getMessage());
*** 198,215 ****
}
}
/**
* "forward" command: Forward request body to local port on the server,
! * and send reponse back to client.
*/
final class CGIForwardCommand implements CGICommandHandler {
public String getName() {
return "forward";
}
public void execute(String param) throws CGIClientException, CGIServerException
{
if (!CGIHandler.RequestMethod.equals("POST"))
throw new CGIClientException("can only forward POST requests");
--- 201,223 ----
}
}
/**
* "forward" command: Forward request body to local port on the server,
! * and send response back to client.
*/
final class CGIForwardCommand implements CGICommandHandler {
public String getName() {
return "forward";
}
+ @SuppressWarnings("deprecation")
+ private String getLine (DataInputStream socketIn) throws IOException {
+ return socketIn.readLine();
+ }
+
public void execute(String param) throws CGIClientException, CGIServerException
{
if (!CGIHandler.RequestMethod.equals("POST"))
throw new CGIClientException("can only forward POST requests");
*** 274,294 ****
boolean contentLengthFound = false;
String line;
int responseContentLength = -1;
do {
try {
! line = socketIn.readLine();
} catch (IOException e) {
throw new CGIServerException("error reading from server");
}
if (line == null)
throw new CGIServerException(
"unexpected EOF reading server response");
if (line.toLowerCase().startsWith(key)) {
! if (contentLengthFound)
! ; // what would we want to do in this case??
responseContentLength =
Integer.parseInt(line.substring(key.length()).trim());
contentLengthFound = true;
}
} while ((line.length() != 0) &&
--- 282,302 ----
boolean contentLengthFound = false;
String line;
int responseContentLength = -1;
do {
try {
! line = getLine(socketIn);
} catch (IOException e) {
throw new CGIServerException("error reading from server");
}
if (line == null)
throw new CGIServerException(
"unexpected EOF reading server response");
if (line.toLowerCase().startsWith(key)) {
! // if contentLengthFound is true
! // we should probably do something here
responseContentLength =
Integer.parseInt(line.substring(key.length()).trim());
contentLengthFound = true;
}
} while ((line.length() != 0) &&