Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

http2: get path throws #76

Closed
robertkowalski opened this issue May 4, 2017 · 6 comments
Closed

http2: get path throws #76

robertkowalski opened this issue May 4, 2017 · 6 comments

Comments

@robertkowalski
Copy link
Contributor

robertkowalski commented May 4, 2017

To me it looks getting the path and/or headers is broken:

internal/http2/compat.js:253
    return headers.get(constants.HTTP2_HEADER_PATH);
                  ^

TypeError: Cannot read property 'get' of undefined
    at Http2ServerRequest.get path [as path] (internal/http2/compat.js:253:19)
    at Http2Server.http2.createServer (/Users/robert/projects/http2/test/parallel/test-http2-set-cookies.js:31:18)
    at emitTwo (events.js:125:13)
    at Http2Server.emit (events.js:213:7)
    at Http2Server.onServerStream (internal/http2/compat.js:501:10)
    at emitThree (events.js:135:13)
    at Http2Server.emit (events.js:216:7)
    at Http2Session.sessionOnStream (internal/http2/core.js:1035:10)
    at emitThree (events.js:135:13)
    at Http2Session.emit (events.js:216:7)

still haven't found out if the client doesn't send a path in general or if the issue is on the server side

'use strict';
require('../common');
const assert = require('assert');
const http2 = require('http2');

const server = http2.createServer((req, res) => {
  console.log(req.path)
});
server.listen(0);

server.on('listening', function() {
  const client = http2.connect(`http://localhost:${this.address().port}`);

  const headers = { ':path': '/' };
  const req = client.request(headers).setEncoding('utf8');
});

process.on('exit', function() {
  assert.strictEqual(2, nresponses);
});

depends on #75 -- without #75 a request crashes with:

internal/http2/compat.js:282
    this[kHeaders] = linkedList.create();
                                ^

TypeError: linkedList.create is not a function
    at new Http2ServerResponse (internal/http2/compat.js:282:33)
    at Http2Server.onServerStream (internal/http2/compat.js:456:5)
    at emitThree (events.js:135:13)
    at Http2Server.emit (events.js:216:7)
    at Http2Session.sessionOnStream (internal/http2/core.js:1035:10)
    at emitThree (events.js:135:13)
    at Http2Session.emit (events.js:216:7)
    at Http2Session.onSessionHeaders [as onheaders] (internal/http2/core.js:104:11)
@jasnell
Copy link
Member

jasnell commented May 5, 2017

Ah yes, this is caused by a recent change in the linked list api over in master. Some of the functions were removed and this part of the code hadn't been updated yet to reflect those changes. We have a PR here that should fix it: #75

@robertkowalski
Copy link
Contributor Author

Sadly not, it still throws:

internal/http2/compat.js:251
    return headers.get(constants.HTTP2_HEADER_PATH);
                  ^

TypeError: Cannot read property 'get' of undefined
    at Http2ServerRequest.get path [as path] (internal/http2/compat.js:251:19)
    at Http2Server.http2.createServer (/Users/robert/projects/http2/test/parallel/test-http2-date-header.js:34:18)
    at emitTwo (events.js:125:13)
    at Http2Server.emit (events.js:213:7)
    at Http2Server.onServerStream (internal/http2/compat.js:497:10)
    at emitThree (events.js:135:13)
    at Http2Server.emit (events.js:216:7)
    at Http2Session.sessionOnStream (internal/http2/core.js:1042:10)
    at emitThree (events.js:135:13)
    at Http2Session.emit (events.js:216:7)

the same applies for req.getHeader('date'), I described it in #94

@sebdeckers
Copy link
Contributor

@robertkowalski Try #47

@robertkowalski
Copy link
Contributor Author

@sebdeckers with #47 req.headers and req.path works, but req.getHeader('date') throws:

/Users/robert/projects/http2/test/parallel/test-http2-date-header.js:37
  console.log("--->", req.getHeader('date'))
                          ^

TypeError: req.getHeader is not a function
    at Http2Server.http2.createServer (/Users/robert/projects/http2/test/parallel/test-http2-date-header.js:37:27)
    at emitTwo (events.js:125:13)
    at Http2Server.emit (events.js:213:7)
    at Http2Server.onServerStream (internal/http2/compat.js:522:10)
    at emitThree (events.js:135:13)
    at Http2Server.emit (events.js:216:7)
    at Http2Session.sessionOnStream (internal/http2/core.js:1059:10)
    at emitThree (events.js:135:13)
    at Http2Session.emit (events.js:216:7)
    at Http2Session.onSessionHeaders [as onheaders] (internal/http2/core.js:115:11)

@sebdeckers
Copy link
Contributor

Oops misread your code. Afaik request does not have a getHeader method. Most of the helper APIs for headers are only on the response object.

@robertkowalski
Copy link
Contributor Author

thanks for explaining! 👍

btw I tried #47 and it worked (except the missing header method, but that seems to be expected).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants