Merge pull request #29 from bitinn/new-release

New release
This commit is contained in:
David Frank 2015-07-11 19:44:26 +08:00
commit 1c67d40567
4 changed files with 21 additions and 22 deletions

View File

@ -5,9 +5,13 @@ Changelog
# 1.x release
## v1.3.0 (master)
## v1.3.1 (master)
- Enhance: now fetch.Request is exposed as well.
- Enhance: allow custom host header to be set (server-side only feature, as it's a forbidden header on client-side)
## v1.3.0
- Enhance: now fetch.Request is exposed as well
## v1.2.1

View File

@ -79,7 +79,7 @@ function Fetch(url, opts) {
options.headers = headers.raw();
// HACK: headers.host must be a string, cannot be an array otherwise get error undefined is not a function
// http.request only support string as host header, this hack make custom host header possible
if (options.headers.host) {
options.headers.host = options.headers.host[0];
}

View File

@ -244,10 +244,4 @@ TestServer.prototype.router = function(req, res) {
});
}
if (p === '/host') {
res.statusCode = 200;
res.setHeader('Fetch-Sent-Host', req.headers.host);
res.end();
}
}

View File

@ -161,6 +161,20 @@ describe('node-fetch', function() {
});
});
it('should accept custom host header', function() {
url = base + '/inspect';
opts = {
headers: {
host: 'example.com'
}
};
return fetch(url, opts).then(function(res) {
return res.json();
}).then(function(res) {
expect(res.headers['host']).to.equal('example.com');
});
});
it('should follow redirect code 301', function() {
url = base + '/redirect/301';
return fetch(url).then(function(res) {
@ -752,17 +766,4 @@ describe('node-fetch', function() {
});
});
it('should allow setting of custom host', function() {
url = base + '/host';
opts = {
method: 'HEAD',
headers: {
host: 'bitinn.net'
}
};
return fetch(url, opts).then(function(res) {
expect(res.headers.get('fetch-sent-host')).to.equal('bitinn.net');
});
});
});