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

HTTP/1.1 500 Internal Server Error when visiting an SMTP imposter through the browser #43

Closed
moodmosaic opened this issue May 20, 2014 · 1 comment

Comments

@moodmosaic
Copy link
Contributor

I issue a POST request to an SMTP imposter

POST http://192.168.1.4:2525/imposters/ HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: 192.168.1.4:2525
Content-Length: 36
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

{ "port": 4547, "protocol": "smtp" }

The result is HTTP/1.1 201 Created

HTTP/1.1 201 Created
Location: http://192.168.1.4:2525/imposters/4547
content-type: application/json
content-length: 167
Date: Tue, 20 May 2014 19:40:37 GMT
Connection: keep-alive

{
  "protocol": "smtp",
  "port": 4547,
  "requests": [],
  "stubs": [],
  "_links": {
    "self": {
      "href": "http://192.168.1.4:2525/imposters/4547"
    }
  }
}

Then, I visit the Location URL with a browser (issuing a GET request - 192.168.1.4 is localhost)

GET http://192.168.1.4:2525/imposters/4547 HTTP/1.1
Host: localhost:2525
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Referer: http://localhost:2525/imposters/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

The result is HTTP/1.1 500 Internal Server Error

HTTP/1.1 500 Internal Server Error
vary: Accept
Content-Type: text/html
Content-Length: 1638
Date: Tue, 20 May 2014 19:43:46 GMT
Connection: keep-alive

TypeError: C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\src\views\imposter.ejs:9
    7| <% requests.forEach(function (request) { -%>
    8|   <pre><code>
 >> 9|     <%= request.method %> <%=request.path %> HTTP/1.1
    10| <% Object.keys(request.headers).forEach(function (name) { -%>
    11|     <%= name %>: <%= request.headers[name] %>
    12| <% }); -%>

Object.keys called on non-object
    at Function.keys (native)
    at __stack.lineno (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:31:395)
    at Array.forEach (native)
    at eval (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:31:199)
    at eval (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:33:37)
    at C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:255:15
    at Object.exports.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:293:13)
    at View.exports.renderFile [as engine] (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:323:20)
    at View.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\express\lib\view.js:76:8)
    at Function.app.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\express\lib\application.js:502:10)
@bbyars bbyars added the bug label May 21, 2014
@bbyars
Copy link
Owner

bbyars commented Jan 2, 2015

This has been fixed. I still have plans to build a more robust UI for navigating the API as well.

@bbyars bbyars closed this as completed Jan 2, 2015
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

2 participants