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

Azure core fix for storage playback tests. #4035

Merged
merged 2 commits into from
Jun 21, 2019
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 @@ -100,7 +100,7 @@ private Mono<HttpResponse> playbackHttpResponse(final HttpRequest request) {
HttpHeaders headers = new HttpHeaders();

for (Map.Entry<String, String> pair : networkCallRecord.response().entrySet()) {
if (!pair.getKey().equals("StatusCode") && !pair.getKey().equals("Body") && !pair.getKey().equals("Content-Length")) {
if (!pair.getKey().equals("StatusCode") && !pair.getKey().equals("Body")) {
String rawHeader = pair.getValue();
for (Map.Entry<String, String> rule : textReplacementRules.entrySet()) {
if (rule.getValue() != null) {
Expand All @@ -122,7 +122,9 @@ private Mono<HttpResponse> playbackHttpResponse(final HttpRequest request) {
}

bytes = rawBody.getBytes(StandardCharsets.UTF_8);
headers.put("Content-Length", String.valueOf(bytes.length));
if (bytes.length > 0) {
headers.put("Content-Length", String.valueOf(bytes.length));
}
}

HttpResponse response = new MockHttpResponse(request, recordStatusCode, headers, bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
Expand Down Expand Up @@ -98,7 +97,7 @@ private Mono<Map<String, String>> extractResponseData(final HttpResponse respons
headerValueToStore = "0";
addedRetryAfter = true;
}
responseData.put(header.name().toLowerCase(Locale.US), headerValueToStore);
responseData.put(header.name(), headerValueToStore);
}

if (!addedRetryAfter) {
Expand All @@ -109,7 +108,7 @@ private Mono<Map<String, String>> extractResponseData(final HttpResponse respons
if (contentType == null) {
return Mono.just(responseData);
} else if (contentType.contains("json") || response.headerValue("content-encoding") == null) {
return response.bodyAsString().map(content -> {
return response.bodyAsString().switchIfEmpty(Mono.just("")).map(content -> {
responseData.put("Body", content);
return responseData;
});
Expand Down