diff --git a/http/pom.xml b/http/pom.xml
index 3e51bf75..603d91b2 100644
--- a/http/pom.xml
+++ b/http/pom.xml
@@ -31,5 +31,10 @@
4.11
test
+
+ com.google.guava
+ guava
+ 14.0.1
+
diff --git a/http/src/main/java/net/md_5/bungee/http/HttpClient.java b/http/src/main/java/net/md_5/bungee/http/HttpClient.java
index 8f10abef..9dd1b5a2 100644
--- a/http/src/main/java/net/md_5/bungee/http/HttpClient.java
+++ b/http/src/main/java/net/md_5/bungee/http/HttpClient.java
@@ -1,5 +1,57 @@
package net.md_5.bungee.http;
+import com.google.common.base.Preconditions;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.http.DefaultHttpRequest;
+import io.netty.handler.codec.http.HttpHeaders;
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpRequest;
+import io.netty.handler.codec.http.HttpVersion;
+import java.net.URI;
+import java.net.URISyntaxException;
+import lombok.RequiredArgsConstructor;
+
+@RequiredArgsConstructor
public class HttpClient
{
+
+ private final EventLoopGroup eventLoop;
+
+ public void get(String url)
+ {
+ URI uri = null;
+ try
+ {
+ uri = new URI( url );
+ } catch ( URISyntaxException ex )
+ {
+ throw new IllegalArgumentException( "Could not parse url " + url, ex );
+ }
+
+ Preconditions.checkNotNull( uri.getScheme(), "scheme" );
+ Preconditions.checkNotNull( uri.getHost(), "host" );
+ boolean ssl = false;
+ int port = uri.getPort();
+ if ( port == -1 )
+ {
+ switch ( uri.getScheme() )
+ {
+ case "http":
+ port = 80;
+ break;
+ case "https":
+ port = 443;
+ break;
+ default:
+ throw new IllegalArgumentException( "Unknown scheme " + uri.getScheme() );
+ }
+ }
+
+ new Bootstrap().channel( NioSocketChannel.class ).group( eventLoop ).handler( new HttpInitializer( url, port, ssl ) ).remoteAddress( uri.getHost(), port ).connect();
+
+ HttpRequest request = new DefaultHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath() );
+ request.headers().set( HttpHeaders.Names.HOST, uri.getHost() );
+ }
}
diff --git a/http/src/main/java/net/md_5/bungee/http/HttpInitializer.java b/http/src/main/java/net/md_5/bungee/http/HttpInitializer.java
new file mode 100644
index 00000000..c2a09a49
--- /dev/null
+++ b/http/src/main/java/net/md_5/bungee/http/HttpInitializer.java
@@ -0,0 +1,30 @@
+package net.md_5.bungee.http;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelInitializer;
+import io.netty.handler.codec.http.HttpClientCodec;
+import io.netty.handler.ssl.SslHandler;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import lombok.RequiredArgsConstructor;
+
+@RequiredArgsConstructor
+public class HttpInitializer extends ChannelInitializer
+{
+
+ private final String host;
+ private final int port;
+ private final boolean ssl;
+
+ @Override
+ protected void initChannel(Channel ch) throws Exception
+ {
+ if ( ssl )
+ {
+ SSLContext context = SSLContext.getDefault();
+ SSLEngine engine = context.createSSLEngine( host, port );
+ ch.pipeline().addLast( "ssl", new SslHandler( engine ) );
+ }
+ ch.pipeline().addLast( "http", new HttpClientCodec() );
+ }
+}