Comments (8)
Hey - sorry for the late reply to this. http.ts
is only half-implemented, as you can tell. It needs someone (probably me) to dig in and complete it. Help welcome - but otherwise you'll have to wait a few weeks. Ultimately we'll probably use a native http parser - this was added so we can benchmark what sort of overhead parsing in pure JS has (also just as some example code for people to look at)
from deno_std.
When using a browser to access, 2 requests were sent at the same time
GET / HTTP/1.1
GET /favicon.ico HTTP/1.1
For some reason (probably a bug), deno has not received EOF
, cause Conn to not close. When using curl, can always receive EOF
, so c.close() has been invoked.
from deno_std.
Works in Firefox for me. Does not work in curl or wrk for me.
from deno_std.
It works in Chrome for me, but not in curl.
Steps to reproduce:
- deno http_test.ts
- curl http://127.0.0.1:8090 (you get a response)
- open Chrome, access http://127.0.0.1:8090 (you get a response)
- curl http://127.0.0.1:8090 (no response!)
from deno_std.
This server may only accept one link from a user agent.
-
deno http_test.ts -D
... listening on http://0.0.0.0:8000/ Deno requests network access to "listen". Grant? [yN] y DEBUG RS - msg_from_js Listen sync true DEBUG RS - resource lookup 3 DEBUG RS - msg_from_js Accept sync false
-
open Chrome, visit
DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 0 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Read sync false DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 0 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Write sync false DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Read sync false DEBUG RS - loop process - 1 events, 0.000s
-
refresh it
DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 0 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Write sync false DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Read sync false DEBUG RS - loop process - 1 events, 0.000s
-
open Firefox, visit
DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 0 events, 0.000s
The program is suspended.
-
refresh the webpage in Chrome again
DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 0 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Write sync false DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - msg_from_js Read sync false DEBUG RS - loop process - 1 events, 0.000s
It still works.
-
Waiting for a long time
DEBUG RS - loop process - 1 events, 0.000s DEBUG RS - resource lookup 4 DEBUG RS - dropping I/O source: 1 DEBUG RS - loop process - 0 events, 0.000s DEBUG RS - msg_from_js Close sync true ConnectionAborted: 你的主机中的软件中止了一个已建立的连接。 (os error 10053) at maybeError (deno/js/errors.ts:38:12) at handleAsyncMsgFromRust (deno/js/dispatch.ts:27:17)
My system is Chinese, so the error message is also Chinese. I don't know what the English information is. I will simply translate it:
你的主机中的软件中止了一个已建立的连接。
The software in your host has aborted an established connection.
from deno_std.
@justjavac try curl http://127.0.0.1:8090/ & curl http://127.0.0.1:8090/favicon.ico
from deno_std.
I add some log-code, in Chrome, c.close() has indeed NOT been invoked, and listener.accept() has NOT been invoked too.
Maybe Chrome uses a socket connection pool, both requests use the same socket.
I generate a NetLog dump file.
url http://127.0.0.1:8000
:
...
t=1007 [st=0] +SOCKET_POOL [dt=1]
t=1008 [st=1] SOCKET_POOL_BOUND_TO_CONNECT_JOB
--> source_dependency = 55197 (TRANSPORT_CONNECT_JOB)
t=1008 [st=1] SOCKET_POOL_BOUND_TO_SOCKET
--> source_dependency = 55198 (SOCKET)
...
url http://127.0.0.1:8000//favicon.ico
:
t=1064 [st=0] +SOCKET_POOL [dt=0]
t=1064 [st=0] SOCKET_POOL_REUSED_AN_EXISTING_SOCKET <--- HERE
--> idle_ms = 53
t=1064 [st=0] SOCKET_POOL_BOUND_TO_SOCKET
--> source_dependency = 55198 (SOCKET)
SOCKET_POOL_REUSED_AN_EXISTING_SOCKET.
I tried curl -H 'Connection: keep-alive'
, but there is no such error like Chrome.
from deno_std.
@justjavac u are right.
when i use browser access the url, the connection cannot be closed properly.
the following code seems to be working fine
import { serveConn } from './net/http'
import { listen } from 'deno'
;(async () => {
const addr = '0.0.0.0:8000'
const listener = listen('tcp', addr)
console.log('listening on', addr)
while (true) {
const conn = await listener.accept()
const res = await serveConn(conn).next()
await res.value.respond({ body: new TextEncoder().encode('Hello\n') })
conn.close()
}
})()
from deno_std.
Related Issues (20)
- bug: `parseRange()` returns unexpected result HOT 1
- todo: fix tests after workspaces migration script is run HOT 1
- snapshot testing fails with Deno v1.40.5 when stdout is terminal HOT 2
- Fix test failures after running `_tools/convert_to_workspace.ts` HOT 2
- [Streams] Add CSV separator setting on CsvParseStreamOptions documentation HOT 5
- bug(log): `RotatingFileHandler.log()` should handle message longer than 4096 HOT 1
- link replacement of fs.ensureSymlink() HOT 3
- semver: deprecate `rangeMax` and `rangeMin` HOT 4
- proposal: config module HOT 1
- Log: debug level logs not showing HOT 3
- suggestion: more readable function chaining for `collections` (pipe, chain, data-last)
- The OS Signals Async iterator example is broken because `std/signal` was removed HOT 1
- deprecation(log): deprecate `LogRecord` class and use plain object instead HOT 3
- question(log): remove `setup()` and `destroy()` from `BaseHandler`? HOT 8
- question(log): public methods in classes HOT 1
- proposal(front_matter): fix file names and exports HOT 5
- is it possible to cache all std lib? HOT 2
- suggestion: optional `reason` param for assert::unreachable
- proposal(std): standardise JSDoc tag usage HOT 4
- Log FileHandler chokes at messages > 4096 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_std.