3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Include implementation in the user-agent.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-11-03 01:39:28 -04:00
Ursprung f423169449
Commit e2389d96e9
3 geänderte Dateien mit 8 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -25,8 +25,10 @@ import javax.net.ssl.SSLEngine;
public class NettyHttpClient {
private final ChannelPoolMap<InetSocketAddress, SimpleChannelPool> poolMap;
private final String userAgent;
public NettyHttpClient(VelocityServer server) {
this.userAgent = server.getVersion().getName() + "/" + server.getVersion().getVersion();
Bootstrap bootstrap = server.initializeGenericBootstrap();
this.poolMap = new AbstractChannelPoolMap<InetSocketAddress, SimpleChannelPool>() {
@Override
@ -80,7 +82,7 @@ public class NettyHttpClient {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.GET, url.getPath() + "?" + url.getQuery());
request.headers().add(HttpHeaderNames.HOST, url.getHost());
request.headers().add(HttpHeaderNames.USER_AGENT, "Velocity");
request.headers().add(HttpHeaderNames.USER_AGENT, userAgent);
channel.writeAndFlush(request);
// Make sure to release this connection

Datei anzeigen

@ -20,9 +20,9 @@ public class SimpleHttpResponse {
@Override
public String toString() {
return "SimpleHttpResponse{" +
"code=" + code +
", body='" + body + '\'' +
'}';
return "SimpleHttpResponse{"
+ "code=" + code
+ ", body='" + body + '\''
+ '}';
}
}

Datei anzeigen

@ -68,8 +68,7 @@ public class VelocityEventManager implements EventManager {
ensurePlugin(plugin);
Preconditions.checkNotNull(listener, "listener");
if (plugin == listener && registeredListenersByPlugin.containsEntry(plugin, plugin)) {
throw new IllegalArgumentException(
"Trying to register the plugin main instance. Velocity already takes care of this for you.");
throw new IllegalArgumentException("The plugin main instance is automatically registered.");
}
registeredListenersByPlugin.put(plugin, listener);
methodAdapter.register(listener);