-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Description
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
Expected behaviour
Print the raw string JSON in the response
...
Actual behaviour
a pretty printed JSON response was responsed
...
Steps to reproduce
- Run the below docker compose
services:
localstack:
image: localstack/localstack:3.8.1-arm64
container_name: localstack
healthcheck:
retries: 3
environment:
SERVICES: dynamodb
LS_LOG: trace
ports:
- 4566:4566
- 4572:4572
mountebank:
# image: bbyars/mountebank:2.6.0
image: bbyars/mountebank:2.7.0
container_name: mountebank
ports:
- 2525:2525
- 8080:8080
volumes:
- ./imposters.ejs:/mountebank/imposters.ejs
entrypoint:
- mb
- --configfile
- /mountebank/imposters.ejs
- --allowInjection
- --loglevel
- debug
...
with imposter
``` json
{
"imposters": [
{
"port": 8080,
"protocol": "http",
"name": "S3 Proxy",
"stubs": [
{
"responses": [
{
"proxy": {
"to": "http://localstack:4566",
"mode": "proxyAlways"
}
}
]
}
]
}
]
}
- Make a request using AWS .NET SDK
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;
}
- An error throws that indicates the CRC value diffs
System.IO.IOException: CRC value returned with response does not match the computed CRC value for the returned response body.
Software versions used
OS : MacOS
mountebank : 2.7.0
node.js : v22.1.0
(only if installed via npm)
Installation method :
(npm, zip, tar, pkg, deb, rpm)
Log contents in mb.log when running mb --loglevel debug
// 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"}˜
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels