mirror of
https://github.com/spring-cloud/spring-cloud-netflix.git
synced 2026-09-17 23:59:04 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb7c68bfb5 | ||
|
|
953e4136f0 | ||
|
|
7d83bf71ec | ||
|
|
53199b4704 | ||
|
|
a568481baa | ||
|
|
b433afb3ba | ||
|
|
296d7020b9 | ||
|
|
acc0e3b735 | ||
|
|
80a0b53612 | ||
|
|
56fe6e616b | ||
|
|
ab6da840b6 | ||
|
|
366efb29d5 | ||
|
|
b5ecf2df16 | ||
|
|
79d3355924 | ||
|
|
d16d9ec858 | ||
|
|
146484a356 | ||
|
|
993f04a6c7 | ||
|
|
e394c1227b | ||
|
|
c1afe1d2a0 |
+2
-16
@@ -128,23 +128,9 @@ the `.mvn` configuration, so if you find you have to do it to make a
|
||||
build succeed, please raise a ticket to get the settings added to
|
||||
source control.
|
||||
|
||||
For hints on how to build the project look in `.travis.yml` if there
|
||||
is one. There should be a "script" and maybe "install" command. Also
|
||||
look at the "services" section to see if any services need to be
|
||||
running locally (e.g. mongo or rabbit). Ignore the git-related bits
|
||||
that you might find in "before_install" since they're related to setting git
|
||||
credentials and you already have those.
|
||||
The projects that require middleware (i.e. Redis) for testing generally
|
||||
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
|
||||
|
||||
The projects that require middleware generally include a
|
||||
`docker-compose.yml`, so consider using
|
||||
https://docs.docker.com/compose/[Docker Compose] to run the middeware servers
|
||||
in Docker containers. See the README in the
|
||||
https://github.com/spring-cloud-samples/scripts[scripts demo
|
||||
repository] for specific instructions about the common cases of mongo,
|
||||
rabbit and redis.
|
||||
|
||||
NOTE: If all else fails, build with the command from `.travis.yml` (usually
|
||||
`./mvnw install`).
|
||||
|
||||
=== Documentation
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-docs</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -264,7 +264,7 @@ Do not use the `EurekaClient` in a `@PostConstruct` method or in a `@Scheduled`
|
||||
It is initialized in a `SmartLifecycle` (with `phase=0`), so the earliest you can rely on it being available is in another `SmartLifecycle` with a higher phase.
|
||||
====
|
||||
|
||||
==== EurekaClient without Jersey
|
||||
==== EurekaClient with Jersey
|
||||
|
||||
By default, EurekaClient uses Jersey for HTTP communication.
|
||||
If you wish to avoid dependencies from Jersey, you can exclude it from your dependencies.
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring Cloud Netflix</name>
|
||||
<description>Spring Cloud Netflix</description>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<version>2.3.6.BUILD-SNAPSHOT</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<scm>
|
||||
@@ -21,9 +21,9 @@
|
||||
</scm>
|
||||
<properties>
|
||||
<bintray.package>netflix</bintray.package>
|
||||
<spring-cloud-commons.version>2.2.9.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
<spring-cloud-config.version>2.2.9.BUILD-SNAPSHOT</spring-cloud-config.version>
|
||||
<spring-cloud-stream.version>Horsham.SR12</spring-cloud-stream.version>
|
||||
<spring-cloud-commons.version>2.2.10.BUILD-SNAPSHOT</spring-cloud-commons.version>
|
||||
<spring-cloud-config.version>2.2.8.RELEASE</spring-cloud-config.version>
|
||||
<spring-cloud-stream.version>Horsham.SR13</spring-cloud-stream.version>
|
||||
<!-- Has to be a stable version (not one that depends on this version of netflix): -->
|
||||
<donotreplacespring-cloud-contract.version>2.2.4.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-concurrency-limits</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-core</artifactId>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>2.3.5.BUILD-SNAPSHOT</version>
|
||||
<version>2.3.6.BUILD-SNAPSHOT</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-dependencies</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>spring-cloud-netflix-dependencies</name>
|
||||
<description>Spring Cloud Netflix Dependencies</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-eureka-client-tls-tests</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
|
||||
|
||||
+1
-2
@@ -54,7 +54,7 @@ import static com.netflix.appinfo.InstanceInfo.DEFAULT_SECURE_PORT;
|
||||
import static org.springframework.util.Assert.isTrue;
|
||||
|
||||
/**
|
||||
* Mocked Eureka Server
|
||||
* Mocked Eureka Server.
|
||||
*
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@@ -95,7 +95,6 @@ public class EurekaServerMockApplication {
|
||||
|
||||
/**
|
||||
* Simulates Eureka Server own's serialization.
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-eureka-server</artifactId>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<version>2.3.6.BUILD-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-hystrix-contract</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>spring-cloud-netflix-hystrix-contract</name>
|
||||
<description>Spring Cloud Netflix Hystrix Contract</description>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
||||
+3
-4
@@ -18,7 +18,6 @@ package org.springframework.cloud.netflix.hystrix.dashboard;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
@@ -35,11 +34,11 @@ public class HystrixDashboardController {
|
||||
return "hystrix/index";
|
||||
}
|
||||
|
||||
@RequestMapping("/hystrix/{path}")
|
||||
public String monitor(@PathVariable String path, Model model, WebRequest request) {
|
||||
@RequestMapping("/hystrix/monitor")
|
||||
public String monitor(Model model, WebRequest request) {
|
||||
model.addAttribute("basePath", extractPath(request));
|
||||
model.addAttribute("contextPath", request.getContextPath());
|
||||
return "hystrix/" + path;
|
||||
return "hystrix/monitor";
|
||||
}
|
||||
|
||||
private String extractPath(WebRequest request) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-hystrix-stream</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-hystrix</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+3
-1
@@ -31,6 +31,7 @@ import static org.springframework.cloud.netflix.ribbon.support.RibbonRequestCust
|
||||
|
||||
/**
|
||||
* @author Christian Lohmann
|
||||
* @author Chintan Radia
|
||||
*/
|
||||
public class RibbonApacheHttpRequest extends ContextAwareRequest implements Cloneable {
|
||||
|
||||
@@ -62,7 +63,8 @@ public class RibbonApacheHttpRequest extends ContextAwareRequest implements Clon
|
||||
// if the entity contentLength isn't set, transfer-encoding will be set
|
||||
// to chunked in org.apache.http.protocol.RequestContent. See gh-1042
|
||||
Long contentLength = this.context.getContentLength();
|
||||
if ("GET".equals(this.context.getMethod())
|
||||
if (("GET".equals(this.context.getMethod())
|
||||
|| "DELETE".equals(this.context.getMethod()))
|
||||
&& (contentLength == null || contentLength < 0)) {
|
||||
entity.setContentLength(0);
|
||||
}
|
||||
|
||||
+8
@@ -39,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Chintan Radia
|
||||
*/
|
||||
public class RibbonApacheHttpRequestTests {
|
||||
|
||||
@@ -79,6 +80,13 @@ public class RibbonApacheHttpRequestTests {
|
||||
"GET");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyEntityDelete() throws Exception {
|
||||
String entityValue = "";
|
||||
testEntity(entityValue, new ByteArrayInputStream(entityValue.getBytes()), false,
|
||||
"DELETE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonEmptyEntityPost() throws Exception {
|
||||
String entityValue = "abcd";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-sidecar</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-turbine-stream</artifactId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<artifactId>spring-cloud-netflix-turbine</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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
|
||||
*
|
||||
* https://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;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.boot.actuate.trace.http.TraceableRequest;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
/**
|
||||
* @author Alexander Kogut
|
||||
*/
|
||||
public class ServletTraceableRequest implements TraceableRequest {
|
||||
|
||||
private HttpServletRequest request;
|
||||
|
||||
ServletTraceableRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
String queryString = request.getQueryString();
|
||||
if (!StringUtils.hasText(queryString)) {
|
||||
return URI.create(request.getRequestURL().toString());
|
||||
}
|
||||
try {
|
||||
StringBuffer urlBuffer = appendQueryString(queryString);
|
||||
return new URI(urlBuffer.toString());
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
String encoded = UriUtils.encode(queryString, StandardCharsets.UTF_8);
|
||||
StringBuffer urlBuffer = appendQueryString(encoded);
|
||||
return URI.create(urlBuffer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuffer appendQueryString(String queryString) {
|
||||
StringBuffer urlBuffer = request.getRequestURL();
|
||||
urlBuffer.append("?");
|
||||
urlBuffer.append(queryString);
|
||||
return urlBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
return extractHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddress() {
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
private Map<String, List<String>> extractHeaders() {
|
||||
Map<String, List<String>> headers = new LinkedHashMap<>();
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
while (names.hasMoreElements()) {
|
||||
String name = names.nextElement();
|
||||
headers.put(name, toList(request.getHeaders(name)));
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
private List<String> toList(Enumeration<String> enumeration) {
|
||||
List<String> list = new ArrayList<>();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
list.add(enumeration.nextElement());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
-58
@@ -19,11 +19,8 @@ package org.springframework.cloud.netflix.zuul.filters;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,9 +34,7 @@ import org.springframework.boot.actuate.trace.http.HttpExchangeTracer;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTrace;
|
||||
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
|
||||
import org.springframework.boot.actuate.trace.http.Include;
|
||||
import org.springframework.boot.actuate.trace.http.TraceableRequest;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -134,57 +129,4 @@ public class TraceProxyRequestHelper extends ProxyRequestHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private class ServletTraceableRequest implements TraceableRequest {
|
||||
|
||||
private HttpServletRequest request;
|
||||
|
||||
ServletTraceableRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
StringBuffer urlBuffer = request.getRequestURL();
|
||||
if (StringUtils.hasText(request.getQueryString())) {
|
||||
urlBuffer.append("?");
|
||||
urlBuffer.append(request.getQueryString());
|
||||
}
|
||||
return URI.create(urlBuffer.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
return extractHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddress() {
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
private Map<String, List<String>> extractHeaders() {
|
||||
Map<String, List<String>> headers = new LinkedHashMap<>();
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
while (names.hasMoreElements()) {
|
||||
String name = names.nextElement();
|
||||
headers.put(name, toList(request.getHeaders(name)));
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
private List<String> toList(Enumeration<String> enumeration) {
|
||||
List<String> list = new ArrayList<>();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
list.add(enumeration.nextElement());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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
|
||||
*
|
||||
* https://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;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ServletTraceableRequest}.
|
||||
*/
|
||||
class ServletTraceableRequestTests {
|
||||
|
||||
private MockHttpServletRequest request;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
request = new MockHttpServletRequest("GET", "/script");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUriWithoutQueryStringShouldReturnUri() {
|
||||
validate("http://localhost/script");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUriShouldReturnUriWithQueryString() {
|
||||
request.setQueryString("a=b");
|
||||
validate("http://localhost/script?a=b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUriWithSpecialCharactersInQueryStringShouldEncode() {
|
||||
request.setQueryString("a=${b}");
|
||||
validate("http://localhost/script?a%3D%24%7Bb%7D");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUriWithSpecialCharactersEncodedShouldNotDoubleEncode() {
|
||||
request.setQueryString("a%3D%24%7Bb%7D");
|
||||
validate("http://localhost/script?a%3D%24%7Bb%7D");
|
||||
}
|
||||
|
||||
private void validate(String expectedUri) {
|
||||
ServletTraceableRequest trace = new ServletTraceableRequest(request);
|
||||
assertThat(trace.getUri().toString()).isEqualTo(expectedUri);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-archaius</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Archaius</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Eureka Client</name>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Eureka Server</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Hystrix Dashboard</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Hystrix</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Ribbon</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-turbine-stream</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Turbine Stream</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Turbine</name>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix</artifactId>
|
||||
<version>2.2.9.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.11.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
||||
<name>Spring Cloud Starter Netflix Zuul</name>
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
<suppress files=".*RibbonClientHttpRequestFactoryTests\.java" checks="JavadocVariable"/>
|
||||
<suppress files=".*TestAutoConfiguration\.java" checks="HideUtilityClassConstructor"/>
|
||||
<suppress files=".*TestAutoConfiguration\.java" checks="JavadocStyle"/>
|
||||
<suppress files=".*TestAutoConfiguration\.java" checks="JavadocStyle"/>
|
||||
<suppress files=".*EurekaConfigServerBootstrapConfigurationTests\.java" checks="JavadocVariable"/>
|
||||
<suppress files=".*HystrixStreamAggregatorTests\.java" checks="JavadocVariable"/>
|
||||
</suppressions>
|
||||
Reference in New Issue
Block a user