diff options
author | ninioe <ninioe@gmail.com> | 2016-07-24 10:12:29 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-07-24 10:12:29 +0300 |
commit | efb18afb3bc265e0d3525ad66ee0e0558d95f478 (patch) | |
tree | f5d4cc82a144072a8eec0d25f9fb592422285e1f /src/org/traccar/protocol/OsmAndProtocolDecoder.java | |
parent | fd3a695813f511d1b94775bd4e8a4c57053fc66d (diff) | |
parent | 0c61dddb5f875e34c819f6d936fcb5e7f45d88ed (diff) | |
download | trackermap-server-efb18afb3bc265e0d3525ad66ee0e0558d95f478.tar.gz trackermap-server-efb18afb3bc265e0d3525ad66ee0e0558d95f478.tar.bz2 trackermap-server-efb18afb3bc265e0d3525ad66ee0e0558d95f478.zip |
Merge remote-tracking branch 'refs/remotes/tananaev/master'
# Conflicts:
# tools/test-generator.py
Diffstat (limited to 'src/org/traccar/protocol/OsmAndProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index cfa8990dd..f46511b27 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -16,10 +16,8 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.handler.codec.http.DefaultHttpResponse; import org.jboss.netty.handler.codec.http.HttpRequest; -import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.codec.http.QueryStringDecoder; @@ -50,8 +48,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { QueryStringDecoder decoder = new QueryStringDecoder(request.getUri()); Map<String, List<String>> params = decoder.getParameters(); if (params.isEmpty()) { - decoder = new QueryStringDecoder( - request.getContent().toString(StandardCharsets.US_ASCII), false); + decoder = new QueryStringDecoder(request.getContent().toString(StandardCharsets.US_ASCII), false); params = decoder.getParameters(); } @@ -66,6 +63,10 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "deviceid": DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value); if (deviceSession == null) { + if (channel != null) { + channel.write( + new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)); + } return null; } position.setDeviceId(deviceSession.getDeviceId()); @@ -123,9 +124,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { } if (channel != null) { - HttpResponse response = new DefaultHttpResponse( - HttpVersion.HTTP_1_1, HttpResponseStatus.OK); - channel.write(response).addListener(ChannelFutureListener.CLOSE); + channel.write(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)); } return position; |