fix query paramater encoding in RequestBuilder, update to Gradle 5.1, update to Netty 4.1.33
This commit is contained in:
parent
42c147cec1
commit
3d683d0b83
8 changed files with 21 additions and 11 deletions
|
@ -2,7 +2,7 @@ import java.time.ZonedDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "com.github.spotbugs" version "1.6.5"
|
id "com.github.spotbugs" version "1.6.9"
|
||||||
id "org.sonarqube" version "2.6.1"
|
id "org.sonarqube" version "2.6.1"
|
||||||
id "io.codearte.nexus-staging" version "0.11.0"
|
id "io.codearte.nexus-staging" version "0.11.0"
|
||||||
id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1"
|
id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = netty-http
|
name = netty-http
|
||||||
version = 4.1.32.0
|
version = 4.1.33.0
|
||||||
|
|
||||||
netty.version = 4.1.32.Final
|
netty.version = 4.1.33.Final
|
||||||
tcnative.version = 2.0.20.Final
|
tcnative.version = 2.0.20.Final
|
||||||
bouncycastle.version = 1.60
|
bouncycastle.version = 1.60
|
||||||
xbib-net-url.version = 1.1.3
|
xbib-net-url.version = 1.2.1
|
||||||
alpnagent.version = 2.0.9
|
alpnagent.version = 2.0.9
|
||||||
|
|
||||||
# tests /docs
|
# tests /docs
|
||||||
|
@ -14,3 +14,5 @@ conscrypt.version = 1.0.1
|
||||||
jackson.version = 2.8.11.1
|
jackson.version = 2.8.11.1
|
||||||
wagon.version = 3.0.0
|
wagon.version = 3.0.0
|
||||||
asciidoclet.version = 1.5.4
|
asciidoclet.version = 1.5.4
|
||||||
|
|
||||||
|
org.gradle.warning.mode=all
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Tue Nov 13 10:38:26 CET 2018
|
#Tue Feb 05 16:02:21 CET 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip
|
||||||
|
|
2
gradlew
vendored
2
gradlew
vendored
|
@ -28,7 +28,7 @@ APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
|
@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
|
@ -14,13 +14,14 @@ import io.netty.handler.codec.http.QueryStringEncoder;
|
||||||
import io.netty.handler.codec.http.cookie.Cookie;
|
import io.netty.handler.codec.http.cookie.Cookie;
|
||||||
import io.netty.handler.codec.http2.HttpConversionUtil;
|
import io.netty.handler.codec.http2.HttpConversionUtil;
|
||||||
import io.netty.util.AsciiString;
|
import io.netty.util.AsciiString;
|
||||||
|
import org.xbib.net.PercentEncoder;
|
||||||
|
import org.xbib.net.PercentEncoders;
|
||||||
import org.xbib.net.QueryParameters;
|
import org.xbib.net.QueryParameters;
|
||||||
import org.xbib.net.URL;
|
import org.xbib.net.URL;
|
||||||
import org.xbib.net.URLSyntaxException;
|
import org.xbib.net.URLSyntaxException;
|
||||||
import org.xbib.netty.http.client.retry.BackOff;
|
import org.xbib.netty.http.client.retry.BackOff;
|
||||||
import org.xbib.netty.http.common.HttpAddress;
|
import org.xbib.netty.http.common.HttpAddress;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.MalformedInputException;
|
import java.nio.charset.MalformedInputException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -62,6 +63,8 @@ public class RequestBuilder {
|
||||||
|
|
||||||
private final Collection<Cookie> cookies;
|
private final Collection<Cookie> cookies;
|
||||||
|
|
||||||
|
private final PercentEncoder encoder;
|
||||||
|
|
||||||
private HttpMethod httpMethod;
|
private HttpMethod httpMethod;
|
||||||
|
|
||||||
private HttpHeaders headers;
|
private HttpHeaders headers;
|
||||||
|
@ -106,6 +109,7 @@ public class RequestBuilder {
|
||||||
headers = new DefaultHttpHeaders();
|
headers = new DefaultHttpHeaders();
|
||||||
removeHeaders = new ArrayList<>();
|
removeHeaders = new ArrayList<>();
|
||||||
cookies = new HashSet<>();
|
cookies = new HashSet<>();
|
||||||
|
encoder = PercentEncoders.getQueryEncoder(StandardCharsets.UTF_8);
|
||||||
queryParameters = new QueryParameters();
|
queryParameters = new QueryParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +189,11 @@ public class RequestBuilder {
|
||||||
|
|
||||||
public RequestBuilder addParameter(String name, String value) {
|
public RequestBuilder addParameter(String name, String value) {
|
||||||
if (queryParameters != null) {
|
if (queryParameters != null) {
|
||||||
queryParameters.add(name, value);
|
try {
|
||||||
|
queryParameters.add(name, encoder.encode(value));
|
||||||
|
} catch (MalformedInputException | UnmappableCharacterException e) {
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class XbibTest extends TestBase {
|
||||||
try {
|
try {
|
||||||
return httpClient.execute(Request.post()
|
return httpClient.execute(Request.post()
|
||||||
.url("http://google.de")
|
.url("http://google.de")
|
||||||
.addParameter("query", content)
|
.addParameter("query", content.substring(0, 15))
|
||||||
.build(), httpResponseStringFunction);
|
.build(), httpResponseStringFunction);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.log(Level.WARNING, e.getMessage(), e);
|
logger.log(Level.WARNING, e.getMessage(), e);
|
||||||
|
|
Loading…
Reference in a new issue