aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-29 11:06:47 +1300
committerGitHub <noreply@github.com>2017-01-29 11:06:47 +1300
commit2df748f53128197c158a62ca5c3f6df0c70d4119 (patch)
tree54444c832e19b6c9d130578c0abef96f1e161167 /src/org
parent72612c6f02dc4d72cfbb95ccd54018ff77920a89 (diff)
parent6520470b767a0882277a7489b3870c676761cebf (diff)
downloadtraccar-server-2df748f53128197c158a62ca5c3f6df0c70d4119.tar.gz
traccar-server-2df748f53128197c158a62ca5c3f6df0c70d4119.tar.bz2
traccar-server-2df748f53128197c158a62ca5c3f6df0c70d4119.zip
Merge pull request #2850 from ValeraVi/fix-geolocation
Set Content Type in http header of geolocation request
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/geolocation/UniversalGeolocationProvider.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/org/traccar/geolocation/UniversalGeolocationProvider.java b/src/org/traccar/geolocation/UniversalGeolocationProvider.java
index 48152f7df..6416b2633 100644
--- a/src/org/traccar/geolocation/UniversalGeolocationProvider.java
+++ b/src/org/traccar/geolocation/UniversalGeolocationProvider.java
@@ -24,6 +24,8 @@ import org.traccar.model.Network;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
public class UniversalGeolocationProvider implements GeolocationProvider {
@@ -37,7 +39,10 @@ public class UniversalGeolocationProvider implements GeolocationProvider {
public void getLocation(Network network, final LocationProviderCallback callback) {
try {
String request = Context.getObjectMapper().writeValueAsString(network);
- Context.getAsyncHttpClient().preparePost(url).setBody(request).execute(new AsyncCompletionHandler() {
+ Context.getAsyncHttpClient().preparePost(url)
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(request.length()))
+ .setBody(request).execute(new AsyncCompletionHandler() {
@Override
public Object onCompleted(Response response) throws Exception {
try (JsonReader reader = Json.createReader(response.getResponseBodyAsStream())) {