Procházet zdrojové kódy

commit eb57e52aebba2ff76a93f8c2059306b1f3106c8a
Author: Tsz Wo Wo Sze <tsz@ucdev29.inktomisearch.com>
Date: Wed Jul 14 00:14:38 2010 +0000

HDFS-1109 from https://issues.apache.org/jira/secure/attachment/12449294/HDFS-1109.2_y0.20.1xx.patch

+++ b/YAHOO-CHANGES.txt
+ HDFS-1109. HFTP supports filenames that contains the character "+".
+ (Dmytro Molkov via dhruba, backported by szetszwo)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077539 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley před 14 roky
rodič
revize
4100e11cc8

+ 2 - 2
src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyFileDataServlet.java

@@ -50,8 +50,8 @@ public class ProxyFileDataServlet extends FileDataServlet {
     }
     
     return new URI(request.getScheme(), null, request.getServerName(), request
-        .getServerPort(), "/streamFile", "filename=" + i.getFullName(parent) 
-        + "&ugi=" + ugi.getShortUserName() + dtParam, null);
+        .getServerPort(), "/streamFile" + i.getFullName(parent),
+         "&ugi=" + ugi.getShortUserName() + dtParam, null);
   }
 
   /** {@inheritDoc} */

+ 2 - 2
src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyFileForward.java

@@ -28,12 +28,12 @@ public class ProxyFileForward extends ProxyForwardServlet {
   @Override
   protected String buildForwardPath(HttpServletRequest request, String pathInfo) {
     String path = "/streamFile";
-    path += "?filename=" + request.getPathInfo();
+    path += request.getPathInfo();
     String userID = (String) request.
         getAttribute("org.apache.hadoop.hdfsproxy.authorized.userID");
     UserGroupInformation ugi = ProxyUtil.getProxyUGIFor(userID);
     if (ugi != null) {
-      path += "&ugi=" + ugi.getShortUserName();
+      path += "?ugi=" + ugi.getShortUserName();
     }
     return path;
   }

+ 2 - 2
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FileDataServlet.java

@@ -62,8 +62,8 @@ public class FileDataServlet extends DfsServlet {
         "https".equals(scheme)
           ? (Integer)getServletContext().getAttribute("datanode.https.port")
           : host.getInfoPort(),
-        "/streamFile", "filename=" + i.getFullName(parent) + 
-        "&ugi=" + ugi.getShortUserName() + dtParam, null);
+        "/streamFile" + i.getFullName(parent), 
+        "ugi=" + ugi.getShortUserName() + dtParam, null);
   }
 
   private static JspHelper jspHelper = null;

+ 13 - 8
src/hdfs/org/apache/hadoop/hdfs/server/namenode/StreamFile.java

@@ -17,16 +17,20 @@
  */
 package org.apache.hadoop.hdfs.server.namenode;
 
-import javax.servlet.*;
-import javax.servlet.http.*;
-import java.io.*;
-import java.net.*;
-import java.security.PrivilegedExceptionAction;
-import org.apache.hadoop.fs.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.InetSocketAddress;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSInputStream;
 import org.apache.hadoop.hdfs.DFSClient;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
 import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.conf.*;
 
 public class StreamFile extends DfsServlet {
   static InetSocketAddress nameNodeAddr;
@@ -41,7 +45,8 @@ public class StreamFile extends DfsServlet {
     throws ServletException, IOException {
     Configuration conf = 
       (Configuration) getServletContext().getAttribute(JspHelper.CURRENT_CONF);
-    String filename = request.getParameter("filename");
+    final String filename = request.getPathInfo() != null ?
+        request.getPathInfo() : "/";
     if (filename == null || filename.length() == 0) {
       response.setContentType("text/plain");
       PrintWriter out = response.getWriter();

+ 3 - 2
src/webapps/datanode/browseBlock.jsp

@@ -88,9 +88,10 @@
     //Add the various links for looking at the file contents
     //URL for downloading the full file
     String downloadUrl = "http://" + req.getServerName() + ":" +
-                         + req.getServerPort() + "/streamFile?" + "filename="
+                         + req.getServerPort() + "/streamFile"
                          + URLEncoder.encode(filename, "UTF-8")
-                         + JspHelper.SET_DELEGATION + tokenString;
+                         + "?" + JspHelper.DELEGATION_PARAMETER_NAME
+                         + "=" + tokenString;
     out.print("<a name=\"viewOptions\"></a>");
     out.print("<a href=\"" + downloadUrl + "\">Download this file</a><br>");