Skip to content

Commit

Permalink
Merge pull request #186 from EricForgy/is_upgrade
Browse files Browse the repository at this point in the history
Add is_upgrade and fixed cert/key path in mwe (for windows)
  • Loading branch information
samoconnor authored Feb 7, 2018
2 parents a6996d0 + 7f261fc commit 4aa53a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ end

# Handshake

is_websocket_upgrade(r::HTTP.Message) =
(r isa HTTP.Request && r.method == "GET" || r.status == 101) &&
HTTP.hasheader(r, "Connection", "upgrade") &&
HTTP.hasheader(r, "Upgrade", "webscoket")


function check_upgrade(http)

Expand Down
6 changes: 2 additions & 4 deletions test/mwe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ end

HTTP.listen(ip"127.0.0.1", 8000,;
ssl = true,
sslconfig = MbedTLS.SSLConfig("cert.pem", "key.pem")) do http
if http.message.method == "GET" &&
hasheader(http, "Connection", "upgrade") &&
hasheader(http, "Upgrade", "websocket")
sslconfig = MbedTLS.SSLConfig(joinpath(dirname(@__FILE__),"cert.pem"), joinpath(dirname(@__FILE__),"key.pem"))) do http
if HTTP.WebSockets.is_websocket_upgrade(http.message)

HTTP.WebSockets.upgrade(http) do client
count = 1
Expand Down

0 comments on commit 4aa53a4

Please sign in to comment.