in src/main/java/com/amazonaws/neptune/auth/NeptuneRequestMetadataSigV4Signer.java [72:115]
protected SignableRequest<?> toSignableRequest(final RequestMetadata request)
throws NeptuneSigV4SignerException {
// make sure the request is not null and contains the minimal required set of information
checkNotNull(request, "The request must not be null");
checkNotNull(request.getFullUri(), "The request URI must not be null");
checkNotNull(request.getMethod(), "The request method must not be null");
final URI fullUri = URI.create(request.getFullUri());
checkNotNull(fullUri.getAuthority(), "Authority must not be null");
checkNotNull(fullUri.getScheme(), "Scheme must not be null");
// convert the headers to the internal API format
final Map<String, String> headersInternal = request.getHeaders()
.entrySet()
.stream()
.filter(e -> !e.getKey().equalsIgnoreCase(HOST))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// convert the parameters to the internal API format
final String queryStr = fullUri.getRawQuery();
final Map<String, List<String>> parametersInternal = extractParametersFromQueryString(queryStr);
// carry over the entity (or an empty entity, if no entity is provided)
final InputStream content;
final byte[] bytes;
if (request.getContent().isPresent()) {
bytes = request.getContent().get();
} else {
bytes = "".getBytes(StandardCharsets.UTF_8);
}
content = new ByteArrayInputStream(bytes);
final URI endpointUri = URI.create(fullUri.getScheme() + "://" + fullUri.getAuthority());
final String resourcePath = fullUri.getPath();
return convertToSignableRequest(
request.getMethod(),
endpointUri,
resourcePath,
headersInternal,
parametersInternal,
content);
}