Skip to content

error http request at headers is array #8235

@magicode

Description

@magicode
  • Version: v6.2.1
  • Platform: ubuntu 14

test case

var http = require("http");

var headersArray = [
        ['Host','echo.websocket.org'],
        ['Connection','Upgrade'],
        ['Upgrade','websocket'],
        ['Origin','http://www.websocket.org'],
    ];
var headersObj = {
        'Host':'echo.websocket.org',
        'Connection':'Upgrade',
        'Upgrade':'websocket',
        'Origin':'http://www.websocket.org'
};

var req = http.request({
    method: "GET",
    host: "echo.websocket.org" ,
    path: "ws://echo.websocket.org/?encoding=text",
    headers: headersArray
});
req.on('response',function(res){
    console.log('response' , res.headers);
});
req.on('upgrade',function(res){
    console.log('upgrade',res.headers);
});
req.end();

error output

_http_common.js:92
      (parser.outgoing._headers.upgrade === undefined ||
                               ^

TypeError: Cannot read property 'upgrade' of null
    at HTTPParser.parserOnHeadersComplete (_http_common.js:92:32)
    at Socket.socketOnData (_http_client.js:359:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions