HBASE-3275 [rest] No gzip/deflat content encoding support; fix error handling in GzipFilter
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1082792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d051203938
commit
cb85bf2e0a
|
@ -1,6 +1,27 @@
|
|||
/*
|
||||
* Copyright 2010 The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase.rest.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
@ -50,8 +71,12 @@ public class GzipFilter implements Filter {
|
|||
response = new GZIPResponseWrapper(response);
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
if ((response instanceof GZIPResponseWrapper)) {
|
||||
((GZIPResponseStream)response.getOutputStream()).finish();
|
||||
if (response instanceof GZIPResponseWrapper) {
|
||||
OutputStream os = response.getOutputStream();
|
||||
if (os instanceof GZIPResponseStream) {
|
||||
((GZIPResponseStream)os).finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -120,13 +120,16 @@ public class TestGzipFilter {
|
|||
|
||||
@Test
|
||||
public void testErrorNotGzipped() throws Exception {
|
||||
String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_2;
|
||||
Header[] headers = new Header[2];
|
||||
headers[0] = new Header("Accept", Constants.MIMETYPE_BINARY);
|
||||
headers[1] = new Header("Accept-Encoding", "gzip");
|
||||
Response response = client.get(path, headers);
|
||||
Response response = client.get("/" + TABLE + "/" + ROW_1 + "/" + COLUMN_2, headers);
|
||||
assertEquals(response.getCode(), 404);
|
||||
String contentEncoding = response.getHeader("Content-Encoding");
|
||||
assertTrue(contentEncoding == null || !contentEncoding.contains("gzip"));
|
||||
response = client.get("/" + TABLE, headers);
|
||||
assertEquals(response.getCode(), 405);
|
||||
contentEncoding = response.getHeader("Content-Encoding");
|
||||
assertTrue(contentEncoding == null || !contentEncoding.contains("gzip"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue