Skip to content

difference between http2 Compatibility API and http #20060

Closed
@xxoo

Description

  • Version: 9.11.1
  • Platform: macos
  • Subsystem:
let http2 = require('http2');
let http = require('http');
http2.createSecureServer({
	allowHTTP1: true,
	cert: `-----BEGIN CERTIFICATE-----
MIICpDCCAYwCCQDchnaEFAYYfzANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAls
b2NhbGhvc3QwHhcNMTcxMTExMjA1NjQ2WhcNMTcxMjExMjA1NjQ2WjAUMRIwEAYD
VQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDP
CdzfoRXMW4rHYSXqR+exh9PfHkGFe7wF0yT5gPVgt6FdSMsYxbDjE6R3zfKSNSAq
mJfsiN1GRfMmO+tv6Ddvy5J/q9tAJmUxqsWcpe7aOAnWnwXNJSFoawjU2HPmKHzb
+vAYECKwWB9WJvztQrBN6WJnJCo1ffVq6qTEb1NiP0CXW/J8DgymmzP7gKTiSnFy
dTnE2OOSx98ZG/YORGTX1w58mzFRkeIG1BAm3NB6jN4RGNaQoIyAPfInutlUbBSs
2dDrclBdw1gjIFGmPtEL15zEqhxuckCSkM1cJWCnm805ZoqNB7/PxpXrPVOVttiL
uj3B31JYCCpr/fFWpuJ9AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAExF+pAYc0Kq
ejSiNxu4Ae5T5XLXOCFSGHRjHwE/Wpud0SqJIrLAAm6VfyU/MDvEIUlwfnHaHpyL
/j+1JNCLlMPcCY81k3CM3FrgnYit9ImU9ni3DU+c23zdMrkiF1bgQZBdbg2gzqgy
8yq2Ws72a6i0S8odCQ4/inCall3D9c64sefE9LocLTEBrTQDYp+bg6+RX7QKdmE6
6dkYm4oQOeB1lb0IdV+YSKz/bkypFPA0KY5dtpsoPK8TpwwUzg9cbnvXo0gKMbR3
qY8JmgsajfMbbynqR88kFHbtHOISC/XtmlObxSA+CqCKrI+f9ljc+wADPkF+rqxX
Gs1T2qkuJ6g=
-----END CER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
emMBfMy0t4i+8tZTT0UdYgVICsbZQSO/8L0LcEkGVfmRgJPrUhDw9o9AeD2YLnXM
7d9mBCD/sQKBgQDxhf6BLQFpKWXIFsLGmrhRLedvjqyXUzswDfIcCqKmwzUGM8zU
iP0Kl3cfwTuL1p+/xQZnPdHzSZmn/oTR9+iiThJ0y9ogQ1Vl95ES0bdfIb+PJkOn
SjukeN+H198xuz/oPncVSPULB+AYXz/0lpBMHNTbBiF63AuwZ/HUEpajxQKBgH8f
z1rQYbQaZSZ3eVXxgPEcYGRiQVpgh9Qf38SBl40TuXF7FHtSEB0NIEutl3IbvpHO
ml/wn1QGVgQZcaJt94F5IQjEy/gmWj7MYV8cpgsDsArggCQUgr97Jq4x4gI5aQ3f
215vhE/7Ni9CFcHOww0gYwJZUZ+Y9n7DJIvBhQvRAoGBAP68uVfOB7oVV3z9K6G+
oJHntre6Za8deemnksM/5H4/k4Kedl+RIMExhLsAypaP0aIZPW29Mwv3eT19ciUm
g6KrdhUNWvbNhryyg//VYnDLQi0FnGr+oZDQNhGxNdWXjxOBBTVxe4Z16CEDgIXI
Pwz9a9ZgvBd2si5/cMwM6aOe
-----END PRIVATE KEY-----`
}, onmessage).listen(1234);
http.createServer(onmessage).listen(5678);

function onmessage(req, res){
	if (req.method === 'GET') {
		res.writeHead(200, {
			'content-type': 'text/html'
		});
		res.end(`<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
		<meta name="format-detection" content="telephone=no"/>
		<title>fusion-backend</title>
	</head>
	<body>welcome
		<input type="file"/>
		<script>
			document.querySelector('input').addEventListener('change', function() {
				if (this.files.length) {
					let x = new XMLHttpRequest();
					x.open('put', '/images/' + this.files[0].name, true);
					x.onreadystatechange = function() {
						if (this.readyState === 4 && this.status === 200) {
							alert(this.responseText);
						}
					};
					x.send(this.files[0]);
					this.value = '';
				}
			});
		</script>
	</body>
</html>`);
	} else {
		res.writeHead(405);
		res.end();
	}
}

choose a file bigger then 100k you'll see http1 returns 405 immediately, but http2 never return any thing.

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions