You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ta...@apache.org on 2020/01/10 08:55:06 UTC

[hadoop] branch trunk updated: HDFS-15110. HttpFS: post requests are not supported for path "/". Contributed by hemanthboyina.

This is an automated email from the ASF dual-hosted git repository.

tasanuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9da294a  HDFS-15110. HttpFS: post requests are not supported for path "/". Contributed by hemanthboyina.
9da294a is described below

commit 9da294a140a919d9ba648637d09340bccfd5edd6
Author: Takanobu Asanuma <ta...@apache.org>
AuthorDate: Fri Jan 10 17:53:19 2020 +0900

    HDFS-15110. HttpFS: post requests are not supported for path "/". Contributed by hemanthboyina.
---
 .../apache/hadoop/fs/http/server/HttpFSServer.java | 24 ++++++++++++++++++++++
 .../hadoop/fs/http/server/TestHttpFSServer.java    | 10 +++++++++
 2 files changed, 34 insertions(+)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
index faa47c5..a9634ad 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
@@ -526,6 +526,30 @@ public class HttpFSServer {
   }
 
   /**
+   * Special binding for '/' as it is not handled by the wildcard binding.
+   * @param is the inputstream for the request payload.
+   * @param uriInfo the of the request.
+   * @param op the HttpFS operation of the request.
+   * @param params the HttpFS parameters of the request.
+   *
+   * @return the request response.
+   *
+   * @throws IOException thrown if an IO error occurred. Thrown exceptions are
+   *           handled by {@link HttpFSExceptionProvider}.
+   * @throws FileSystemAccessException thrown if a FileSystemAccess related
+   *           error occurred. Thrown exceptions are handled by
+   *           {@link HttpFSExceptionProvider}.
+   */
+  @POST
+  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
+  public Response postRoot(InputStream is, @Context UriInfo uriInfo,
+      @QueryParam(OperationParam.NAME) OperationParam op,
+      @Context Parameters params, @Context HttpServletRequest request)
+      throws IOException, FileSystemAccessException {
+    return post(is, uriInfo, "/", op, params, request);
+  }
+
+  /**
    * Binding to handle POST requests.
    *
    * @param is the inputstream for the request payload.
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
index 88364d2..1460f82 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
@@ -1790,5 +1790,15 @@ public class TestHttpFSServer extends HFSTestCase {
         putCmdWithReturn(dir1, "SETECPOLICY", "ecpolicy=" + ecPolicyName);
     // Should return HTTP_OK
     Assert.assertEquals(HttpURLConnection.HTTP_OK, conn3.getResponseCode());
+
+    // test post operation with path as "/"
+    final String dir2 = "/";
+    URL url1 = new URL(TestJettyHelper.getJettyURL(),
+        MessageFormat.format("/webhdfs/v1{0}?user.name={1}&op={2}&{3}", dir2,
+            user, "UNSETECPOLICY", ""));
+    HttpURLConnection conn4 = (HttpURLConnection) url1.openConnection();
+    conn4.setRequestMethod("POST");
+    conn4.connect();
+    Assert.assertEquals(HttpURLConnection.HTTP_OK, conn4.getResponseCode());
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org