mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-12 05:20:35 +01:00
Dynamic Body not to be cached when a Func is used to created the body #459
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @paulmctigue on GitHub (Oct 4, 2022).
Originally assigned to: @StefH on GitHub.
I'm using wirenet.net as a standalone process. The response func code below loads an existing file from disk, mutates the string and return it to the user. In my case it mutates all the dates relative to the todays date.
Because it a dynamics response I don't want the response to be cached. Currently (version 1.5.6), I think, the behaviour is caching the response every time its invoked increasing the memory on each request.
@StefH commented on GitHub (Oct 11, 2022):
I'm not sure if there is caching when you use a Func to define your response.
Caching can only be enabled for
WithBodyFromFile.Can you please double check?
@StefH commented on GitHub (Oct 13, 2022):
@paulmctigue
I did add a extra unit test: https://github.com/WireMock-Net/WireMock.Net/pull/828 which shows that it works correct.
@paulmctigue commented on GitHub (Oct 14, 2022):
@StefH It always returns the correct response string for the request. That bit is fine. However memory is increased for each new string that is returned. I'll double check it now
@StefH commented on GitHub (Oct 14, 2022):
Yes I can understand that the memory is increased because the return value from that Func is a string, and this is saved internally.
However I think that this is only kept in memory for logging the request. So cleaning the logging could help, or I can investigate if in case it's a Func, the response is not saved to the logging.
@paulmctigue commented on GitHub (Oct 14, 2022):
Yes its the log entries that are consuming the memory - this object WireMock.Util.BodyData.
I didn't see DeleteLogEntry method.
This solves the issue.
@paulmctigue commented on GitHub (Oct 14, 2022):
Maybe have a global setting to opt of this type of logging when setting up the server (in WireMockServerSettings).
Is the internal logging separate for the general logging because using WireMockNullLogger wouldn't help in this circumstance?
@StefH commented on GitHub (Oct 14, 2022):
Yes a good idea.
I'll see if this can be added, however, it will take some time because I first want merge some other PR's.
@StefH commented on GitHub (Oct 15, 2022):
@paulmctigue
You can now opt-out using
DoNotSaveDynamicResponseInLogEntry=truePreview version :
1.5.7-ci-16532https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@paulmctigue commented on GitHub (Oct 17, 2022):
@StefH
Tested this and the memory kept on increasing.
Are there log entries for request as well as responses?
@StefH commented on GitHub (Oct 17, 2022):
A log entry defines the request AND the response.
So the memory will increase, but not as much as before (in case you had big xml-strings to return).
If you do not want log entries at all, you can set the
MaxRequestLogCountto0in the settings.@StefH commented on GitHub (Oct 18, 2022):
@paulmctigue
Is the explanation sufficient?
@StefH commented on GitHub (Oct 21, 2022):
merged