Skip to content

Commit

Permalink
tests: support IANA compliant header messages
Browse files Browse the repository at this point in the history
This commit allows the tests to pass when the node HTTP server uses IANA
compliant header messages rather than the messages the server used to
use. This prevents future test breakage caused by
nodejs/node#1470, a pull request tracked for
node 3.0.0 semver-major release. See:
nodejs/node@235036e

The only pertinent status code change is the 302 code, which used to be
"Moved Temporarily" but is now "Found", according to the document here:
http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
  • Loading branch information
brendanashworth committed Jul 21, 2015
1 parent 6c7a367 commit 098c5af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/res.redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('res', function(){
.set('Accept', 'text/html')
.end(function(err, res){
res.headers.should.have.property('location', 'http://google.com');
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>');
res.text.should.match(/<p>(Moved Temporarily|Found). Redirecting to <a href="http:\/\/google.com">http:\/\/google.com<\/a><\/p>/);
done();
})
})
Expand All @@ -102,7 +102,7 @@ describe('res', function(){
.set('Host', 'http://example.com')
.set('Accept', 'text/html')
.end(function(err, res){
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;</a></p>');
res.text.should.match(/<p>(Moved Temporarily|Found). Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;<\/a><\/p>/);
done();
})
})
Expand Down Expand Up @@ -136,8 +136,8 @@ describe('res', function(){
.set('Accept', 'text/plain, */*')
.end(function(err, res){
res.headers.should.have.property('location', 'http://google.com');
res.headers.should.have.property('content-length', '51');
res.text.should.equal('Moved Temporarily. Redirecting to http://google.com');
res.headers.should.have.property('content-length');
res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/google.com/);
done();
})
})
Expand All @@ -154,7 +154,7 @@ describe('res', function(){
.set('Host', 'http://example.com')
.set('Accept', 'text/plain, */*')
.end(function(err, res){
res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E');
res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/example.com\/\?param=%3Cscript%3Ealert\(%22hax%22\);%3C\/script%3E/);
done();
})
})
Expand Down

0 comments on commit 098c5af

Please sign in to comment.