mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 03:00:30 +00:00
Add User-Agent to Websockets
I think, haven't actually tested this :D:. Closes #730.
This commit is contained in:
parent
ed0afc4068
commit
0ee3d10fda
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -80,10 +80,6 @@ public final class HttpRequestHandler extends SimpleChannelInboundHandler<HttpOb
|
||||
{
|
||||
request.headers().set( HttpHeaderNames.ACCEPT_CHARSET, "UTF-8" );
|
||||
}
|
||||
if( !request.headers().contains( HttpHeaderNames.USER_AGENT ) )
|
||||
{
|
||||
request.headers().set( HttpHeaderNames.USER_AGENT, this.request.environment().getComputerEnvironment().getUserAgent() );
|
||||
}
|
||||
request.headers().set( HttpHeaderNames.HOST, uri.getPort() < 0 ? uri.getHost() : uri.getHost() + ":" + uri.getPort() );
|
||||
request.headers().set( HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user