Skip to content

Commit 098c5af

Browse files
tests: support IANA compliant header messages
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
1 parent 6c7a367 commit 098c5af

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/res.redirect.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('res', function(){
8585
.set('Accept', 'text/html')
8686
.end(function(err, res){
8787
res.headers.should.have.property('location', 'http://google.com');
88-
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>');
88+
res.text.should.match(/<p>(Moved Temporarily|Found). Redirecting to <a href="http:\/\/google.com">http:\/\/google.com<\/a><\/p>/);
8989
done();
9090
})
9191
})
@@ -102,7 +102,7 @@ describe('res', function(){
102102
.set('Host', 'http://example.com')
103103
.set('Accept', 'text/html')
104104
.end(function(err, res){
105-
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;</a></p>');
105+
res.text.should.match(/<p>(Moved Temporarily|Found). Redirecting to <a href="&lt;lame&gt;">&lt;lame&gt;<\/a><\/p>/);
106106
done();
107107
})
108108
})
@@ -136,8 +136,8 @@ describe('res', function(){
136136
.set('Accept', 'text/plain, */*')
137137
.end(function(err, res){
138138
res.headers.should.have.property('location', 'http://google.com');
139-
res.headers.should.have.property('content-length', '51');
140-
res.text.should.equal('Moved Temporarily. Redirecting to http://google.com');
139+
res.headers.should.have.property('content-length');
140+
res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/google.com/);
141141
done();
142142
})
143143
})
@@ -154,7 +154,7 @@ describe('res', function(){
154154
.set('Host', 'http://example.com')
155155
.set('Accept', 'text/plain, */*')
156156
.end(function(err, res){
157-
res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E');
157+
res.text.should.match(/(Moved Temporarily|Found). Redirecting to http:\/\/example.com\/\?param=%3Cscript%3Ealert\(%22hax%22\);%3C\/script%3E/);
158158
done();
159159
})
160160
})

0 commit comments

Comments
 (0)