Skip to content

Commit ccac861

Browse files
committed
Use append to support multi-value headers
1 parent 9918911 commit ccac861

13 files changed

Lines changed: 68831 additions & 1 deletion

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function fastbootExpressMiddleware(distPath, options) {
3838
let statusMessage = result.error ? 'NOT OK ' : 'OK ';
3939

4040
for (var pair of headers.entries()) {
41-
res.set(pair[0], pair[1]);
41+
res.append(pair[0], pair[1]);
4242
}
4343

4444
if (result.error) {

test/fixtures/multivalue-headers/assets/auto-import-fastboot.js

Whitespace-only changes.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
define('~fastboot/app-factory', ['multivalue-headers/app', 'multivalue-headers/config/environment'], function(App, config) {
2+
App = App['default'];
3+
config = config['default'];
4+
5+
return {
6+
'default': function() {
7+
return App.create(config.APP);
8+
}
9+
};
10+
});
11+
12+
define("multivalue-headers/initializers/ajax", ["exports"], function (_exports) {
13+
"use strict";
14+
15+
Object.defineProperty(_exports, "__esModule", {
16+
value: true
17+
});
18+
_exports.default = void 0;
19+
const {
20+
get
21+
} = Ember;
22+
23+
var nodeAjax = function (options) {
24+
let httpRegex = /^https?:\/\//;
25+
let protocolRelativeRegex = /^\/\//;
26+
let protocol = get(this, 'fastboot.request.protocol');
27+
28+
if (protocolRelativeRegex.test(options.url)) {
29+
options.url = protocol + options.url;
30+
} else if (!httpRegex.test(options.url)) {
31+
try {
32+
options.url = protocol + '//' + get(this, 'fastboot.request.host') + options.url;
33+
} catch (fbError) {
34+
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message);
35+
}
36+
}
37+
38+
if (najax) {
39+
najax(options);
40+
} else {
41+
throw new Error('najax does not seem to be defined in your app. Did you override it via `addOrOverrideSandboxGlobals` in the fastboot server?');
42+
}
43+
};
44+
45+
var _default = {
46+
name: 'ajax-service',
47+
initialize: function (application) {
48+
application.register('ajax:node', nodeAjax, {
49+
instantiate: false
50+
});
51+
application.inject('adapter', '_ajaxRequest', 'ajax:node');
52+
application.inject('adapter', 'fastboot', 'service:fastboot');
53+
}
54+
};
55+
_exports.default = _default;
56+
});
57+
define("multivalue-headers/initializers/error-handler", ["exports"], function (_exports) {
58+
"use strict";
59+
60+
Object.defineProperty(_exports, "__esModule", {
61+
value: true
62+
});
63+
_exports.default = void 0;
64+
65+
/**
66+
* Initializer to attach an `onError` hook to your app running in fastboot. It catches any run loop
67+
* exceptions and other errors and prevents the node process from crashing.
68+
*
69+
*/
70+
var _default = {
71+
name: 'error-handler',
72+
initialize: function () {
73+
if (!Ember.onerror) {
74+
// if no onerror handler is defined, define one for fastboot environments
75+
Ember.onerror = function (err) {
76+
const errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${err.stack || err}`;
77+
console.error(errorMessage);
78+
};
79+
}
80+
}
81+
};
82+
_exports.default = _default;
83+
});//# sourceMappingURL=multivalue-headers-fastboot.map

test/fixtures/multivalue-headers/assets/multivalue-headers-fastboot.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/multivalue-headers/assets/multivalue-headers.css

Whitespace-only changes.

0 commit comments

Comments
 (0)