Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-23 23:00:35 +01:00
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 {
|
||||
|
||||
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
|
||||
|
@ -20,9 +20,9 @@ public class SimpleHttpResponse {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleHttpResponse{" +
|
||||
"code=" + code +
|
||||
", body='" + body + '\'' +
|
||||
'}';
|
||||
return "SimpleHttpResponse{"
|
||||
+ "code=" + code
|
||||
+ ", body='" + body + '\''
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren