Closed cristianoliveira closed 1 year ago
After a bit of debugging my suggestion wasn't correct, I believe there's something else causing this issue
hi @cristianoliveira, glad you like talkback!
I don't seem to be able to reproduce the issue. The http server should already be lower-casing all the headers.
Do you have any decorators
that might be modifying them on the tape directly?
Could you also post the full tape that gets generated?
Hey thanks for the quick answer. Hmmm Let me check. I'll try to create a demo using our implementation so I can share, or maybe I can figure out the issue by doing so š . I'll come back with an answer
Here is a demo of the issue: https://github.com/cristianoliveira/talkback-issue-demo
If you look at the saved tapes: https://github.com/cristianoliveira/talkback-issue-demo/blob/main/tapes/
The request body from both is encoded https://github.com/cristianoliveira/talkback-issue-demo/blob/main/tapes/unnamed-1.json5#L11
I was expecting it to be stored in plain JSON. Is this the expected behavior?
Thanks for the demo, that was helpful!
The problem is allowHeaders: []
, which strips the content-type
header from the request before talkback can process it.
Try allowHeaders: ['content-type']
Aha bingo! It works! I really didn't notice that! Maybe is worth adding a warning in the https://github.com/ijpiantanida/talkback#options about this behavior :)
If you feel it's a good idea I can open a PR. Anyway, thanks again!
Hello there š First of all thanks for the effort you have put into this project. We have been using it to mock our API, and its flexibility is key.
I have a bug to report tho, and I believe I found the culprit. The issue is that it isn't saving the tapes in human-readable form, which makes it a bit harder to debug them.
The issue is related to the case sensitivity of the
content-type
headers matcher (here) which I believe should be case insensitive.For instance, our SDK uses the following request to communicate with the API:
And that causes the tapes to be recorded like:
How to reproduce
Make a request using the following content type format:
Check the generated tape
Expected
{"foo": "bar"}
Outcome
Suggested fix
When checking human-readable content type, ignore the case