aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
diff options
context:
space:
mode:
authorjcardus <joaquim.cardeira@gmail.com>2020-03-25 17:25:19 +0000
committerjcardus <joaquim.cardeira@gmail.com>2020-03-25 17:25:19 +0000
commitfeac85bad4004fb3e316a88285626e12840398d2 (patch)
treed268a79d63b9d1f27b6e433fedc90de7b427b172 /src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
parent7b669e3181f637f06b31b55bd930584c7b08e897 (diff)
parentf3d465abe7f255ec44e976caade642e4c2fd7598 (diff)
downloadtrackermap-server-feac85bad4004fb3e316a88285626e12840398d2.tar.gz
trackermap-server-feac85bad4004fb3e316a88285626e12840398d2.tar.bz2
trackermap-server-feac85bad4004fb3e316a88285626e12840398d2.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
index 26af8d5af..ab89f10c8 100644
--- a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import io.netty.channel.Channel;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import org.traccar.BaseHttpProtocolDecoder;
@@ -96,21 +97,23 @@ public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder {
rootElement.appendChild(state);
Element stateMessage = document.createElement("stateMessage");
- stateMessage.appendChild(document.createTextNode("Messages received and stored successfully"));
+ stateMessage.appendChild(document.createTextNode("Store OK"));
rootElement.appendChild(stateMessage);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
ByteBuf content = Unpooled.buffer();
transformer.transform(new DOMSource(document), new StreamResult(new ByteBufOutputStream(content)));
- FullHttpResponse response = new DefaultFullHttpResponse(
- HttpVersion.HTTP_1_1, HttpResponseStatus.OK, content);
if (channel != null) {
+ FullHttpResponse response = new DefaultFullHttpResponse(
+ HttpVersion.HTTP_1_1, HttpResponseStatus.OK, content);
+ response.headers()
+ .add(HttpHeaderNames.CONTENT_LENGTH, content.readableBytes())
+ .add(HttpHeaderNames.CONTENT_TYPE, "text/xml");
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
-
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {