src/share/classes/sun/rmi/transport/proxy/CGIHandler.java
Print this page
@@ -31,10 +31,11 @@
/**
* 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,10 +43,12 @@
/**
* 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,13 +112,13 @@
new CGIPingCommand(),
new CGITryHostnameCommand()
};
/* construct table mapping command strings to handlers */
- private static Hashtable commandLookup;
+ private static Hashtable<String, CGICommandHandler> commandLookup;
static {
- commandLookup = new Hashtable();
+ commandLookup = new Hashtable<>();
for (int i = 0; i < commands.length; ++ i)
commandLookup.put(commands[i].getName(), commands[i]);
}
/* prevent instantiation of this class */
@@ -138,11 +141,11 @@
else {
command = QueryString.substring(0, delim);
param = QueryString.substring(delim + 1);
}
CGICommandHandler handler =
- (CGICommandHandler) commandLookup.get(command);
+ commandLookup.get(command);
if (handler != null)
try {
handler.execute(param);
} catch (CGIClientException e) {
returnClientError(e.getMessage());
@@ -198,18 +201,23 @@
}
}
/**
* "forward" command: Forward request body to local port on the server,
- * and send reponse back to client.
+ * 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,21 +282,22 @@
boolean contentLengthFound = false;
String line;
int responseContentLength = -1;
do {
try {
- line = socketIn.readLine();
+ 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)
- ; // what would we want to do in this case??
+ 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) &&