aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorVitaliy Gergel <vitaliy.gergel@zoomdata.com>2020-03-04 21:18:14 +0200
committerVitaliy Gergel <vitaliy.gergel@zoomdata.com>2020-03-04 21:18:14 +0200
commite7c04c8dfaa67e5bef2d3b9c5ba8924e85045ffc (patch)
treec6077d208e7976373c3c6f4117e9680940f62592 /src/main/java
parentdd23d3becaf50ad4cdaf0064712f1f104e1c5967 (diff)
downloadtraccar-server-e7c04c8dfaa67e5bef2d3b9c5ba8924e85045ffc.tar.gz
traccar-server-e7c04c8dfaa67e5bef2d3b9c5ba8924e85045ffc.tar.bz2
traccar-server-e7c04c8dfaa67e5bef2d3b9c5ba8924e85045ffc.zip
Fix code review comments and repace url variables for post request as well
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/WebDataHandler.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/WebDataHandler.java b/src/main/java/org/traccar/WebDataHandler.java
index c8bb9b461..858b00aad 100644
--- a/src/main/java/org/traccar/WebDataHandler.java
+++ b/src/main/java/org/traccar/WebDataHandler.java
@@ -192,7 +192,7 @@ public class WebDataHandler extends BaseDataHandler {
String formattedUrl;
try {
- formattedUrl = json ? url : formatRequest(position);
+ formattedUrl = formatRequest(position);
} catch (UnsupportedEncodingException | JsonProcessingException e) {
throw new RuntimeException("Forwarding formatting error", e);
}
@@ -203,9 +203,10 @@ public class WebDataHandler extends BaseDataHandler {
String[] values = line.split(":", 2);
String headerName = values[0].trim();
String headerValue = values[1].trim();
- requestBuilder.header(headerName, headerValue);
if (headerName.equals(HttpHeaders.CONTENT_TYPE)) {
mediaType = MediaType.valueOf(headerValue);
+ } else {
+ requestBuilder.header(headerName, headerValue);
}
}
}
@@ -220,9 +221,10 @@ public class WebDataHandler extends BaseDataHandler {
private void send() {
if (json) {
try {
- requestBuilder.async().post(Entity.entity(objectMapper.writeValueAsString(payload), mediaType), this);
+ Entity<String> entity = Entity.entity(objectMapper.writeValueAsString(payload), mediaType);
+ requestBuilder.async().post(entity, this);
} catch (JsonProcessingException e) {
- throw new RuntimeException("Failed to serialize payload to json: " + payload);
+ throw new RuntimeException("Failed to serialize location to json", e);
}
} else {
requestBuilder.async().get(this);