Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HttpUtils): Use UTF-8 when forwarding request bodies to OTP #188

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 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,9 +19,9 @@

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.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeParseException;
Expand Down Expand Up @@ -102,26 +102,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, StandardCharsets.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, StandardCharsets.UTF_8));
postRequest.setConfig(timeoutConfig);
httpUriRequest = postRequest;
break;
case HEAD:
case OPTIONS:
Expand Down
Loading