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

http2: client round 1 - #43

Closed
mcollina wants to merge 1 commit into
masterfrom
client
Closed

mcollina wants to merge 1 commit into
masterfrom
client

Conversation

@mcollina

Copy link
Copy Markdown
Member

@jasnell this is not working, I suspect it is not sending anything on the wire in fact.

@mcollina
mcollina requested a review from jasnell February 22, 2017 09:13
jasnell

This comment was marked as off-topic.

@mcollina

Copy link
Copy Markdown
Member Author

@jasnell updated with kProceed.

@jasnell

jasnell commented Feb 24, 2017

Copy link
Copy Markdown
Member

+1... I started digging in yesterday then completely ran out of time to finish. Hoping to return to it this afternoon.

jasnell

This comment was marked as off-topic.

@jasnell

jasnell commented Mar 1, 2017

Copy link
Copy Markdown
Member

Ok, looks like there's a conflict with the change in node_http2.cc that needs to be looked at following @addaleax's refactor that landed yesterday. I'll look at resolving that in just a bit

@mcollina

mcollina commented Mar 1, 2017

Copy link
Copy Markdown
Member Author

@jasnell this is not working ATM. You can check out the branch as it is and let me know what the problem is.

This is my current client, and it's not working :(:

'use strict'

const net = require('net');
const h2 = require('http2');

const socket = net.connect(8000, 'localhost');
const client = h2.createClientSession(socket);

const req = client.request();

socket.on('connect', function () {
  console.log('socket connected');
});

req.on('response', function (headers) {
  console.log('response!', headers)
})

let data = '';
req.setEncoding('utf8');
req.on('data', console.log);

@jasnell

jasnell commented Mar 1, 2017 •

Copy link
Copy Markdown
Member

Yeah, I've applied the patch locally and will be going through it in detail again here shortly. Hoping to have it working by the time we meet up in Seattle

@jasnell

jasnell commented Mar 1, 2017

Copy link
Copy Markdown
Member

Here's the "working" client

'use strict'

const common = require('../common');
const assert = require('assert');
const h2 = require('http2');
const net = require('net');
const body =
  '<html><head></head><body><h1>this is some data</h2></body></html>';

const server = h2.createServer();

server.on('stream', common.mustCall(onStream));

function onStream (stream) {
  stream.respond({
    'content-type': 'text/html',
    ':status': 200
  })
  stream.end(body);
}

server.listen(0);

server.on('listening', common.mustCall(function() {
  const socket = net.connect(this.address());
  const client = h2.createClientSession(socket);

  setImmediate(() => {
    const headers = {
      ':method': 'GET',
      ':scheme': 'http',
      ':authority': `localhost:${this.address().port}`,
      ':path': '/'
    };

    const req = client.request(headers);

    req.on('response', common.mustCall(function (headers) {
      console.log('response!', headers)
    }))

    let data = '';
    req.setEncoding('utf8');
    req.on('data', d => data += d);
    req.on('end', common.mustCall(function () {
      assert.strictEqual(body, data);
    }));
    req.end();
  });

}));

Also, in core.js, createClientSession, send the client settings in setImmediate:

  setImmediate(() => session.submitSettings(settings));

@mcollina
mcollina force-pushed the client branch 2 times, most recently from 992750c to 8ece24e Compare March 2, 2017 00:27
@mcollina

mcollina commented Mar 2, 2017

Copy link
Copy Markdown
Member Author

that's progress!
I've updated the test and it is almost passing, but it's giving me a:

Assertion failed: (handle->ready_callbacks_head == nullptr), function nghttp2_session_free, file ../src/node-http2-core-inl.h, line 845.
Abort trap: 6

I'll work on it later on.

@mcollina

mcollina commented Mar 4, 2017

Copy link
Copy Markdown
Member Author

@jasnell this is ready to go. The test is green with a bunch of TODO!

@jasnell

jasnell commented Mar 4, 2017

Copy link
Copy Markdown
Member

Landed!

@jasnell jasnell closed this Mar 4, 2017
@mcollina
mcollina deleted the client branch March 4, 2017 16:20
@mcollina mcollina mentioned this pull request Mar 4, 2017
30 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants