I am using the mountebank to make the request proxy to the LocalStack (an AWS emulator tool).
The behavior changed since mountebank version 2.7.0 because a more pretty printed response was responded that changes the Content-Length value in the response header.
The difference can be seen in the log part..Obviously, in mountebank v2.7.0 or onwards, The json in the response body is prettied by line break.
Can we have an option for user to choose whether to use pretty body response or not? Thanks
using System.Text.Json;
using Amazon;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
var client = new AmazonDynamoDBClient(new AmazonDynamoDBConfig
{
ServiceURL = "http://localhost:8080",
AuthenticationRegion = "eu-west-1",
DisableLogging = false,
MaxErrorRetry = 3
});
try
{
Console.WriteLine("Fetching DynamoDB...");
var result = await client.GetItemAsync("Devices", new Dictionary<string, AttributeValue>()
{
{ "Serial", new AttributeValue { S = "xxx" } }
});
Console.WriteLine("Done");
Console.WriteLine(JsonSerializer.Serialize(result));
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
System.IO.IOException: CRC value returned with response does not match the computed CRC value for the returned response body.
OS : MacOS
mountebank : 2.7.0
node.js : v22.1.0
(only if installed via npm)
Installation method :
(npm, zip, tar, pkg, deb, rpm)
// mountebank 2.6.0 .NET SDK
mountebank | debug: [http:8080 S3 Proxy] ::ffff:192.168.65.1:45167 <= {"statusCode":200,"headers":{"Connection":"close","Server":"TwistedWeb/24.3.0","Date":"Thu, 24 Oct 2024 07:06:45 GMT","Content-Type":"application/x-amz-json-1.0","Content-Length":397,"x-amzn-requestid":"ed933fb1-da80-45f2-a192-4afaff2cb054","x-amz-crc32":"3479715746"},"body":"{\"Item\": {\"Timezone\": {\"S\": \"xx\"}, \"Serial\": {\"S\": \"xxxx\"}, \"Data\": {\"S\": \"{\\\"Serial\\\":\\\"xxxx\\\",\\\"Name\\\":\\\"xxxx\\\",\\\"ScaleUnit\\\":\\\"AWS-IOT\\\",\\\"Variant\\\":\\\"E\\\",\\\"Version\\\":\\\"xx\\\",\\\"AutoUpdate\\\":true,\\\"NewVersionAvailable\\\":false,\\\"Provisioned\\\":true}\"}}}","_mode":"text"}
// mountebank 2.7.0 .NET SDK
mountebank | debug: [http:8080 S3 Proxy] ::ffff:192.168.65.1:29435 <= {"statusCode":200,"headers":{"Connection":"close","Server":"TwistedWeb/24.3.0","Date":"Thu, 24 Oct 2024 07:08:09 GMT","Content-Type":"application/x-amz-json-1.0","Content-Length":469,"x-amzn-requestid":"30817988-5174-45e0-9b87-1ca36b7cf7f6","x-amz-crc32":"3479715746"},"body":"{\n \"Item\": {\n \"Timezone\": {\n \"S\": \"xx\"\n },\n \"Serial\": {\n \"S\": \"xxxx\"\n },\n \"Data\": {\n \"S\": \"{\\\"Serial\\\":\\\"xxxx\\\",\\\"Name\\\":\\\"xxxx\\\",\\\"ScaleUnit\\\":\\\"AWS-IOT\\\",\\\"Variant\\\":\\\"E\\\",\\\"Version\\\":\\\"xx\\\",\\\"AutoUpdate\\\":true,\\\"NewVersionAvailable\\\":false,\\\"Provisioned\\\":true}\"\n }\n }\n}","_mode":"text"}
// mountebank 2.7.0 NODE.SDK
mountebank | debug: [http:8080 S3 Proxy] ::ffff:192.168.65.1:38636 <= {"statusCode":200,"headers":{"Server":"TwistedWeb/24.3.0","Date":"Thu, 24 Oct 2024 07:21:57 GMT","Content-Type":"application/x-amz-json-1.0","Content-Length":469,"x-amzn-requestid":"284a9a12-b05a-4c12-94d0-30eb80efd458","x-amz-crc32":"3479715746","Connection":"close"},"body":"{\n \"Item\": {\n \"Timezone\": {\n \"S\": \"xx\"\n },\n \"Serial\": {\n \"S\": \"xxxx\"\n },\n \"Data\": {\n \"S\": \"{\\\"Serial\\\":\\\"xxxx\\\",\\\"Name\\\":\\\"xxxx\\\",\\\"ScaleUnit\\\":\\\"AWS-IOT\\\",\\\"Variant\\\":\\\"E\\\",\\\"Version\\\":\\\"xx\\\",\\\"AutoUpdate\\\":true,\\\"NewVersionAvailable\\\":false,\\\"Provisioned\\\":true}\"\n }\n }\n}","_mode":"text"}˜
I am using the mountebank to make the request proxy to the LocalStack (an AWS emulator tool).
The behavior changed since mountebank version 2.7.0 because a more pretty printed response was responded that changes the
Content-Lengthvalue in the response header.The difference can be seen in the log part..Obviously, in mountebank v2.7.0 or onwards, The json in the response body is prettied by line break.
Can we have an option for user to choose whether to use pretty body response or not? Thanks
Expected behaviour
Print the raw string JSON in the response
...
Actual behaviour
a pretty printed JSON response was responsed
...
Steps to reproduce
Software versions used
Log contents in mb.log when running mb --loglevel debug