HDFS-2441. Remove the Content-Type set by HttpServer.QuotingInputFilter in webhdfs responses.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1183081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2011-10-13 20:41:00 +00:00
parent e9544ef3d2
commit 7d1a5078b7
3 changed files with 27 additions and 0 deletions

View File

@ -113,6 +113,9 @@ Trunk (unreleased changes)
HDFS-2349. Corruption detected during block transfers between DNs HDFS-2349. Corruption detected during block transfers between DNs
should log a WARN instead of INFO. (harsh) should log a WARN instead of INFO. (harsh)
HDFS-2441. Remove the Content-Type set by HttpServer.QuotingInputFilter in
webhdfs responses. (szetszwo)
Release 0.23.0 - Unreleased Release 0.23.0 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -27,6 +27,7 @@
import java.util.EnumSet; import java.util.EnumSet;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue; import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -78,6 +79,7 @@ public class DatanodeWebHdfsMethods {
public static final Log LOG = LogFactory.getLog(DatanodeWebHdfsMethods.class); public static final Log LOG = LogFactory.getLog(DatanodeWebHdfsMethods.class);
private @Context ServletContext context; private @Context ServletContext context;
private @Context HttpServletResponse response;
/** Handle HTTP PUT request. */ /** Handle HTTP PUT request. */
@PUT @PUT
@ -108,6 +110,9 @@ public Response put(
replication, blockSize)); replication, blockSize));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException, URISyntaxException { public Response run() throws IOException, URISyntaxException {
@ -164,6 +169,9 @@ public Response post(
+ Param.toSortedString(", ", bufferSize)); + Param.toSortedString(", ", bufferSize));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException { public Response run() throws IOException {
@ -215,6 +223,9 @@ public Response get(
+ Param.toSortedString(", ", offset, length, bufferSize)); + Param.toSortedString(", ", offset, length, bufferSize));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException { public Response run() throws IOException {

View File

@ -28,6 +28,7 @@
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue; import javax.ws.rs.DefaultValue;
@ -108,6 +109,7 @@ public static String getRemoteAddress() {
private @Context ServletContext context; private @Context ServletContext context;
private @Context HttpServletRequest request; private @Context HttpServletRequest request;
private @Context HttpServletResponse response;
private static DatanodeInfo chooseDatanode(final NameNode namenode, private static DatanodeInfo chooseDatanode(final NameNode namenode,
final String path, final HttpOpParam.Op op, final long openOffset final String path, final HttpOpParam.Op op, final long openOffset
@ -226,6 +228,9 @@ public Response put(
modificationTime, accessTime, renameOptions)); modificationTime, accessTime, renameOptions));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException, URISyntaxException { public Response run() throws IOException, URISyntaxException {
@ -317,6 +322,9 @@ public Response post(
+ Param.toSortedString(", ", bufferSize)); + Param.toSortedString(", ", bufferSize));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException, URISyntaxException { public Response run() throws IOException, URISyntaxException {
@ -394,6 +402,8 @@ public Response get(
+ Param.toSortedString(", ", offset, length, renewer, bufferSize)); + Param.toSortedString(", ", offset, length, renewer, bufferSize));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
@ -522,6 +532,9 @@ public Response delete(
+ Param.toSortedString(", ", recursive)); + Param.toSortedString(", ", recursive));
} }
//clear content type
response.setContentType(null);
return ugi.doAs(new PrivilegedExceptionAction<Response>() { return ugi.doAs(new PrivilegedExceptionAction<Response>() {
@Override @Override
public Response run() throws IOException { public Response run() throws IOException {