downgrade to Netty 4.1.19

This commit is contained in:
Jörg Prante 2018-03-01 15:48:28 +01:00
parent c43c3b9f67
commit f25291a506
4 changed files with 30 additions and 4 deletions

View file

@ -1,8 +1,8 @@
group = org.xbib
name = netty-http-client
version = 4.1.22.0
version = 4.1.19.0
netty.version = 4.1.22.Final
netty.version = 4.1.19.Final
tcnative.version = 2.0.1.Final
xbib-net-url.version = 1.1.0
alpnagent.version = 2.0.7

View file

@ -1,5 +1,6 @@
task xbibUpload(type: Upload) {
group = 'publish'
configuration = configurations.archives
uploadDescriptor = true
repositories {
@ -15,6 +16,7 @@ task xbibUpload(type: Upload) {
}
task sonaTypeUpload(type: Upload) {
group = 'publish'
configuration = configurations.archives
uploadDescriptor = true
repositories {

View file

@ -100,6 +100,10 @@ public final class Client {
return new ClientBuilder();
}
public ByteBufAllocator getByteBufAllocator() {
return byteBufAllocator;
}
public void setTransportListener(TransportListener transportListener) {
this.transportListener = transportListener;
}

View file

@ -7,10 +7,12 @@ import org.xbib.net.URL;
import org.xbib.netty.http.client.Client;
import org.xbib.netty.http.client.HttpAddress;
import org.xbib.netty.http.client.Request;
import org.xbib.netty.http.client.RequestBuilder;
import org.xbib.netty.http.client.transport.Transport;
import java.io.IOException;
import java.net.ConnectException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;
@ -39,6 +41,16 @@ public class RestClient {
}
public static RestClient get(String urlString) throws IOException {
return method(urlString, null, null, HttpMethod.GET);
}
public static RestClient post(String urlString, String body) throws IOException {
return method(urlString, body, null, HttpMethod.POST);
}
public static RestClient method(String urlString,
String body, Charset charset,
HttpMethod httpMethod) throws IOException {
URL url = URL.create(urlString);
Client client = new Client();
Transport transport = client.newTransport(HttpAddress.http1(url));
@ -50,8 +62,16 @@ public class RestClient {
throw new ConnectException("unable to connect to " + url);
}
transport.awaitSettings();
transport.execute(Request.builder(HttpMethod.GET).setURL(url).build());
transport.get();
RequestBuilder requestBuilder = Request.builder(httpMethod);
requestBuilder.setURL(url);
if (body != null && charset != null) {
ByteBuf byteBuf = client.getByteBufAllocator().buffer();
byteBuf.writeCharSequence(body, charset);
requestBuilder.setContent(byteBuf);
}
transport.execute(requestBuilder.build()).get();
return restClient;
}
}