jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1374945 - in /jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server: MicroKernelServlet.java Request.java
Date Mon, 20 Aug 2012 08:44:56 GMT
Author: dpfister
Date: Mon Aug 20 08:44:55 2012
New Revision: 1374945

URL: http://svn.apache.org/viewvc?rev=1374945&view=rev
Log:
Treat HTTP request headers case-insensitive

Modified:
    jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
    jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/Request.java

Modified: jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java?rev=1374945&r1=1374944&r2=1374945&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/MicroKernelServlet.java
Mon Aug 20 08:44:55 2012
@@ -112,7 +112,7 @@ class MicroKernelServlet {
 
             response.setContentType("application/json");
             String json = mk.getRevisionHistory(since, maxEntries, path);
-            if (request.getHeaders().containsKey("User-Agent")) {
+            if (request.getUserAgent() != null) {
                 json = JsopBuilder.prettyPrint(json);
             }
             response.write(json);
@@ -157,7 +157,7 @@ class MicroKernelServlet {
 
             response.setContentType("application/json");
             String json = mk.getJournal(fromRevisionId, toRevisionId, path);
-            if (request.getHeaders().containsKey("User-Agent")) {
+            if (request.getUserAgent() != null) {
                 json = JsopBuilder.prettyPrint(json);
             }
             response.write(json);
@@ -179,7 +179,7 @@ class MicroKernelServlet {
 
             response.setContentType("application/json");
             String json = mk.diff(fromRevisionId, toRevisionId, path, depth);
-            if (request.getHeaders().containsKey("User-Agent")) {
+            if (request.getUserAgent() != null) {
                 json = JsopBuilder.prettyPrint(json);
             }
             response.write(json);
@@ -239,7 +239,7 @@ class MicroKernelServlet {
             if (json == null) {
                 json = "null";
             }
-            if (request.getHeaders().containsKey("User-Agent")) {
+            if (request.getUserAgent() != null) {
                 json = JsopBuilder.prettyPrint(json);
             }
             response.write(json);

Modified: jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/Request.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/Request.java?rev=1374945&r1=1374944&r2=1374945&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/Request.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-remote/src/main/java/org/apache/jackrabbit/mk/server/Request.java
Mon Aug 20 08:44:55 2012
@@ -94,7 +94,7 @@ class Request implements Closeable {
             }
             parts = headerLine.split(":");
             if (parts.length == 2) {
-                headers.put(parts[0].trim(), parts[1].trim());
+                headers.put(parts[0].trim().toLowerCase(), parts[1].trim());
             }
         }
 
@@ -139,7 +139,7 @@ class Request implements Closeable {
     }
 
     private String getContentType() {
-        String ct = headers.get("Content-Type");
+        String ct = headers.get("content-type");
         if (ct != null) {
             int sep = ct.indexOf(';');
             if (sep != -1) {
@@ -150,7 +150,7 @@ class Request implements Closeable {
     }
 
     private int getContentLength() {
-        String s = headers.get("Content-Length");
+        String s = headers.get("content-length");
         if (s != null) {
             try {
                 return Integer.parseInt(s);
@@ -160,11 +160,12 @@ class Request implements Closeable {
         }
         return -1;
     }
-
-    public Map<String, String> getHeaders() {
-        return headers;
+    
+    public String getUserAgent() {
+        return headers.get("user-agent");
     }
 
+
     public String getQueryString() {
         return queryString;
     }
@@ -251,7 +252,7 @@ class Request implements Closeable {
 
     public InputStream getInputStream() {
         if (reqIn == null) {
-            String encoding = headers.get("Transfer-Encoding");
+            String encoding = headers.get("transfer-encoding");
             if ("chunked".equalsIgnoreCase(encoding)) {
                 chunkedIn.recycle(in);
                 reqIn = chunkedIn;



Mime
View raw message