mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-03 19:48:46 +00:00
Michael's review - make sure the status line parsing considers only the space character
This commit is contained in:
parent
a216241058
commit
3dbc2eb83c
@ -2041,7 +2041,11 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
if (statusLine == null || statusLine.isBlank()) {
|
||||
return invalidStatusLine;
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(statusLine);
|
||||
//
|
||||
// status-line = HTTP-version SP status-code SP [ reason-phrase ]
|
||||
// SP = space character
|
||||
//
|
||||
final StringTokenizer st = new StringTokenizer(statusLine, " ");
|
||||
if (!st.hasMoreTokens()) {
|
||||
return invalidStatusLine;
|
||||
}
|
||||
@ -2049,7 +2053,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
if (!st.hasMoreTokens()) {
|
||||
return invalidStatusLine;
|
||||
}
|
||||
final String v = st.nextToken().trim(); // response code
|
||||
final String v = st.nextToken().trim(); // status code
|
||||
try {
|
||||
return Integer.parseInt(v);
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
||||
@ -66,7 +66,10 @@ class ProxyBadStatusLine {
|
||||
Arguments.of("HTTP/1.1\n", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1 301 ", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1 404 ", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1 503 ", "Unable to tunnel through proxy")
|
||||
Arguments.of("HTTP/1.1 503 ", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1\n200 ", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1\r200 ", "Unable to tunnel through proxy"),
|
||||
Arguments.of("HTTP/1.1\f200 ", "Unable to tunnel through proxy")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user