diff options
author | namo <namo@gurtam.com> | 2017-12-26 10:19:46 +0300 |
---|---|---|
committer | namo <namo@gurtam.com> | 2017-12-26 10:19:46 +0300 |
commit | 992b8e14af92626724b581be23850fd74f7e4620 (patch) | |
tree | 78430c4f52efb6db4ea6ee09acf5764d9f181e6d /src/org | |
parent | 181d91bf2a7c86b443fcd14cf41a3aa6afe7e204 (diff) | |
download | trackermap-server-992b8e14af92626724b581be23850fd74f7e4620.tar.gz trackermap-server-992b8e14af92626724b581be23850fd74f7e4620.tar.bz2 trackermap-server-992b8e14af92626724b581be23850fd74f7e4620.zip |
flespi protocol: content-type=application/json
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/FlespiProtocolDecoder.java | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/FlespiProtocolDecoder.java b/src/org/traccar/protocol/FlespiProtocolDecoder.java index 976746472..6cba234e5 100644 --- a/src/org/traccar/protocol/FlespiProtocolDecoder.java +++ b/src/org/traccar/protocol/FlespiProtocolDecoder.java @@ -18,10 +18,6 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponseStatus; -import org.jboss.netty.handler.codec.http.multipart.Attribute; -import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory; -import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder; -import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData; import org.traccar.BaseHttpProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.model.Position; @@ -34,6 +30,7 @@ import javax.json.JsonString; import javax.json.JsonValue; import java.io.StringReader; import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -50,16 +47,8 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder { Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { HttpRequest request = (HttpRequest) msg; - HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request); - InterfaceHttpData data = decoder.getBodyHttpData("data"); - if (data.getHttpDataType() != InterfaceHttpData.HttpDataType.Attribute) { - sendResponse(channel, HttpResponseStatus.BAD_REQUEST); - return null; - } - - Attribute attribute = (Attribute) data; - String value = attribute.getValue(); - JsonArray result = Json.createReader(new StringReader(value)).readArray(); + JsonArray result = Json.createReader(new StringReader(request.getContent().toString(StandardCharsets.UTF_8))) + .readArray(); List<Position> positions = new LinkedList<>(); for (int i = 0; i < result.size(); i++) { JsonObject message = result.getJsonObject(i); |