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
b5619042
Commit
b5619042
authored
Jul 26, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied pyflakes & pep8
parent
667d6115
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
connection.py
connection.py
+1
-1
frame.py
frame.py
+2
-4
websocket.py
websocket.py
+6
-5
No files found.
connection.py
View file @
b5619042
...
@@ -146,7 +146,7 @@ class Connection(object):
...
@@ -146,7 +146,7 @@ class Connection(object):
frame
=
self
.
sock
.
recv
()
frame
=
self
.
sock
.
recv
()
if
frame
.
opcode
!=
OPCODE_CLOSE
:
if
frame
.
opcode
!=
OPCODE_CLOSE
:
raise
ValueError
(
'expected CLOSE frame, got %s
instead
'
%
frame
)
raise
ValueError
(
'expected CLOSE frame, got %s'
%
frame
)
res_code
,
res_reason
=
frame
.
unpack_close
()
res_code
,
res_reason
=
frame
.
unpack_close
()
...
...
frame.py
View file @
b5619042
...
@@ -3,8 +3,6 @@ import socket
...
@@ -3,8 +3,6 @@ import socket
from
os
import
urandom
from
os
import
urandom
from
string
import
printable
from
string
import
printable
from
errors
import
SocketClosed
OPCODE_CONTINUATION
=
0x0
OPCODE_CONTINUATION
=
0x0
OPCODE_TEXT
=
0x1
OPCODE_TEXT
=
0x1
...
@@ -176,7 +174,7 @@ class ControlFrame(Frame):
...
@@ -176,7 +174,7 @@ class ControlFrame(Frame):
125 bytes.
125 bytes.
"""
"""
if
len
(
self
.
payload
)
>
125
:
if
len
(
self
.
payload
)
>
125
:
raise
ValueError
(
'control frames must not be larger than 125
'
\
raise
ValueError
(
'control frames must not be larger than 125
'
'bytes'
)
'bytes'
)
return
Frame
.
pack
(
self
)
return
Frame
.
pack
(
self
)
...
...
websocket.py
View file @
b5619042
...
@@ -42,8 +42,8 @@ class websocket(object):
...
@@ -42,8 +42,8 @@ class websocket(object):
>>> sock.connect(('', 8000))
>>> sock.connect(('', 8000))
>>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!'))
>>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!'))
"""
"""
def
__init__
(
self
,
sock
=
None
,
protocols
=
[],
extensions
=
[],
sfamily
=
socket
.
AF_INET
,
def
__init__
(
self
,
sock
=
None
,
protocols
=
[],
extensions
=
[],
sproto
=
0
):
s
family
=
socket
.
AF_INET
,
s
proto
=
0
):
"""
"""
Create a regular TCP socket of family `family` and protocol
Create a regular TCP socket of family `family` and protocol
...
@@ -251,10 +251,12 @@ class websocket(object):
...
@@ -251,10 +251,12 @@ class websocket(object):
# Request protocols and extension, these are later checked with the
# Request protocols and extension, these are later checked with the
# actual supported values from the server's response
# actual supported values from the server's response
if
self
.
protocols
:
if
self
.
protocols
:
shake
+=
'Sec-WebSocket-Protocol: %s
\
r
\
n
'
%
', '
.
join
(
self
.
protocols
)
shake
+=
'Sec-WebSocket-Protocol: %s
\
r
\
n
'
\
%
', '
.
join
(
self
.
protocols
)
if
self
.
extensions
:
if
self
.
extensions
:
shake
+=
'Sec-WebSocket-Extensions: %s
\
r
\
n
'
%
', '
.
join
(
self
.
extensions
)
shake
+=
'Sec-WebSocket-Extensions: %s
\
r
\
n
'
\
%
', '
.
join
(
self
.
extensions
)
if
auth
:
if
auth
:
shake
+=
'Authorization: %s
\
r
\
n
'
%
auth
shake
+=
'Authorization: %s
\
r
\
n
'
%
auth
...
@@ -351,7 +353,6 @@ class websocket(object):
...
@@ -351,7 +353,6 @@ class websocket(object):
self
.
handshake_started
=
True
self
.
handshake_started
=
True
receive_response
(
send_request
(
location
))
receive_response
(
send_request
(
location
))
def
enable_ssl
(
self
,
*
args
,
**
kwargs
):
def
enable_ssl
(
self
,
*
args
,
**
kwargs
):
"""
"""
Transforms the regular socket.socket to an ssl.SSLSocket for secure
Transforms the regular socket.socket to an ssl.SSLSocket for secure
...
...
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