Handler.java (10444:f08705540498) | Handler.java (12588:108912ec77eb) |
---|---|
1/* 2 * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided --- 102 unchanged lines hidden (view full) --- 111 { 112 return new FileURLConnection(u, file); 113 } 114 115 /** 116 * Compares the host components of two URLs. 117 * @param u1 the URL of the first host to compare 118 * @param u2 the URL of the second host to compare | 1/* 2 * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided --- 102 unchanged lines hidden (view full) --- 111 { 112 return new FileURLConnection(u, file); 113 } 114 115 /** 116 * Compares the host components of two URLs. 117 * @param u1 the URL of the first host to compare 118 * @param u2 the URL of the second host to compare |
119 * @return <tt>true</tt> if and only if they 120 * are equal, <tt>false</tt> otherwise. | 119 * @return {@code true} if and only if they 120 * are equal, {@code false} otherwise. |
121 */ 122 protected boolean hostsEqual(URL u1, URL u2) { 123 /* 124 * Special case for file: URLs 125 * per RFC 1738 no hostname is equivalent to 'localhost' 126 * i.e. file:///path is equal to file://localhost/path 127 */ 128 String s1 = u1.getHost(); 129 String s2 = u2.getHost(); 130 if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) 131 return true; 132 if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) 133 return true; 134 return super.hostsEqual(u1, u2); 135 } 136} | 121 */ 122 protected boolean hostsEqual(URL u1, URL u2) { 123 /* 124 * Special case for file: URLs 125 * per RFC 1738 no hostname is equivalent to 'localhost' 126 * i.e. file:///path is equal to file://localhost/path 127 */ 128 String s1 = u1.getHost(); 129 String s2 = u2.getHost(); 130 if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) 131 return true; 132 if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) 133 return true; 134 return super.hostsEqual(u1, u2); 135 } 136} |