Skip to content

Commit

Permalink
fix(HttpUtils): Use UTF-8 when forwarding request bodies to OTP.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Oct 10, 2023
1 parent d6ae410 commit d18377a
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/main/java/org/opentripplanner/middleware/utils/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.http.HttpTimeoutException;
import java.time.LocalDate;
Expand Down Expand Up @@ -102,26 +101,16 @@ public static HttpResponseValues httpRequestRawResponse(URI uri, int timeoutInSe
httpUriRequest = deleteRequest;
break;
case PUT:
try {
HttpPut putRequest = new HttpPut(uri);
putRequest.setEntity(new StringEntity(bodyContent));
putRequest.setConfig(timeoutConfig);
httpUriRequest = putRequest;
} catch (UnsupportedEncodingException e) {
LOG.error("Unsupported encoding type", e);
return null;
}
HttpPut putRequest = new HttpPut(uri);
putRequest.setEntity(new StringEntity(bodyContent, "UTF-8"));
putRequest.setConfig(timeoutConfig);
httpUriRequest = putRequest;
break;
case POST:
try {
HttpPost postRequest = new HttpPost(uri);
postRequest.setEntity(new StringEntity(bodyContent));
postRequest.setConfig(timeoutConfig);
httpUriRequest = postRequest;
} catch (UnsupportedEncodingException e) {
LOG.error("Unsupported encoding type", e);
return null;
}
HttpPost postRequest = new HttpPost(uri);
postRequest.setEntity(new StringEntity(bodyContent, "UTF-8"));
postRequest.setConfig(timeoutConfig);
httpUriRequest = postRequest;
break;
case HEAD:
case OPTIONS:
Expand Down

0 comments on commit d18377a

Please sign in to comment.