Merge branch 'develop' of github.com:wehotel/fizz-gateway-community into develop
This commit is contained in:
@@ -9,11 +9,10 @@
|
|||||||
<version>2.2.13.RELEASE</version>
|
<version>2.2.13.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.fizzgate</groupId>
|
<groupId>com.fizzgate</groupId>
|
||||||
<artifactId>fizz-bootstrap</artifactId>
|
<artifactId>fizz-bootstrap</artifactId>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fizz-gateway-community</artifactId>
|
<artifactId>fizz-gateway-community</artifactId>
|
||||||
<groupId>com.fizzgate</groupId>
|
<groupId>com.fizzgate</groupId>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>fizz-common</artifactId>
|
<artifactId>fizz-common</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -17,16 +17,28 @@
|
|||||||
|
|
||||||
package we.spring.http.server.reactive.ext;
|
package we.spring.http.server.reactive.ext;
|
||||||
|
|
||||||
|
import io.netty.handler.codec.http.cookie.Cookie;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.NettyDataBuffer;
|
import org.springframework.core.io.buffer.NettyDataBuffer;
|
||||||
import org.springframework.core.io.buffer.PooledDataBuffer;
|
import org.springframework.core.io.buffer.PooledDataBuffer;
|
||||||
|
import org.springframework.http.HttpCookie;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.server.reactive.AbstractServerHttpRequest;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.netty.http.server.HttpServerRequest;
|
||||||
import we.util.NettyDataBufferUtils;
|
import we.util.NettyDataBufferUtils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongqiaowei
|
* @author hongqiaowei
|
||||||
@@ -34,20 +46,87 @@ import java.nio.charset.StandardCharsets;
|
|||||||
|
|
||||||
public class FizzServerHttpRequestDecorator extends ServerHttpRequestDecorator {
|
public class FizzServerHttpRequestDecorator extends ServerHttpRequestDecorator {
|
||||||
|
|
||||||
|
private static final Pattern QUERY_PATTERN = Pattern.compile("([^&=]+)(=?)([^&]+)?");
|
||||||
|
|
||||||
|
private AbstractServerHttpRequest delegate;
|
||||||
|
|
||||||
|
private HttpServerRequest nativeRequest;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private MultiValueMap<String, String> queryParams;
|
||||||
|
|
||||||
private HttpHeaders headers;
|
private HttpHeaders headers;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private MultiValueMap<String, HttpCookie> cookies;
|
||||||
|
|
||||||
private Flux<DataBuffer> body = Flux.empty();
|
private Flux<DataBuffer> body = Flux.empty();
|
||||||
|
|
||||||
public FizzServerHttpRequestDecorator(ServerHttpRequest delegate) {
|
public FizzServerHttpRequestDecorator(ServerHttpRequest delegate) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
headers = HttpHeaders.writableHttpHeaders(delegate.getHeaders());
|
this.delegate = (AbstractServerHttpRequest) delegate;
|
||||||
|
nativeRequest = this.delegate.getNativeRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultiValueMap<String, String> getQueryParams() {
|
||||||
|
if (queryParams == null) {
|
||||||
|
queryParams = initQueryParams();
|
||||||
|
}
|
||||||
|
return queryParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiValueMap<String, String> initQueryParams() {
|
||||||
|
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||||
|
String query = getURI().getRawQuery();
|
||||||
|
if (query != null) {
|
||||||
|
Matcher matcher = QUERY_PATTERN.matcher(query);
|
||||||
|
while (matcher.find()) {
|
||||||
|
String name = decodeQueryParam(matcher.group(1));
|
||||||
|
String eq = matcher.group(2);
|
||||||
|
String value = matcher.group(3);
|
||||||
|
value = (value != null ? decodeQueryParam(value) : (StringUtils.hasLength(eq) ? "" : null));
|
||||||
|
queryParams.add(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return queryParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String decodeQueryParam(String value) {
|
||||||
|
try {
|
||||||
|
return URLDecoder.decode(value, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
return URLDecoder.decode(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpHeaders getHeaders() {
|
public HttpHeaders getHeaders() {
|
||||||
|
if (headers == null) {
|
||||||
|
headers = HttpHeaders.writableHttpHeaders(delegate.getHeaders());
|
||||||
|
}
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultiValueMap<String, HttpCookie> getCookies() {
|
||||||
|
if (cookies == null) {
|
||||||
|
cookies = initCookies();
|
||||||
|
}
|
||||||
|
return cookies;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiValueMap<String, HttpCookie> initCookies() {
|
||||||
|
MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>();
|
||||||
|
for (CharSequence name : nativeRequest.cookies().keySet()) {
|
||||||
|
for (Cookie cookie : nativeRequest.cookies().get(name)) {
|
||||||
|
HttpCookie httpCookie = new HttpCookie(name.toString(), cookie.value());
|
||||||
|
cookies.add(name.toString(), httpCookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cookies;
|
||||||
|
}
|
||||||
|
|
||||||
public void setEmptyBody() {
|
public void setEmptyBody() {
|
||||||
this.body = Flux.empty();
|
this.body = Flux.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fizz-gateway-community</artifactId>
|
<artifactId>fizz-gateway-community</artifactId>
|
||||||
<groupId>com.fizzgate</groupId>
|
<groupId>com.fizzgate</groupId>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>fizz-core</artifactId>
|
<artifactId>fizz-core</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fizz-gateway-community</artifactId>
|
<artifactId>fizz-gateway-community</artifactId>
|
||||||
<groupId>com.fizzgate</groupId>
|
<groupId>com.fizzgate</groupId>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>fizz-plugin</artifactId>
|
<artifactId>fizz-plugin</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>fizz-gateway-community</artifactId>
|
<artifactId>fizz-gateway-community</artifactId>
|
||||||
<groupId>com.fizzgate</groupId>
|
<groupId>com.fizzgate</groupId>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>fizz-spring-boot-starter</artifactId>
|
<artifactId>fizz-spring-boot-starter</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@@ -34,9 +34,7 @@
|
|||||||
<artifactId>fizz-gateway-community</artifactId>
|
<artifactId>fizz-gateway-community</artifactId>
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>fizz gateway community</description>
|
<description>fizz gateway community</description>
|
||||||
|
<version>2.3.3-beta3</version>
|
||||||
<version>2.3.3-beta2</version>
|
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>fizz-common</module>
|
<module>fizz-common</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user