Skip to content

Instantly share code, notes, and snippets.

@miyukki
Created December 10, 2014 07:18
Show Gist options
  • Save miyukki/53b89d3a813858a8963c to your computer and use it in GitHub Desktop.
Save miyukki/53b89d3a813858a8963c to your computer and use it in GitHub Desktop.
Bad tiny HTTP2 client
HTTP1 = "GET / HTTP/1.1\r\n" +
"Host: nghttp2.org\r\n" +
"Connection: Upgrade, HTTP2-Settings\r\n" +
"Upgrade: h2c-14\r\n" +
"HTTP2-Settings: AAMAAABkAAQAAP__\r\n" +
"Accept: */*\r\n" +
"User-Agent: tiny_client/0.0.1\r\n\r\n"
HOST = 'nghttp2.org'
PORT = 80
net = require 'net'
socket = new net.Socket
socket.connect PORT, HOST, ->
socket.write HTTP1
socket.on 'data', (buffer) ->
console.log buffer, buffer.toString()
socket.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment