Re: best way to resolve an "absolute" URI
Hi Max, You should take a look at how this is done in FileServerHandler.java [1] ( one of the httpserver tests in the regression library). I think it does what you are trying to do. -Chris. [1] http://hg.openjdk.java.net/jdk7/tl/jdk/file/9f08a221e5f2/test/com/sun/net/httpserver/FileServerHandler.java On 04/ 6/11 05:02 AM, Weijun Wang wrote: Hi Guys I am writing a test that starts a small HttpServer, and I write my HttpHandler like this: static class MyHttpHandler implements HttpHandler { private final URI root; MyHttpHandler(String fileroot) { root = new File(fileroot).toURI(); } public void handle(HttpExchange t) throws IOException { URI uri = root.resolve(t.getRequestURI()); ... Here, root is the root of the webserver, and when a request comes in, I'd like to resolve the request URI to the real URI in a file system. Unfortunately, t.getRequestURI() already returns an absolute URI (say, "/"), so the result uri is the same of it. We all know the "/" in "GET /" is in fact not an absolute URI. What is the elegant way to resolve it? I'm now using URI uri = root.resolve(t.getRequestURI().toString().substring(1)); but it looks so ugly. Thanks Max
Re: best way to resolve an "absolute" URI
It seems I shouldn't use t.getRequestURI() as a real URI, its getPath() is much better. Thanks Max On 04/06/2011 05:09 PM, Chris Hegarty wrote: Hi Max, You should take a look at how this is done in FileServerHandler.java [1] ( one of the httpserver tests in the regression library). I think it does what you are trying to do. -Chris. [1] http://hg.openjdk.java.net/jdk7/tl/jdk/file/9f08a221e5f2/test/com/sun/net/httpserver/FileServerHandler.java On 04/ 6/11 05:02 AM, Weijun Wang wrote: Hi Guys I am writing a test that starts a small HttpServer, and I write my HttpHandler like this: static class MyHttpHandler implements HttpHandler { private final URI root; MyHttpHandler(String fileroot) { root = new File(fileroot).toURI(); } public void handle(HttpExchange t) throws IOException { URI uri = root.resolve(t.getRequestURI()); ... Here, root is the root of the webserver, and when a request comes in, I'd like to resolve the request URI to the real URI in a file system. Unfortunately, t.getRequestURI() already returns an absolute URI (say, "/"), so the result uri is the same of it. We all know the "/" in "GET /" is in fact not an absolute URI. What is the elegant way to resolve it? I'm now using URI uri = root.resolve(t.getRequestURI().toString().substring(1)); but it looks so ugly. Thanks Max
hg: jdk7/tl/jdk: 6312706: Map entrySet iterators should return different entries on each call to next()
Changeset: c1e87a18e46a Author:mduigou Date: 2011-04-06 09:31 -0700 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c1e87a18e46a 6312706: Map entrySet iterators should return different entries on each call to next() Reviewed-by: mduigou, alanb Contributed-by: Neil Richards ! src/share/classes/java/util/EnumMap.java ! src/share/classes/java/util/IdentityHashMap.java + test/java/util/EnumMap/DistinctEntrySetElements.java + test/java/util/EnumMap/EntrySetIteratorRemoveInvalidatesEntry.java + test/java/util/EnumMap/SimpleSerialization.java + test/java/util/IdentityHashMap/DistinctEntrySetElements.java + test/java/util/IdentityHashMap/EntrySetIteratorRemoveInvalidatesEntry.java + test/java/util/concurrent/ConcurrentHashMap/DistinctEntrySetElements.java
hg: jdk7/tl/jdk: 7031546: test/java/util/ResourceBundle/Bug4168625Test.java fails on solaris10u9 sparc.
Changeset: ea45b4ed1758 Author:naoto Date: 2011-04-06 10:53 -0700 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/ea45b4ed1758 7031546: test/java/util/ResourceBundle/Bug4168625Test.java fails on solaris10u9 sparc. Reviewed-by: okutsu ! test/java/util/ResourceBundle/Bug4168625Test.java
hg: jdk7/tl/jdk: 2 new changesets
Changeset: cd86fbf11e33 Author:alanb Date: 2011-04-06 20:51 +0100 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/cd86fbf11e33 7034155: (ch) NullPointerException in sun.io.ch.IOUtil when OOM is thrown Reviewed-by: forax ! src/share/classes/sun/nio/ch/DatagramChannelImpl.java ! src/share/classes/sun/nio/ch/IOUtil.java Changeset: e279678f9f66 Author:alanb Date: 2011-04-06 20:54 +0100 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/e279678f9f66 Merge
hg: jdk7/tl/jdk: 7034471: Wrap registeredDrivers in DriverManager
Changeset: d5bc10b1aa2c Author:lancea Date: 2011-04-06 17:37 -0400 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/d5bc10b1aa2c 7034471: Wrap registeredDrivers in DriverManager Reviewed-by: alanb, briangoetz ! src/share/classes/java/sql/DriverManager.java
hg: jdk7/tl/jdk: 7032354: no-addresses should not be used on acceptor side
Changeset: 06c7ee973e05 Author:weijun Date: 2011-04-07 08:51 +0800 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/06c7ee973e05 7032354: no-addresses should not be used on acceptor side Reviewed-by: valeriep ! src/share/classes/sun/security/krb5/KrbApReq.java ! test/sun/security/krb5/auto/KDC.java + test/sun/security/krb5/auto/NoAddresses.java
hg: jdk7/tl/langtools: 7033809: Rename "disjunctive" to "union" in javax.lang.model
Changeset: 8cc5b440fdde Author:darcy Date: 2011-04-06 19:30 -0700 URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/8cc5b440fdde 7033809: Rename "disjunctive" to "union" in javax.lang.model Reviewed-by: mcimadamore, jjg - src/share/classes/com/sun/source/tree/DisjunctiveTypeTree.java ! src/share/classes/com/sun/source/tree/Tree.java ! src/share/classes/com/sun/source/tree/TreeVisitor.java + src/share/classes/com/sun/source/tree/UnionTypeTree.java ! src/share/classes/com/sun/source/util/SimpleTreeVisitor.java ! src/share/classes/com/sun/source/util/TreeScanner.java ! src/share/classes/com/sun/tools/javac/code/Flags.java ! src/share/classes/com/sun/tools/javac/comp/Attr.java ! src/share/classes/com/sun/tools/javac/comp/Flow.java ! src/share/classes/com/sun/tools/javac/jvm/Gen.java ! src/share/classes/com/sun/tools/javac/parser/JavacParser.java ! src/share/classes/com/sun/tools/javac/tree/JCTree.java ! src/share/classes/com/sun/tools/javac/tree/Pretty.java ! src/share/classes/com/sun/tools/javac/tree/TreeCopier.java ! src/share/classes/com/sun/tools/javac/tree/TreeInfo.java ! src/share/classes/com/sun/tools/javac/tree/TreeMaker.java ! src/share/classes/com/sun/tools/javac/tree/TreeScanner.java ! src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java - src/share/classes/javax/lang/model/type/DisjunctiveType.java ! src/share/classes/javax/lang/model/type/TypeKind.java ! src/share/classes/javax/lang/model/type/TypeVisitor.java + src/share/classes/javax/lang/model/type/UnionType.java ! src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java ! src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java ! src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java ! src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
hg: jdk7/tl/jdk: 7033954: (launcher) Launchers not built with mapfiles
Changeset: 244b27bb14f8 Author:ksrini Date: 2011-04-06 19:31 -0700 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/244b27bb14f8 7033954: (launcher) Launchers not built with mapfiles Reviewed-by: ohair ! make/com/sun/java/pack/Makefile + make/com/sun/java/pack/mapfile-vers-unpack200 ! make/common/Mapfile-vers.gmk ! make/common/Program.gmk ! make/java/main/java/Makefile ! make/java/main/java/mapfile-amd64 ! make/java/main/java/mapfile-i586 ! make/java/main/java/mapfile-sparc ! make/java/main/java/mapfile-sparcv9