HDFS-15110. HttpFS: post requests are not supported for path "/". Contributed by hemanthboyina.
This commit is contained in:
parent
20a90c0b5b
commit
9da294a140
|
@ -525,6 +525,30 @@ public class HttpFSServer {
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue