提交 2e3f6411 编写于 作者: C coffeys

8007315: HttpURLConnection.filterHeaderField method returns null where empty string is expected

Reviewed-by: chegar
上级 34aeb550
/*
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -2637,7 +2637,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
multipleCookies = true;
}
return retValue.length() == 0 ? null : retValue.toString();
return retValue.length() == 0 ? "" : retValue.toString();
}
return value;
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -22,7 +22,7 @@
*/
/**
* @test
* @bug 7095980
* @bug 7095980 8007315
* @summary Ensure HttpURLConnection (and supporting APIs) don't expose
* HttpOnly cookies
*/
......@@ -52,6 +52,8 @@ import com.sun.net.httpserver.HttpServer;
* 4) check HttpOnly cookies received by server
* 5) server reply with Set-Cookie containing HttpOnly cookie
* 6) check HttpOnly cookies are not accessible from Http client
* 7) check that non-null (empty string) values are returned for
scenario where all values are stripped from original key values
*/
public class HttpOnly {
......@@ -177,6 +179,36 @@ public class HttpOnly {
" value " + val);
}
}
// TEST 7 : check that header keys containing empty key values don't return null
int i = 1;
String key = "";
String value = "";
while (true) {
key = uc.getHeaderFieldKey(i);
value = uc.getHeaderField(i++);
if (key == null && value == null)
break;
if (key != null)
check(value != null,
"Encountered a null value for key value : " + key);
}
// TEST 7.5 similar test but use getHeaderFields
respHeaders = uc.getHeaderFields();
respEntries = respHeaders.entrySet();
for (Map.Entry<String,List<String>> entry : respEntries) {
String header = entry.getKey();
if (header != null) {
List<String> listValues = entry.getValue();
for (String value1 : listValues)
check(value1 != null,
"getHeaderFields returned null values for header:, "
+ header);
}
}
}
// HTTP Server
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册