@fuman/net 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fuman/net",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "description": "experimental network abstractions",
6
6
  "license": "MIT",
7
7
  "scripts": {},
8
8
  "dependencies": {
9
- "@fuman/io": "^0.0.8",
10
- "@fuman/utils": "^0.0.4"
9
+ "@fuman/io": "^0.0.10",
10
+ "@fuman/utils": "^0.0.10"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
@@ -4,13 +4,14 @@ const io = require("@fuman/io");
4
4
  const utils = require("@fuman/utils");
5
5
  const _protocol = require("./_protocol.cjs");
6
6
  const types = require("./types.cjs");
7
+ const HTTP1_0_OK = /* @__PURE__ */ utils.utf8.encoder.encode("HTTP/1.0 200");
7
8
  const HTTP1_1_OK = /* @__PURE__ */ utils.utf8.encoder.encode("HTTP/1.1 200");
8
9
  const CR = /* @__PURE__ */ "\r".charCodeAt(0);
9
10
  const LF = /* @__PURE__ */ "\n".charCodeAt(0);
10
11
  async function performHttpProxyHandshake(reader, writer, proxy, destination) {
11
12
  await writer.write(_protocol.buildConnectRequest(proxy, destination));
12
13
  const res1 = await io.read.async.exactly(reader, 12);
13
- if (!utils.typed.equal(res1, HTTP1_1_OK)) {
14
+ if (!utils.typed.equal(res1, HTTP1_0_OK) && !utils.typed.equal(res1, HTTP1_1_OK)) {
14
15
  throw new types.HttpProxyConnectionError(
15
16
  proxy,
16
17
  `Invalid HTTP response: ${utils.utf8.decoder.decode(res1)}`
@@ -2,13 +2,14 @@ import { read } from "@fuman/io";
2
2
  import { typed, utf8, u8 } from "@fuman/utils";
3
3
  import { buildConnectRequest } from "./_protocol.js";
4
4
  import { HttpProxyConnectionError } from "./types.js";
5
+ const HTTP1_0_OK = /* @__PURE__ */ utf8.encoder.encode("HTTP/1.0 200");
5
6
  const HTTP1_1_OK = /* @__PURE__ */ utf8.encoder.encode("HTTP/1.1 200");
6
7
  const CR = /* @__PURE__ */ "\r".charCodeAt(0);
7
8
  const LF = /* @__PURE__ */ "\n".charCodeAt(0);
8
9
  async function performHttpProxyHandshake(reader, writer, proxy, destination) {
9
10
  await writer.write(buildConnectRequest(proxy, destination));
10
11
  const res1 = await read.async.exactly(reader, 12);
11
- if (!typed.equal(res1, HTTP1_1_OK)) {
12
+ if (!typed.equal(res1, HTTP1_0_OK) && !typed.equal(res1, HTTP1_1_OK)) {
12
13
  throw new HttpProxyConnectionError(
13
14
  proxy,
14
15
  `Invalid HTTP response: ${utf8.decoder.decode(res1)}`