Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: expose websocket in nodehttp #53721

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4083955
http: expose websockets
anfibiacreativa Jul 4, 2024
9dd678b
test: add test for exposing websocket in http
anfibiacreativa Jul 4, 2024
a2e4f84
http: add dynamic loading on first usage
anfibiacreativa Jul 4, 2024
0d5d120
test: extend test to compare strict with global
anfibiacreativa Jul 4, 2024
e4b6558
http: refactor to lazyload classes more effectively
anfibiacreativa Jul 4, 2024
576bdb0
test: update test/parallel/test-http-import-websocket.js
anfibiacreativa Jul 4, 2024
ecfd5ec
http: refactor lazy loading function
anfibiacreativa Jul 4, 2024
9b65b5b
docs: add websocket reference to http doc
anfibiacreativa Jul 5, 2024
804276c
fix: fix linting errors from ci
anfibiacreativa Jul 5, 2024
6e1cb1d
http: prevent global override
anfibiacreativa Jul 6, 2024
a9c915e
docs: put placeholder version
anfibiacreativa Jul 6, 2024
c80014b
http: add return in scope
anfibiacreativa Jul 6, 2024
b529947
docs: fix linter errors
anfibiacreativa Jul 6, 2024
29e1861
http: update with suggestion to rename var
anfibiacreativa Jul 6, 2024
067782d
http: update return accordingly
anfibiacreativa Jul 6, 2024
fc9a869
docs: remove escaping
anfibiacreativa Jul 6, 2024
9aa63b0
docs: add link at the bottom of the page
anfibiacreativa Jul 6, 2024
20789fb
fix: fix linter docs
anfibiacreativa Jul 6, 2024
b5e0931
http: revert suggestion to fix errors
anfibiacreativa Jul 6, 2024
d3df897
fix: revert broken link
anfibiacreativa Jul 6, 2024
4d5f180
http: import all unidici in the lazy function
anfibiacreativa Jul 7, 2024
0c2c82b
http: remove additional export
anfibiacreativa Jul 8, 2024
aeed701
http: remove unnecessary declaration that was used in module.exports
anfibiacreativa Jul 8, 2024
7209a89
http: replace ternary
anfibiacreativa Jul 8, 2024
c928a97
http: rename function
anfibiacreativa Jul 8, 2024
cf3e9a7
http: rename function invocation
anfibiacreativa Jul 8, 2024
5ca86a1
http: fix typo in name function
anfibiacreativa Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
ObjectDefineProperty,
} = primordials;

const { CloseEvent, WebSocket, MessageEvent } = require('internal/deps/undici/undici');
anfibiacreativa marked this conversation as resolved.
Show resolved Hide resolved
const { validateInteger } = require('internal/validators');
const httpAgent = require('_http_agent');
const { ClientRequest } = require('_http_client');
Expand Down Expand Up @@ -126,6 +127,9 @@ module.exports = {
OutgoingMessage,
Server,
ServerResponse,
WebSocket,
MessageEvent,
CloseEvent,
anfibiacreativa marked this conversation as resolved.
Show resolved Hide resolved
createServer,
validateHeaderName,
validateHeaderValue,
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-http-import-websocket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

Check failure on line 1 in test/parallel/test-http-import-websocket.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Mandatory module "common" must be loaded

Check failure on line 1 in test/parallel/test-http-import-websocket.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Mandatory module "common" must be loaded before any other modules

const assert = require('assert');
const { CloseEvent, WebSocket, MessageEvent } = require('node:http');

assert.strictEqual(typeof WebSocket, 'function');
assert.strictEqual(typeof CloseEvent, 'function');
assert.strictEqual(typeof MessageEvent, 'function');

Check failure on line 9 in test/parallel/test-http-import-websocket.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Too many blank lines at the end of file. Max of 0 allowed
Loading