Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

feat: http2 support #9

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

feat: http2 support #9

wants to merge 3 commits into from

Conversation

climba03003
Copy link
Member

@Uzlopak Sorry for duplication, but it should be how I would like to implement the http2 with native solution.

It still missing test for http2.

Checklist

lib/support.js Show resolved Hide resolved
Co-authored-by: Uzlopak <aras.abbasi@googlemail.com>
@@ -0,0 +1,18 @@
// TODO: remove after node@18 End-of-Life
'use strict'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt it maybe faster if we do it like this?

'use strict'

const status = { ':status': '103' }

function writeEarlyHints (reply, headers) {
  return new Promise(function (resolve) {
    if (reply.raw.socket === null) {
      resolve()
      return
    }
    Object.assign(headers, status)
    reply.raw.stream.additionalHeaders(headers)
    resolve()
  })
}

module.exports = writeEarlyHints

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should resolve after the headers are added.
Not directly resolved.


function write (reply, headers) {
let message = ''
for (const key of Object.keys(headers)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid the value variable.

  for (const key of Object.keys(headers)) {
    if (Array.isArray(headers[key])) {
      message += `${key}: ${headers[key].join(', ')}${CRLF}`
    } else {
      message += `${key}: ${headers[key]}${CRLF}`
    }
  }

How is the performance of for-of-loops?

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