changeset 7515:d977b736a139

Merge
author asaha
date Tue, 29 Apr 2014 14:58:44 -0700
parents 3902dc166d37 0ae4b35ec523
children 9a5aa33fadc4
files .hgtags test/java/net/CookieHandler/LocalHostCookie.java
diffstat 3 files changed, 4 insertions(+), 128 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Apr 25 18:09:54 2014 +0100
+++ b/.hgtags	Tue Apr 29 14:58:44 2014 -0700
@@ -425,6 +425,7 @@
 b7fbd9b4febf8961091fdf451d3da477602a8f1d jdk7u60-b14
 04882f9a073e8de153ec7ad32486569fd9a087ec jdk7u60-b15
 41547583c3a035c3924ffedfa8704e58d69e5c50 jdk7u60-b16
+e484202d9a4104840d758a21b2bba1250e766343 jdk7u60-b18
 c220d329a78161f79df73048ed55db91f538e3b7 jdk7u65-b01
 a42a3bb22f6991d8f6a30e4f1782ad620c40eb65 jdk7u65-b02
 756071871d61e1ca410c63a3f1c4dabcc51a90df jdk7u65-b03
@@ -434,7 +435,9 @@
 cde691a6989fa875107a3974aa92681d286be6ec jdk7u65-b07
 d5353f8e1e02e12a1262d65ed85183425b0cdf13 jdk7u65-b08
 45913a29c1edd3e63c9c818ffab7aebd4d75fa40 jdk7u65-b09
+3bb943c6ff7dd614cb428501db8c2c655e5f5223 jdk7u65-b10
 9ccfe70cee626ac7831cfa7b7a7eb7a88fe1cd42 jdk7u66-b00
 fc87b55d62fc1e81aaf61ff21175129b8ccc302e jdk7u66-b01
 c67e394e49429565540f04c5c2a5544f750658bb jdk7u66-b09
+257fd79cdef52511db18e1bab8967d94a03920bc jdk7u66-b10
 ee0cedc50d3250edf24e96aecc785580dd61944f jdk7u71-b00
--- a/src/share/classes/java/net/CookieManager.java	Fri Apr 25 18:09:54 2014 +0100
+++ b/src/share/classes/java/net/CookieManager.java	Tue Apr 29 14:58:44 2014 -0700
@@ -310,10 +310,7 @@
                         // there is no dot at the beginning of effective request-host,
                         // the default Domain can only domain-match itself.)
                         if (cookie.getDomain() == null) {
-                            String host = uri.getHost();
-                            if (host != null && !host.contains("."))
-                                host += ".local";
-                            cookie.setDomain(host);
+                            cookie.setDomain(uri.getHost());
                         }
                         String ports = cookie.getPortlist();
                         if (ports != null) {
--- a/test/java/net/CookieHandler/LocalHostCookie.java	Fri Apr 25 18:09:54 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import com.sun.net.httpserver.*;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.*;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executors;
-
-/*
- * @test
- * @bug 7169142
- * @summary CookieHandler does not work with localhost
- * @run main/othervm LocalHostCookie
- */
-public class LocalHostCookie {
-
-    public static void main(String[] args) throws Exception {
-        new LocalHostCookie().runTest();
-    }
-
-    public void runTest() throws Exception {
-        Server s = null;
-        try {
-            s = new Server();
-            s.startServer();
-            URL url = new URL("http","localhost", s.getPort(), "/");
-            HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
-            urlConnection.setRequestMethod("GET");
-            urlConnection.setDoOutput(true);
-            urlConnection.connect();
-            urlConnection.getInputStream();
-
-            CookieHandler cookieHandler = CookieHandler.getDefault();
-            if (cookieHandler == null) {
-                cookieHandler = new java.net.CookieManager();
-                CookieHandler.setDefault(cookieHandler);
-            }
-            cookieHandler.put(urlConnection.getURL().toURI(),
-                    urlConnection.getHeaderFields());
-            Map<String, List<String>> map =
-                    cookieHandler.get(urlConnection.getURL().toURI(),
-                    urlConnection.getHeaderFields());
-            if (map.containsKey("Cookie")) {
-                List<String> list = map.get("Cookie");
-                // name-value list will be empty if ".local" is not appended
-                if (list == null || list.size() ==  0) {
-                    throw new RuntimeException("Test failed!");
-                }
-            }
-        } finally {
-            s.stopServer();
-        }
-    }
-
-    class Server {
-        HttpServer server;
-
-        public void startServer() {
-            InetSocketAddress addr = new InetSocketAddress(0);
-            try {
-                server = HttpServer.create(addr, 0);
-            } catch (IOException ioe) {
-                throw new RuntimeException("Server could not be created");
-            }
-
-            server.createContext("/", new MyCookieHandler());
-            server.start();
-        }
-
-        public int getPort() {
-            return server.getAddress().getPort();
-        }
-
-        public void stopServer() {
-            server.stop(0);
-        }
-    }
-
-    class MyCookieHandler implements HttpHandler {
-
-        @Override
-        public void handle(HttpExchange exchange) throws IOException {
-            String requestMethod = exchange.getRequestMethod();
-            if (requestMethod.equalsIgnoreCase("GET")){
-                Headers responseHeaders = exchange.getResponseHeaders();
-                responseHeaders.set("Content-Type", "text/plain");
-                responseHeaders.set("Date", "June 13th 2012");
-                // No domain value set
-                responseHeaders.set("Set-Cookie2", "name=value");
-                exchange.sendResponseHeaders(200, 0);
-                OutputStream os = exchange.getResponseBody();
-                String str = "This is what the server sent!";
-                os.write(str.getBytes());
-                os.flush();
-                os.close();
-            }
-        }
-    }
-}
-