dobyte/due

3 questions about annotations, naming, and protocols

guowei-gong opened this issue · 4 comments

  1. due/network/ws/server.go 中,为什么除了 GET 请求会被升级,其余的都会抛出 405 的错误?
    通常 HTTP GET 请求是获取资源的请求,也就是只读请求,但是 Websocket 是双向通信协议呀。
    image

  2. ws 和 tcp 的 server_conn_mgr.go 中的结构体 connMgr(ws/server_conn_mgr.go)和 serverConnMgr 结构体(tcp/server_conn_mgr.go)是否可以统一命名?

  3. due/network/ws/client_conn.go 中的 clientConn 结构体中的 conn 字段注解有误。
    image

我想确认 2 和 3 是否修改后,会让 Due 变得更好(或者这样做是否对)?得到答复后,我很乐意修改它们并提交 pr。

期待你的回复 :-)

dobyte commented

问题1:
rfc6455
Once a connection to the server has been established (including a
connection via a proxy or over a TLS-encrypted tunnel), the client
MUST send an opening handshake to the server. The handshake consists
of an HTTP Upgrade request, along with a list of required and
optional header fields. The requirements for this handshake are as
follows.

  1. The handshake MUST be a valid HTTP request as specified by
    [RFC2616].

  2. The method of the request MUST be GET, and the HTTP version MUST
    be at least 1.1.

    For example, if the WebSocket URI is "ws://example.com/chat",
    the first line sent should be "GET /chat HTTP/1.1".

  3. The "Request-URI" part of the request MUST match the /resource
    name/ defined in Section 3 (a relative URI) or be an absolute
    http/https URI that, when parsed, has a /resource name/, /host/,
    and /port/ that match the corresponding ws/wss URI.

  4. The request MUST contain a |Host| header field whose value
    contains /host/ plus optionally ":" followed by /port/ (when not
    using the default port).

  5. The request MUST contain an |Upgrade| header field whose value
    MUST include the "websocket" keyword.

dobyte commented

问题2和问题3已在v2-feature-main分支中进行了修改

dobyte commented

感谢您的反馈

感谢您的反馈

感谢您的答复!同时感谢您提供了这么好的框架,让我学习