Skip to content

Brave-Pi/hxnodejs-http2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hxnodejs-http2

Haxe externs for Node.js HTTP/2 module.

(initially generated with ts2hx)

Example

Generating localhost-cert.pem and localhost-privkey.pem:

openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout localhost-privkey.pem -out localhost-cert.pem

Simple test:

var onRequest = Future.trigger(); // to be triggered when the first request occurs
server = js.node.Http2.createSecureServer(
	{
		cert: js.node.Fs.readFileSync('./localhost-cert.pem'),
		key: js.node.Fs.readFileSync('./localhost-privkey.pem'),
		allowHTTP1: true
	}, (req, res) -> {
		res.writeHead(200, "OK");
		res.end("<h1>Hello, World</h1>");
		res.stream.on('close', () -> onRequest.trigger(Noise)); // after the first request is finished.
		Noise;
});
server.listen(8080);
trace('Listening on port 8080');
onRequest.next(_ -> {
    server.close(); // stop listening for new connections after the first request
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages