add more information on unexpected response

This commit is contained in:
Emil Lerch 2023-08-29 11:56:01 -07:00
parent 48fc41c4b8
commit 70bd8dafa5
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -479,7 +479,13 @@ pub fn Request(comptime request_action: anytype) type {
const xml_options = xml_shaper.ParseOptions{ .allocator = options.client.allocator };
var body: []const u8 = result.body;
var free_body = false;
if (result.body.len < 20) return error.UnexpectedResponse;
if (result.body.len < 20) {
std.log.err(
"Unexpected response from server. Looking for XML that ends in 'Response' or 'Result'. Found:\n{s}␃\n===",
.{result.body},
);
return error.UnexpectedResponse;
}
if (std.mem.lastIndexOf(u8, result.body[result.body.len - 20 ..], "Response>") == null and
std.mem.lastIndexOf(u8, result.body[result.body.len - 20 ..], "Result>") == null)
{