ch41

ch41

React is an operating system.

Member Since 7 years ago

Experience Points
27
follower
Lessons Completed
161
follow
Lessons Completed
289
stars
Best Reply Awards
86
repos

407 contributions in the last year

Pinned
⚡ promise A+
⚡ nodejs api 文档
⚡ Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:
⚡ Command-line utility for managing your /etc/hosts file built with rust
Activity
Nov
26
1 week ago
started
started time in 1 week ago
Nov
23
2 weeks ago
Nov
20
2 weeks ago
started
started time in 2 weeks ago
Nov
16
3 weeks ago
Nov
14
3 weeks ago
Nov
13
3 weeks ago
started
started time in 3 weeks ago
Nov
9
4 weeks ago
Nov
7
1 month ago
started
started time in 4 weeks ago
Nov
6
1 month ago
Nov
5
1 month ago
Activity icon
issue

ch41 issue comment denoland/deno

ch41
ch41

Headers are wrongly formatted when printed

// test.ts

import { Status } from "https://deno.land/[email protected]/http/http_status.ts";
import { listenAndServe } from "https://deno.land/[email protected]/http/server.ts";

const HOST_ADDR = "localhost:3000";

async function handle_req(req : Request) : Promise<Response>
{
  if (req.url == `http://${HOST_ADDR}/ws`)
  {
    console.log(req);

    const { response: res } = Deno.upgradeWebSocket(req);

    console.log(res);

    return (res);
  }
  else
  {
    return (new Response(null, { status: Status.NotFound }));
  }
}

listenAndServe(HOST_ADDR, handle_req);

new WebSocket(`ws://${HOST_ADDR}/ws`);
deno run --allow-net test.ts
// output

`
Request {
  bodyUsed: false,
  headers: Headers {
  connection: "Upgrade",
  host: "localhost:3000",
  "sec-websocket-key": "yygneBrE9K1PTv+dGAy8QQ==",
  "sec-websocket-version": "13",
  upgrade: "websocket",
  "user-agent": "Deno/1.15.2"
},
  method: "GET",
  redirect: "follow",
  url: "http://localhost:3000/ws"
}
Response {
  body: null,
  bodyUsed: false,
  headers: Headers {
  connection: "Upgrade",
  "sec-websocket-accept": "tjfvylMXdNwRgOWna4mAPOG4HNg=",
  upgrade: "websocket"
},
  ok: false,
  redirected: false,
  status: 101,
  statusText: "",
  url: ""
}
`
started
started time in 1 month ago
Activity icon
issue

ch41 issue comment denoland/deno

ch41
ch41

Headers are wrongly formatted when printed

// test.ts

import { Status } from "https://deno.land/[email protected]/http/http_status.ts";
import { listenAndServe } from "https://deno.land/[email protected]/http/server.ts";

const HOST_ADDR = "localhost:3000";

async function handle_req(req : Request) : Promise<Response>
{
  if (req.url == `http://${HOST_ADDR}/ws`)
  {
    console.log(req);

    const { response: res } = Deno.upgradeWebSocket(req);

    console.log(res);

    return (res);
  }
  else
  {
    return (new Response(null, { status: Status.NotFound }));
  }
}

listenAndServe(HOST_ADDR, handle_req);

new WebSocket(`ws://${HOST_ADDR}/ws`);
deno run --allow-net test.ts
// output

`
Request {
  bodyUsed: false,
  headers: Headers {
  connection: "Upgrade",
  host: "localhost:3000",
  "sec-websocket-key": "yygneBrE9K1PTv+dGAy8QQ==",
  "sec-websocket-version": "13",
  upgrade: "websocket",
  "user-agent": "Deno/1.15.2"
},
  method: "GET",
  redirect: "follow",
  url: "http://localhost:3000/ws"
}
Response {
  body: null,
  bodyUsed: false,
  headers: Headers {
  connection: "Upgrade",
  "sec-websocket-accept": "tjfvylMXdNwRgOWna4mAPOG4HNg=",
  upgrade: "websocket"
},
  ok: false,
  redirected: false,
  status: 101,
  statusText: "",
  url: ""
}
`
Previous