Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow mountebank to send back statusMesage #746

Open
clickthisnick opened this issue Dec 14, 2023 · 0 comments
Open

[Feature Request] Allow mountebank to send back statusMesage #746

clickthisnick opened this issue Dec 14, 2023 · 0 comments

Comments

@clickthisnick
Copy link

clickthisnick commented Dec 14, 2023

Expected behaviour

I was hoping I could add a statusMessage in the response body:

    "responses": [
        {
            "headers": {
                "Content-Type": "application/json"
            },
            "statusMessage": "foobar",
            "is": {
                "body": {
                    "foo": "bar
                    },
....

Which in turn in mountebank would essentially do:

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, "STATUS MESSAGE", {'Content-Type': 'text/plain'});
    res.write('Hello World!');
    res.end();
}).listen(8080);

Actual behaviour

I have a service that I don't own and have no control over that uses the statusMessage (also called reason phrases) to communicate information that is critical to take action on.

An example is wget https://example.com in my scenario would return:

HTTP request sent, awaiting response... 503 up

503 is the statusCode

up is the statusMessage

I need to be able to mock this statusMessage with mountebank as the "up" message is necessary to do certain actions on.

Mountebank uses writeHead from node
https://github.com/nodejs/node/blob/99f6084ef04dd868c7b894ca0fdbb5088773ca6c/lib/_http_server.js#L341-L365

Here:

response.writeHead(stubResponse.statusCode, stubResponse.headers);

Looking into the nodejs http code we can see statusMessage is an optional argument that defaults what we normally see as the message (but it is overridable).

Steps to reproduce

There's no current way to mock the statusMessage

Software versions used

OS         :
mountebank :
node.js    :
  (only if installed via npm)
Installation method :
  (npm, zip, tar, pkg, deb, rpm)

mountebank latest

Log contents in mb.log when running mb --loglevel debug

Log contents here

No logs as its not compatible with the code if I'm groking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant