Skip to content

Commit 918d8d4

Browse files
Merge pull request aspnet#22 from gregbty/master
Replace express with native node calls
2 parents e9ba747 + cda1663 commit 918d8d4

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

Microsoft.AspNet.NodeServices/Content/Node/entrypoint-http.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ var server = http.createServer(function(req, res) {
2020
if (!hasSentResult) {
2121
hasSentResult = true;
2222
if (errorValue) {
23-
res.status(500).send(errorValue);
23+
res.statusCode = 500;
24+
25+
if (errorValue.stack) {
26+
res.end(errorValue.stack);
27+
} else {
28+
res.end(errorValue.toString());
29+
}
2430
} else if (typeof successValue !== 'string') {
2531
// Arbitrary object/number/etc - JSON-serialize it
2632
res.setHeader('Content-Type', 'application/json');

Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
using System.Net;
13
using System.Net.Http;
24
using System.Text;
35
using System.Text.RegularExpressions;
@@ -29,6 +31,11 @@ public override async Task<T> Invoke<T>(NodeInvocationInfo invocationInfo) {
2931
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
3032
var response = await client.PostAsync("http://localhost:" + this._portNumber, payload);
3133
var responseString = await response.Content.ReadAsStringAsync();
34+
35+
if (response.StatusCode != HttpStatusCode.OK) {
36+
throw new Exception("Node module responded with error: " + responseString);
37+
}
38+
3239
var responseIsJson = response.Content.Headers.ContentType.MediaType == "application/json";
3340
if (responseIsJson) {
3441
return JsonConvert.DeserializeObject<T>(responseString);

0 commit comments

Comments
 (0)