Skip to content

Commit

Permalink
fix #156: support for multiple HTTP response headers with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Apr 23, 2012
1 parent 5fa47e9 commit 0f65ec9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/iisnode/chttpprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ HRESULT CHttpProtocol::ParseResponseHeaders(CNodeHttpStoredContext* context)
while (*(data + nameEndOffset) == ' ') // data is already zero-terminated, so this loop has sentinel value
nameEndOffset++;

CheckError(response->SetHeader(data + offset, data + nameEndOffset, valueEndOffset - nameEndOffset, TRUE));
CheckError(response->SetHeader(data + offset, data + nameEndOffset, valueEndOffset - nameEndOffset, FALSE));
}
else if ((valueEndOffset - nameEndOffset) >= 5 && 0 == memcmp((void*)(data + valueEndOffset - 5), "close", 5))
{
Expand Down
3 changes: 3 additions & 0 deletions src/iisnode/iisnode.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ copy /y $(ProjectDir)\..\config\* $(ProjectDir)\..\..\build\$(Configuration)\$(P
<None Include="..\..\test\functional\tests\119_servervars.js" />
<None Include="..\..\test\functional\tests\120_dev_errors_exception.js" />
<None Include="..\..\test\functional\tests\121_watchedFiles.js" />
<None Include="..\..\test\functional\tests\122_multipleResponseHeaders.js" />
<None Include="..\..\test\functional\tests\200_samples.bat" />
<None Include="..\..\test\functional\tests\node_modules\iisnodeassert.js" />
<None Include="..\..\test\functional\tests\parts\106_autoupdate_first.js" />
Expand Down Expand Up @@ -310,6 +311,8 @@ copy /y $(ProjectDir)\..\config\* $(ProjectDir)\..\..\build\$(Configuration)\$(P
<None Include="..\..\test\functional\www\120_dev_errors_exception\web.config" />
<None Include="..\..\test\functional\www\121_watchedFiles\hello.js" />
<None Include="..\..\test\functional\www\121_watchedFiles\web.config" />
<None Include="..\..\test\functional\www\122_multipleResponseHeaders\hello.js" />
<None Include="..\..\test\functional\www\122_multipleResponseHeaders\web.config" />
<None Include="..\..\test\performance\client.bat" />
<None Include="..\..\test\performance\localRun.bat" />
<None Include="..\..\test\performance\readme.txt" />
Expand Down
12 changes: 12 additions & 0 deletions src/iisnode/iisnode.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<Filter Include="Tests\functional\www\121_watchedFiles">
<UniqueIdentifier>{53a23746-6411-4600-8315-bc8a1b2120da}</UniqueIdentifier>
</Filter>
<Filter Include="Tests\functional\www\122_multipleResponseHeaders">
<UniqueIdentifier>{53b5e674-69d5-4bae-9629-49cd8b7c7c45}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down Expand Up @@ -576,6 +579,15 @@
<None Include="..\..\test\functional\www\121_watchedFiles\web.config">
<Filter>Tests\functional\www\121_watchedFiles</Filter>
</None>
<None Include="..\..\test\functional\www\122_multipleResponseHeaders\hello.js">
<Filter>Tests\functional\www\122_multipleResponseHeaders</Filter>
</None>
<None Include="..\..\test\functional\www\122_multipleResponseHeaders\web.config">
<Filter>Tests\functional\www\122_multipleResponseHeaders</Filter>
</None>
<None Include="..\..\test\functional\tests\122_multipleResponseHeaders.js">
<Filter>Tests\functional\tests</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="iisnode.rc" />
Expand Down
26 changes: 26 additions & 0 deletions test/functional/tests/122_multipleResponseHeaders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
A simple GET request receives a hello world response
*/

var net = require('net')
, assert = require('assert');

var timeout = setTimeout(function () {
console.error('Timeout occurred');
assert.ok(false, 'request timed out');
}, 10000);

var host = process.env.IISNODETEST_HOST || 'localhost';
var port = process.env.IISNODETEST_PORT || 31415;

var client = net.connect(port, host, function () {
client.setEncoding('utf8');
client.write('GET /122_multipleResponseHeaders/hello.js HTTP/1.1\r\nHost: ' + host + ':' + port + '\r\n\r\n');
});

client.on('data', function (data) {
clearTimeout(timeout);
assert.ok(data.indexOf('Foo: Val1') > 0, 'First instance of Foo header exists in the response');
assert.ok(data.indexOf('Foo: Val2') > 0, 'Second instance of Foo header exists in the response');
client.end();
});
6 changes: 6 additions & 0 deletions test/functional/www/122_multipleResponseHeaders/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, [['Foo','Val1'], ['Foo','Val2']]);
res.end('Hello, world!');
}).listen(process.env.PORT);
7 changes: 7 additions & 0 deletions test/functional/www/122_multipleResponseHeaders/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</configuration>

0 comments on commit 0f65ec9

Please sign in to comment.