Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8263899: HttpClient throws NPE in AuthenticationFilter when parsing www-authenticate head #3113

Closed
wants to merge 6 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/jdk/java/net/httpclient/EmptyAuthenticate.java
Original file line number Diff line number Diff line change
@@ -41,13 +41,15 @@
public class EmptyAuthenticate {

public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
int port = 8000;
int port = 0;

//start server:
HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
port = server.getAddress().getPort();
server.createContext("/", exchange -> {
String response = "test body";
exchange.getResponseHeaders().add("www-authenticate", ""); //this empty header will make the HttpClient crash
//this empty header will make the HttpClient throw NPE
exchange.getResponseHeaders().add("www-authenticate", "");
exchange.sendResponseHeaders(401, response.length());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/crash/throw NPE

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

OutputStream os = exchange.getResponseBody();
os.write(response.getBytes());