-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[
ADDITIONAL OS VERSION INFORMATION :
Linux artemis 4.9.13-101.fc24.x86_64 #1 SMP Tue Mar 7 23:48:32 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
A plain HttpUrlConnection created like this:
URL url = new URL("http", "localhost", 8888, "/");
URLConnection conn = url.openConnection();
conn.getInputStream();
Sends a request with a header line:
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
In this list of media ranges, the media range "*; q=.2" is illegal. RFC 7231, section 5.3.2 defines a media range as
media-range = ( "*/*"
/ ( type "/" "*" )
/ ( type "/" subtype )
) *( OWS ";" OWS parameter )
So the part without the parameter must be
( "*/*"
/ ( type "/" "*" )
/ ( type "/" subtype )
This obviously does not include "*".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program above, use e.g. wireshark to get the header sent.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An RFC compliant header.
ACTUAL -
See above.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Explicitly set the accept range, e.g.:
URLConnection conn = url.openConnection();
// URLConnection default accept header is illegal
conn.setRequestProperty("Accept", "*/*");
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[
ADDITIONAL OS VERSION INFORMATION :
Linux artemis 4.9.13-101.fc24.x86_64 #1 SMP Tue Mar 7 23:48:32 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
A plain HttpUrlConnection created like this:
URL url = new URL("http", "localhost", 8888, "/");
URLConnection conn = url.openConnection();
conn.getInputStream();
Sends a request with a header line:
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
In this list of media ranges, the media range "*; q=.2" is illegal. RFC 7231, section 5.3.2 defines a media range as
media-range = ( "*/*"
/ ( type "/" "*" )
/ ( type "/" subtype )
) *( OWS ";" OWS parameter )
So the part without the parameter must be
( "*/*"
/ ( type "/" "*" )
/ ( type "/" subtype )
This obviously does not include "*".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program above, use e.g. wireshark to get the header sent.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An RFC compliant header.
ACTUAL -
See above.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Explicitly set the accept range, e.g.:
URLConnection conn = url.openConnection();
// URLConnection default accept header is illegal
conn.setRequestProperty("Accept", "*/*");
- duplicates
-
JDK-8163921 HttpURLConnection default Accept header is malformed according to HTTP/1.1 RFC
- Closed