Skip to content

Instantly share code, notes, and snippets.

@webcarrot
webcarrot / SocketProxy.js
Last active May 28, 2018 09:34
nodejs http2 pre-read connection stream wrapper
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _stream = require("stream");
const kWait = Symbol("wait");
const kNread = Symbol("nread");
@webcarrot
webcarrot / PlainHttp2.js
Created May 28, 2018 08:53
PlainHttp2 server that make pseudo ALPN negotiation
"use strict";
import http2 from "http2";
import SocketProxy from "./SocketProxy";
const Http2Server = http2.createServer().constructor;
// HTTP2 preface from node-spdy
const PREFACE_BUFFER = Buffer.from("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");
const PREFACE_BUFFER_LENGTH = PREFACE_BUFFER.length;
@webcarrot
webcarrot / proxyWrap.js
Created May 28, 2018 08:59
nodejs haproxy PROXY v1/v2 server class wrapper
/*
* simple proxywrap - only plain mode
*
* BASE ON: node-proxywrap
*
* Copyright (c) 2013, Josh Dague
* Copyright (c) 2018, webcarrot
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@webcarrot
webcarrot / base+polyfill.html
Last active September 7, 2018 13:29
Test __proto__ in babel 7: preset-env: ie9 + @babel/plugin-proposal-class-properties
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script>
(function(O, F) {
"use strict";