From bb6a73f97f87ce06dcc9f3b2b129b7fde657b22c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 16 Jan 2022 10:49:42 -0800 Subject: Add request headers --- src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main') diff --git a/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java b/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java index 87fa039e1..9465f63a7 100644 --- a/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java +++ b/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.handler.codec.http.DefaultFullHttpRequest; +import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpRequest; import io.netty.handler.codec.http.HttpVersion; @@ -37,6 +38,7 @@ public class OrbcommProtocolPoller extends BaseProtocolPoller { private final String accessId; private final String password; + private final String host; private Date startTime = new Date(); @@ -48,6 +50,7 @@ public class OrbcommProtocolPoller extends BaseProtocolPoller { super(protocol); accessId = Context.getConfig().getString(Keys.ORBCOMM_ACCESS_ID); password = Context.getConfig().getString(Keys.ORBCOMM_PASSWORD); + host = Context.getConfig().getString(Keys.PROTOCOL_ADDRESS.withPrefix(protocol.getName())); } @Override @@ -63,6 +66,8 @@ public class OrbcommProtocolPoller extends BaseProtocolPoller { HttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.POST, encoder.toString(), Unpooled.buffer()); + request.headers().add(HttpHeaderNames.HOST, host); + request.headers().add(HttpHeaderNames.CONTENT_LENGTH, 0); channel.writeAndFlush(request); } -- cgit v1.2.3