Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,12 @@ private CloseableHttpResponse sendDigipostMedia(Object data, String uri) {

private HttpClientResponseHandler<CloseableHttpResponse> responseHandler() {
return response -> {
if (response.getCode() / 100 == 2) {
if (response instanceof CloseableHttpResponse) {
return (CloseableHttpResponse) response;
} else {
throw new DigipostClientException(ErrorCode.GENERAL_ERROR,
"Expected response to be instance of CloseableHttpResponse, but got " + response.getClass().getName());
}
} else {
ErrorMessage errorMessage = unmarshal(jaxbContext, response.getEntity().getContent(), ErrorMessage.class);
throw new DigipostClientException(errorMessage);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public SortedMap<String, String> getHeaders() {

@Override
public String getPath() {
String path = clientRequest.getPath();
return path != null ? path : "";
try {
String path = clientRequest.getUri().getPath();
return path != null ? path : "";
} catch (URISyntaxException e) {
throw new RuntimeException(e.getMessage(), e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.StatusLine;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -92,10 +93,7 @@ public static void checkResponse(ClassicHttpResponse response, EventLogger event
}

private static ErrorMessage fetchErrorMessageString(final HttpResponse response, final HttpEntity responseEntity) {
String statusLine = response.getVersion() + " " + response.getCode();
if (StringUtils.isNotBlank(response.getReasonPhrase())) {
statusLine += " " + response.getReasonPhrase();
}
StatusLine statusLine = new StatusLine(response);
final ErrorType errorType = ErrorType.fromResponseStatus(response.getCode());
if (responseEntity == null) {
return new ErrorMessage(errorType, "status=" + statusLine + ", body=<empty>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public SortedMap<String, String> getHeaders() {

@Override
public String getPath() {
return (String) context.getAttribute("request-path");
String pathWithQueryParams = (String) context.getAttribute("request-path");
int indexOfQuestionMark = pathWithQueryParams.indexOf('?');
if (indexOfQuestionMark != -1) {
return pathWithQueryParams.substring(0, indexOfQuestionMark);
}
return pathWithQueryParams;
}
}