diff --git a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java index 0494066ce..396232e92 100644 --- a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java @@ -14,6 +14,7 @@ import dan200.computercraft.core.apis.http.*; import dan200.computercraft.core.apis.http.request.HttpRequest; import dan200.computercraft.core.apis.http.websocket.Websocket; import io.netty.handler.codec.http.DefaultHttpHeaders; +import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpMethod; @@ -179,7 +180,7 @@ public class HTTPAPI implements ILuaAPI } @Nonnull - private static HttpHeaders getHeaders( @Nonnull Map headerTable ) throws LuaException + private HttpHeaders getHeaders( @Nonnull Map headerTable ) throws LuaException { HttpHeaders headers = new DefaultHttpHeaders(); for( Map.Entry entry : headerTable.entrySet() ) @@ -197,6 +198,11 @@ public class HTTPAPI implements ILuaAPI } } } + + if( !headers.contains( HttpHeaderNames.USER_AGENT ) ) + { + headers.set( HttpHeaderNames.USER_AGENT, apiEnvironment.getComputerEnvironment().getUserAgent() ); + } return headers; } } diff --git a/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java b/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java index db83124e6..e4e6445b4 100644 --- a/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java +++ b/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java @@ -80,10 +80,6 @@ public final class HttpRequestHandler extends SimpleChannelInboundHandler