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

Do not retrieve the headers when request was rejected by server when using Expect header #4588

Closed
Closed
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 @@ -389,14 +389,21 @@ private ClientResponse _apply(final ClientRequest request) throws IOException {
}

ClientResponse responseContext = new ClientResponse(status, request, resolvedRequestUri);
responseContext.headers(
if (!(storedException instanceof ProtocolException
&& storedException.getMessage().equals("Server rejected operation"))) {
// Set the headers only when the request was not rejected by the server based on 'Expect' header.
// If the request contains 'Expect' header and server returned non-100 response then both input
// and output streams are null. Calling getHeaderFields in turn calls getInputStream which again
// sends the request to server.
responseContext.headers(
uc.getHeaderFields()
.entrySet()
.stream()
.filter(stringListEntry -> stringListEntry.getKey() != null)
.collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue))
);
.entrySet()
.stream()
.filter(stringListEntry -> stringListEntry.getKey() != null)
.collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue))
);
}

try {
InputStream inputStream = getInputStream(uc);
Expand Down