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

No-ops instead of encoding empty string when encoding an empty body in xml #481

Merged
merged 3 commits into from
Nov 16, 2022
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 @@ -111,17 +111,11 @@ class HttpBodyMiddleware(
renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration)
}
writer.indent()
writer.openBlock("if encoder is JSONEncoder {", "} else if encoder is XMLEncoder {") {
writer.openBlock("if encoder is JSONEncoder {", "}") {
writer.write("// Encode an empty body as an empty structure in JSON")
writer.write("let \$L = \"{}\".data(using: .utf8)!", dataDeclaration)
renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration)
}
writer.indent()
writer.write("// Encode an empty body as an empty string in XML")
writer.write("let \$L = \"\".data(using: .utf8)!", dataDeclaration)
renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration)
writer.dedent()
writer.write("}")
writer.dedent()
writer.write("}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ class HttpBodyMiddlewareTests {
let payload1data = "{}".data(using: .utf8)!
let payload1body = ClientRuntime.HttpBody.data(payload1data)
input.builder.withBody(payload1body)
} else if encoder is XMLEncoder {
// Encode an empty body as an empty string in XML
let payload1data = "".data(using: .utf8)!
let payload1body = ClientRuntime.HttpBody.data(payload1data)
input.builder.withBody(payload1body)
}
}
} catch let err {
Expand Down