geforkt von Mirrors/Velocity
Include implementation in the user-agent.
Dieser Commit ist enthalten in:
Ursprung
f423169449
Commit
e2389d96e9
@ -25,8 +25,10 @@ import javax.net.ssl.SSLEngine;
|
|||||||
public class NettyHttpClient {
|
public class NettyHttpClient {
|
||||||
|
|
||||||
private final ChannelPoolMap<InetSocketAddress, SimpleChannelPool> poolMap;
|
private final ChannelPoolMap<InetSocketAddress, SimpleChannelPool> poolMap;
|
||||||
|
private final String userAgent;
|
||||||
|
|
||||||
public NettyHttpClient(VelocityServer server) {
|
public NettyHttpClient(VelocityServer server) {
|
||||||
|
this.userAgent = server.getVersion().getName() + "/" + server.getVersion().getVersion();
|
||||||
Bootstrap bootstrap = server.initializeGenericBootstrap();
|
Bootstrap bootstrap = server.initializeGenericBootstrap();
|
||||||
this.poolMap = new AbstractChannelPoolMap<InetSocketAddress, SimpleChannelPool>() {
|
this.poolMap = new AbstractChannelPoolMap<InetSocketAddress, SimpleChannelPool>() {
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +82,7 @@ public class NettyHttpClient {
|
|||||||
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
|
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
|
||||||
HttpMethod.GET, url.getPath() + "?" + url.getQuery());
|
HttpMethod.GET, url.getPath() + "?" + url.getQuery());
|
||||||
request.headers().add(HttpHeaderNames.HOST, url.getHost());
|
request.headers().add(HttpHeaderNames.HOST, url.getHost());
|
||||||
request.headers().add(HttpHeaderNames.USER_AGENT, "Velocity");
|
request.headers().add(HttpHeaderNames.USER_AGENT, userAgent);
|
||||||
channel.writeAndFlush(request);
|
channel.writeAndFlush(request);
|
||||||
|
|
||||||
// Make sure to release this connection
|
// Make sure to release this connection
|
||||||
|
@ -20,9 +20,9 @@ public class SimpleHttpResponse {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SimpleHttpResponse{" +
|
return "SimpleHttpResponse{"
|
||||||
"code=" + code +
|
+ "code=" + code
|
||||||
", body='" + body + '\'' +
|
+ ", body='" + body + '\''
|
||||||
'}';
|
+ '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,7 @@ public class VelocityEventManager implements EventManager {
|
|||||||
ensurePlugin(plugin);
|
ensurePlugin(plugin);
|
||||||
Preconditions.checkNotNull(listener, "listener");
|
Preconditions.checkNotNull(listener, "listener");
|
||||||
if (plugin == listener && registeredListenersByPlugin.containsEntry(plugin, plugin)) {
|
if (plugin == listener && registeredListenersByPlugin.containsEntry(plugin, plugin)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException("The plugin main instance is automatically registered.");
|
||||||
"Trying to register the plugin main instance. Velocity already takes care of this for you.");
|
|
||||||
}
|
}
|
||||||
registeredListenersByPlugin.put(plugin, listener);
|
registeredListenersByPlugin.put(plugin, listener);
|
||||||
methodAdapter.register(listener);
|
methodAdapter.register(listener);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren