Details
-
Bug
-
Resolution: Fixed
-
P3
-
8, 9, 11
-
b10
-
generic
-
generic
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8230276 | 13.0.2 | Michael McMahon | P3 | Resolved | Fixed | b01 |
JDK-8230277 | 11.0.6-oracle | Michael McMahon | P3 | Resolved | Fixed | b01 |
JDK-8233969 | 11.0.6 | Michael McMahon | P3 | Resolved | Fixed | b04 |
JDK-8239177 | openjdk8u252 | Yuri Nesterenko | P3 | Resolved | Fixed | b03 |
JDK-8236068 | openjdk8u242 | Yuri Nesterenko | P3 | Resolved | Fixed | b05 |
JDK-8230278 | 8u241 | Robert Mckenna | P3 | Resolved | Fixed | b01 |
JDK-8235050 | emb-8u241 | Robert Mckenna | P3 | Resolved | Fixed | team |
Description
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
If setRequestProperty method is called on HttpURLConnection object with non-empty "key" and "value" set to null, the corresponding HTTP header is inserted into the request, but without ":" (colon). The header name passed via "key" is directly followed by CR LF. This is violation of HTTP protocol, since colons in headers are mandatory.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the included source code and run it passing any HTTP URL as a parameter and inspect network traffic with a sniffer. For example:
java -cp . Test1 http://www.ya.ru
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In no conditions an HTTP header without colon should ever be put into a request. Possible platform behavior for passed null as value of "value" argument may include:
- Throwing NullPointerException (the preferred approach)
- Adding a valid HTTP header with name passed in "key" argument and empty value. The colon MUST be present.
- Not adding a header.
ACTUAL -
The following request is being generated and sent to the server for described example. Note the missing ":" in "MyHeader" header:
GET / HTTP/1.1
MyHeader
User-Agent: Java/1.8.0_131
Host: www.ya.ru
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Test1 {
public static void main(String[] asArguments) throws MalformedURLException, IOException {
URL rURL = new URL(asArguments[0]);
URLConnection rConnection = rURL.openConnection();
rConnection.setRequestProperty("MyHeader", null);
BufferedReader in = new BufferedReader(new InputStreamReader(rConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
in.close();
}
}
---------- END SOURCE ----------
Attachments
Issue Links
- backported by
-
JDK-8230276 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8230277 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8230278 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8233969 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8235050 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8236068 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved
-
JDK-8239177 setRequestProperty(key, null) results in HTTP header without colon in request
- Resolved