Merge branch '1.3.x'
This commit is contained in:
@@ -73,12 +73,17 @@ public class SendResponseFilter extends ZuulFilter {
|
||||
super();
|
||||
// To support Servlet API 3.1 we need to check if setContentLengthLong exists
|
||||
try {
|
||||
HttpServletResponse.class.getMethod("setContentLengthLong");
|
||||
//TODO: remove in 2.0
|
||||
HttpServletResponse.class.getMethod("setContentLengthLong", long.class);
|
||||
} catch(NoSuchMethodException e) {
|
||||
useServlet31 = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* for testing */ boolean isUseServlet31() {
|
||||
return useServlet31;
|
||||
}
|
||||
|
||||
private ThreadLocal<byte[]> buffers = new ThreadLocal<byte[]>() {
|
||||
@Override
|
||||
protected byte[] initialValue() {
|
||||
|
||||
@@ -70,6 +70,7 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
this.requestCustomizers = requestCustomizers;
|
||||
// To support Servlet API 3.1 we need to check if getContentLengthLong exists
|
||||
try {
|
||||
//TODO: remove in 2.0
|
||||
HttpServletRequest.class.getMethod("getContentLengthLong");
|
||||
} catch(NoSuchMethodException e) {
|
||||
useServlet31 = false;
|
||||
@@ -80,6 +81,10 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
this(new ProxyRequestHelper(), ribbonCommandFactory, null);
|
||||
}
|
||||
|
||||
/* for testing */ boolean isUseServlet31() {
|
||||
return useServlet31;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterType() {
|
||||
return ROUTE_TYPE;
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.netflix.zuul.constants.ZuulConstants;
|
||||
import com.netflix.zuul.context.Debug;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -74,6 +75,11 @@ public class SendResponseFilterTests {
|
||||
runFilter(characterEncoding, content, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useServlet31Works() {
|
||||
assertThat(new SendResponseFilter().isUseServlet31()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void characterEncodingNotOverridden() throws Exception {
|
||||
String characterEncoding = "UTF-16";
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed 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.springframework.cloud.netflix.zuul.filters.route;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.netflix.ribbon.support.RibbonRequestCustomizer;
|
||||
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class RibbonRoutingFilterTests {
|
||||
@Test
|
||||
public void useServlet31Works() {
|
||||
RibbonCommandFactory factory = mock(RibbonCommandFactory.class);
|
||||
RibbonRoutingFilter filter = new RibbonRoutingFilter(new ProxyRequestHelper(), factory,
|
||||
Collections.<RibbonRequestCustomizer>emptyList());
|
||||
assertThat(filter.isUseServlet31()).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user