Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wspy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
wspy
Commits
6303f518
Commit
6303f518
authored
Jul 26, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some small header fixes
parent
ee818ad0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
handshake.py
handshake.py
+8
-6
No files found.
handshake.py
View file @
6303f518
...
@@ -89,12 +89,12 @@ class ServerHandshake(Handshake):
...
@@ -89,12 +89,12 @@ class ServerHandshake(Handshake):
def
perform
(
self
):
def
perform
(
self
):
# Receive and validate client handshake
# Receive and validate client handshake
location
,
headers
=
self
.
receive_request
()
self
.
wsock
.
location
,
headers
=
self
.
receive_request
()
# Send server handshake in response
# Send server handshake in response
self
.
send_headers
(
self
.
response_headers
(
location
,
headers
))
self
.
send_headers
(
self
.
response_headers
(
headers
))
def
response_headers
(
self
,
location
,
headers
):
def
response_headers
(
self
,
headers
):
# Check if headers that MUST be present are actually present
# Check if headers that MUST be present are actually present
for
name
in
(
'Host'
,
'Upgrade'
,
'Connection'
,
'Sec-WebSocket-Key'
,
for
name
in
(
'Host'
,
'Upgrade'
,
'Connection'
,
'Sec-WebSocket-Key'
,
'Sec-WebSocket-Version'
):
'Sec-WebSocket-Version'
):
...
@@ -117,14 +117,14 @@ class ServerHandshake(Handshake):
...
@@ -117,14 +117,14 @@ class ServerHandshake(Handshake):
# Origin must be present if browser client, and must match the list of
# Origin must be present if browser client, and must match the list of
# trusted origins
# trusted origins
origin
=
'null'
if
'Origin'
not
in
headers
:
if
'Origin'
not
in
headers
:
if
'User-Agent'
in
headers
:
if
'User-Agent'
in
headers
:
self
.
fail
(
'browser client must specify "Origin" header'
)
self
.
fail
(
'browser client must specify "Origin" header'
)
if
self
.
wsock
.
trusted_origins
:
if
self
.
wsock
.
trusted_origins
:
self
.
fail
(
'no "Origin" header specified, assuming untrusted'
)
self
.
fail
(
'no "Origin" header specified, assuming untrusted'
)
origin
=
'null'
elif
self
.
wsock
.
trusted_origins
:
elif
self
.
wsock
.
trusted_origins
:
origin
=
headers
[
'Origin'
]
origin
=
headers
[
'Origin'
]
...
@@ -164,12 +164,14 @@ class ServerHandshake(Handshake):
...
@@ -164,12 +164,14 @@ class ServerHandshake(Handshake):
if
port
!=
default_port
:
if
port
!=
default_port
:
host
+=
':%d'
%
port
host
+=
':%d'
%
port
location
=
'%s://%s%s'
%
(
scheme
,
host
,
self
.
wsock
.
location
)
# Construct HTTP response header
# Construct HTTP response header
yield
'HTTP/1.1 101 Web Socket Protocol Handshake'
yield
'HTTP/1.1 101 Web Socket Protocol Handshake'
yield
'Upgrade'
,
'websocket'
yield
'Upgrade'
,
'websocket'
yield
'Connection'
,
'Upgrade'
yield
'Connection'
,
'Upgrade'
yield
'WebSocket-Origin'
,
origin
yield
'WebSocket-Origin'
,
origin
yield
'WebSocket-Location'
,
'%s://%s%s'
%
(
scheme
,
host
,
location
)
yield
'WebSocket-Location'
,
location
yield
'Sec-WebSocket-Accept'
,
accept
yield
'Sec-WebSocket-Accept'
,
accept
yield
'Sec-WebSocket-Protocol'
,
protocol
yield
'Sec-WebSocket-Protocol'
,
protocol
yield
'Sec-WebSocket-Extensions'
,
', '
.
join
(
extensions
)
yield
'Sec-WebSocket-Extensions'
,
', '
.
join
(
extensions
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment