Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90aa6d6

Browse files
committed
http/{request,websocket}: websocket:scheme is "http" not "ws"
RFC 8441 Section 5 says that the `:scheme` for websockets in HTTP/2 shouldbe "http" or "https" rather than "ws" or "wss".It seems like this should apply to our HTTP/1.1 headers expressed in terms ofHTTP/2 header structures.
1 parent2dadd7d commit90aa6d6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

‎http/proxies.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ function proxies_methods:choose(scheme, host)
5757
end
5858
end
5959
end
60-
ifscheme=="http"orscheme=="ws"then
60+
ifscheme=="http"then
6161
ifself.http_proxythen
6262
returnself.http_proxy
6363
end
64-
elseifscheme=="https"orscheme=="wss"then
64+
elseifscheme=="https"then
6565
ifself.https_proxythen
6666
returnself.https_proxy
6767
end

‎http/request.lua‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ local function new_from_uri(uri_t, headers)
7777
path=path.."?"..uri_t.query
7878
end
7979
headers:upsert(":path",path)
80+
ifscheme=="wss"then
81+
scheme="https"
82+
elseifscheme=="ws"then
83+
scheme="http"
84+
end
8085
headers:upsert(":scheme",scheme)
8186
end
8287
ifuri_t.userinfothen
@@ -95,7 +100,7 @@ local function new_from_uri(uri_t, headers)
95100
returnsetmetatable({
96101
host=host;
97102
port=port;
98-
tls= (scheme=="https"orscheme=="wss");
103+
tls= (scheme=="https");
99104
headers=headers;
100105
body=nil;
101106
},request_mt)
@@ -209,9 +214,9 @@ function request_methods:handle_redirect(orig_headers)
209214
ifnotis_connectthen
210215
new_req.headers:upsert(":scheme",new_scheme)
211216
end
212-
ifnew_scheme=="https"ornew_scheme=="wss"then
217+
ifnew_scheme=="https"then
213218
new_req.tls=true
214-
elseifnew_scheme=="http"ornew_scheme=="ws"then
219+
elseifnew_scheme=="http"then
215220
new_req.tls=false
216221
else
217222
returnnil,"unknown scheme",ce.EINVAL

‎http/websocket.lua‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,6 @@ end
545545

546546
localfunctionnew_from_uri(uri,protocols)
547547
localrequest=http_request.new_from_uri(uri)
548-
localscheme=request.headers:get(":scheme")
549-
assert(scheme=="ws"orscheme=="wss","scheme not websocket")
550548
localself=new("client")
551549
self.request=request
552550
self.request.version=1.1

‎spec/websocket_spec.lua‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ describe("http.websocket module two sided tests", function()
375375
port=0;
376376
onstream=function(s,stream)
377377
localheaders=assert(stream:get_headers())
378+
assert.same("http",headers:get(":scheme"))
378379
localws=websocket.new_from_stream(stream,headers)
379380
assert(ws:accept())
380381
assert(ws:close())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp