Mercurial > hg > openjdk > jigsaw > jdk
changeset 7026:01b6b0dd2006
8007315: HttpURLConnection.filterHeaderField method returns null where empty string is expected
Reviewed-by: chegar
author | coffeys |
---|---|
date | Tue, 19 Feb 2013 14:12:09 +0000 |
parents | 885bb24f6018 |
children | 824187de1591 |
files | src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java test/sun/net/www/protocol/http/HttpOnly.java |
diffstat | 2 files changed, 36 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Tue Feb 19 14:07:25 2013 +0000 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Tue Feb 19 14:12:09 2013 +0000 @@ -1,5 +1,5 @@ /* - * 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 @@ multipleCookies = true; } - return retValue.length() == 0 ? null : retValue.toString(); + return retValue.length() == 0 ? "" : retValue.toString(); } return value;
--- a/test/sun/net/www/protocol/http/HttpOnly.java Tue Feb 19 14:07:25 2013 +0000 +++ b/test/sun/net/www/protocol/http/HttpOnly.java Tue Feb 19 14:12:09 2013 +0000 @@ -1,5 +1,5 @@ /* - * 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 @@ * 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 @@ " 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