Merge
authorasaha
Fri, 23 Oct 2009 12:58:10 -0700
changeset 4217 c572c24479d1
parent 4216 8686c4539f6d (current diff)
parent 4164 7ba55fbef5be (diff)
child 4218 fcff3c891ba3
Merge
jdk/src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java
--- a/jdk/make/sun/net/FILES_java.gmk	Thu Oct 22 16:28:01 2009 -0700
+++ b/jdk/make/sun/net/FILES_java.gmk	Fri Oct 23 12:58:10 2009 -0700
@@ -85,7 +85,6 @@
 	sun/net/www/http/Hurryable.java \
 	sun/net/www/protocol/http/Handler.java \
 	sun/net/www/protocol/http/HttpURLConnection.java \
-	sun/net/www/protocol/http/HttpLogFormatter.java \
 	sun/net/www/protocol/http/HttpAuthenticator.java \
 	sun/net/www/protocol/http/AuthenticationHeader.java \
 	sun/net/www/protocol/http/AuthenticationInfo.java \
@@ -101,6 +100,7 @@
 	sun/net/www/protocol/http/ntlm/NTLMAuthentication.java \
 	sun/net/www/protocol/http/spnego/NegotiatorImpl.java \
 	sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java \
+	sun/net/www/protocol/http/logging/HttpLogFormatter.java \
 	sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java \
 	sun/net/www/protocol/https/HttpsClient.java \
 	sun/net/www/protocol/https/DefaultHostnameVerifier.java \
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java	Thu Oct 22 16:28:01 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc.  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.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.net.www.protocol.http;
-
-import java.util.logging.LogRecord;
-import java.util.regex.*;
-
-/**
- * A Formatter to make the HTTP logs a bit more palatable to the developer
- * looking at them. The idea is to present the HTTP events in such a way that
- * commands and headers are easily spotted (i.e. on separate lines).
- * @author jccollet
- */
-public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
-    // Pattern for MessageHeader data. Mostly pairs within curly brackets
-    private static volatile Pattern pattern = null;
-    // Pattern for Cookies
-    private static volatile Pattern cpattern = null;
-
-    public HttpLogFormatter() {
-        if (pattern == null) {
-            pattern = Pattern.compile("\\{[^\\}]*\\}");
-            cpattern = Pattern.compile("[^,\\] ]{2,}");
-        }
-    }
-
-    @Override
-    public String format(LogRecord record) {
-        String sourceClassName = record.getSourceClassName();
-        if (sourceClassName == null ||
-            !(sourceClassName.startsWith("sun.net.www.protocol.http") ||
-              sourceClassName.startsWith("sun.net.www.http"))) {
-            return super.format(record);
-        }
-        String src = record.getMessage();
-        StringBuilder buf = new StringBuilder("HTTP: ");
-        if (src.startsWith("sun.net.www.MessageHeader@")) {
-            // MessageHeader logs are composed of pairs within curly brackets
-            // Let's extract them to make it more readable. That way we get one
-            // header pair (name, value) per line. A lot easier to read.
-            Matcher match = pattern.matcher(src);
-            while (match.find()) {
-                int i = match.start();
-                int j = match.end();
-                String s = src.substring(i + 1, j - 1);
-                if (s.startsWith("null: ")) {
-                    s = s.substring(6);
-                }
-                if (s.endsWith(": null")) {
-                    s = s.substring(0, s.length() - 6);
-                }
-                buf.append("\t").append(s).append("\n");
-            }
-        } else if (src.startsWith("Cookies retrieved: {")) {
-            // This comes from the Cookie handler, let's clean up the format a bit
-            String s = src.substring(20);
-            buf.append("Cookies from handler:\n");
-            while (s.length() >= 7) {
-                if (s.startsWith("Cookie=[")) {
-                    String s2 = s.substring(8);
-                    int c = s2.indexOf("Cookie2=[");
-                    if (c > 0) {
-                        s2 = s2.substring(0, c-1);
-                        s = s2.substring(c);
-                    } else {
-                        s = "";
-                    }
-                    if (s2.length() < 4) {
-                        continue;
-                    }
-                    Matcher m = cpattern.matcher(s2);
-                    while (m.find()) {
-                        int i = m.start();
-                        int j = m.end();
-                        if (i >= 0) {
-                            String cookie = s2.substring(i + 1, j > 0 ? j - 1 : s2.length() - 1);
-                            buf.append("\t").append(cookie).append("\n");
-                        }
-                    }
-                }
-                if (s.startsWith("Cookie2=[")) {
-                    String s2 = s.substring(9);
-                    int c = s2.indexOf("Cookie=[");
-                    if (c > 0) {
-                        s2 = s2.substring(0, c-1);
-                        s = s2.substring(c);
-                    } else {
-                        s = "";
-                    }
-                    Matcher m = cpattern.matcher(s2);
-                    while (m.find()) {
-                        int i = m.start();
-                        int j = m.end();
-                        if (i >= 0) {
-                            String cookie = s2.substring(i+1, j > 0 ? j-1 : s2.length() - 1);
-                            buf.append("\t").append(cookie).append("\n");
-                        }
-                    }
-                }
-            }
-        } else {
-            // Anything else we let as is.
-            buf.append(src).append("\n");
-        }
-        return buf.toString();
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/logging/HttpLogFormatter.java	Fri Oct 23 12:58:10 2009 -0700
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.net.www.protocol.http.logging;
+
+import java.util.logging.LogRecord;
+import java.util.regex.*;
+
+/**
+ * A Formatter to make the HTTP logs a bit more palatable to the developer
+ * looking at them. The idea is to present the HTTP events in such a way that
+ * commands and headers are easily spotted (i.e. on separate lines).
+ * @author jccollet
+ */
+public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
+    // Pattern for MessageHeader data. Mostly pairs within curly brackets
+    private static volatile Pattern pattern = null;
+    // Pattern for Cookies
+    private static volatile Pattern cpattern = null;
+
+    public HttpLogFormatter() {
+        if (pattern == null) {
+            pattern = Pattern.compile("\\{[^\\}]*\\}");
+            cpattern = Pattern.compile("[^,\\] ]{2,}");
+        }
+    }
+
+    @Override
+    public String format(LogRecord record) {
+        String sourceClassName = record.getSourceClassName();
+        if (sourceClassName == null ||
+            !(sourceClassName.startsWith("sun.net.www.protocol.http") ||
+              sourceClassName.startsWith("sun.net.www.http"))) {
+            return super.format(record);
+        }
+        String src = record.getMessage();
+        StringBuilder buf = new StringBuilder("HTTP: ");
+        if (src.startsWith("sun.net.www.MessageHeader@")) {
+            // MessageHeader logs are composed of pairs within curly brackets
+            // Let's extract them to make it more readable. That way we get one
+            // header pair (name, value) per line. A lot easier to read.
+            Matcher match = pattern.matcher(src);
+            while (match.find()) {
+                int i = match.start();
+                int j = match.end();
+                String s = src.substring(i + 1, j - 1);
+                if (s.startsWith("null: ")) {
+                    s = s.substring(6);
+                }
+                if (s.endsWith(": null")) {
+                    s = s.substring(0, s.length() - 6);
+                }
+                buf.append("\t").append(s).append("\n");
+            }
+        } else if (src.startsWith("Cookies retrieved: {")) {
+            // This comes from the Cookie handler, let's clean up the format a bit
+            String s = src.substring(20);
+            buf.append("Cookies from handler:\n");
+            while (s.length() >= 7) {
+                if (s.startsWith("Cookie=[")) {
+                    String s2 = s.substring(8);
+                    int c = s2.indexOf("Cookie2=[");
+                    if (c > 0) {
+                        s2 = s2.substring(0, c-1);
+                        s = s2.substring(c);
+                    } else {
+                        s = "";
+                    }
+                    if (s2.length() < 4) {
+                        continue;
+                    }
+                    Matcher m = cpattern.matcher(s2);
+                    while (m.find()) {
+                        int i = m.start();
+                        int j = m.end();
+                        if (i >= 0) {
+                            String cookie = s2.substring(i + 1, j > 0 ? j - 1 : s2.length() - 1);
+                            buf.append("\t").append(cookie).append("\n");
+                        }
+                    }
+                }
+                if (s.startsWith("Cookie2=[")) {
+                    String s2 = s.substring(9);
+                    int c = s2.indexOf("Cookie=[");
+                    if (c > 0) {
+                        s2 = s2.substring(0, c-1);
+                        s = s2.substring(c);
+                    } else {
+                        s = "";
+                    }
+                    Matcher m = cpattern.matcher(s2);
+                    while (m.find()) {
+                        int i = m.start();
+                        int j = m.end();
+                        if (i >= 0) {
+                            String cookie = s2.substring(i+1, j > 0 ? j-1 : s2.length() - 1);
+                            buf.append("\t").append(cookie).append("\n");
+                        }
+                    }
+                }
+            }
+        } else {
+            // Anything else we let as is.
+            buf.append(src).append("\n");
+        }
+        return buf.toString();
+    }
+
+}