forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1622683 - Make dom/websocket flake8 and pylint compliant. r=sylve…
…stre Differential Revision: https://phabricator.services.mozilla.com/D88809
- Loading branch information
1 parent
50b96d5
commit 24588e8
Showing
12 changed files
with
246 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
from mod_pywebsocket import msgutil | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
# must set request.ws_protocol to the selected version from ws_requested_protocols | ||
request.ws_protocol = request.ws_requested_protocols[0] | ||
# must set request.ws_protocol to the selected version from ws_requested_protocols | ||
request.ws_protocol = request.ws_requested_protocols[0] | ||
|
||
if (request.ws_protocol == 'error'): | ||
raise ValueError('Error') | ||
pass | ||
|
||
if (request.ws_protocol == 'error'): | ||
raise ValueError('Error') | ||
pass | ||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
line = msgutil.receive_message(request) | ||
if line == 'protocol': | ||
msgutil.send_message(request, request.ws_protocol) | ||
continue | ||
while True: | ||
line = msgutil.receive_message(request) | ||
if line == 'protocol': | ||
msgutil.send_message(request, request.ws_protocol) | ||
continue | ||
|
||
if line == 'resource': | ||
msgutil.send_message(request, request.ws_resource) | ||
continue | ||
if line == 'resource': | ||
msgutil.send_message(request, request.ws_resource) | ||
continue | ||
|
||
if line == 'origin': | ||
msgutil.send_message(request, request.ws_origin) | ||
continue | ||
if line == 'origin': | ||
msgutil.send_message(request, request.ws_origin) | ||
continue | ||
|
||
msgutil.send_message(request, line) | ||
msgutil.send_message(request, line) | ||
|
||
if line == 'end': | ||
return | ||
if line == 'end': | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from mod_pywebsocket import msgutil | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
pass | ||
pass | ||
|
||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
line = msgutil.receive_message(request) | ||
msgutil.send_message(request, line, True, True) | ||
while True: | ||
line = msgutil.receive_message(request) | ||
msgutil.send_message(request, line, True, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from mod_pywebsocket import msgutil | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
pass | ||
pass | ||
|
||
|
||
def web_socket_transfer_data(request): | ||
resp = "Test" | ||
if msgutil.receive_message(request) == "data": | ||
resp = "Hello world!" | ||
msgutil.send_message(request, resp) | ||
resp = "Test" | ||
if msgutil.receive_message(request) == "data": | ||
resp = "Hello world!" | ||
msgutil.send_message(request, resp) |
24 changes: 13 additions & 11 deletions
24
dom/websocket/tests/file_websocket_permessage_deflate_disabled_wsh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
from mod_pywebsocket import msgutil | ||
from mod_pywebsocket import common | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
if request.ws_requested_extensions is not None: | ||
for extension_request in request.ws_requested_extensions: | ||
if extension_request.name() == "permessage-deflate": | ||
raise ValueError('permessage-deflate should not be offered') | ||
if request.ws_requested_extensions is not None: | ||
for extension_request in request.ws_requested_extensions: | ||
if extension_request.name() == "permessage-deflate": | ||
raise ValueError('permessage-deflate should not be offered') | ||
|
||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) |
32 changes: 17 additions & 15 deletions
32
dom/websocket/tests/file_websocket_permessage_deflate_params_wsh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
from mod_pywebsocket import msgutil | ||
from mod_pywebsocket import common | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
deflate_found = False | ||
deflate_found = False | ||
|
||
if request.ws_extension_processors is not None: | ||
for extension_processor in request.ws_extension_processors: | ||
if extension_processor.name() == "deflate": | ||
extension_processor.set_client_no_context_takeover(True) | ||
deflate_found = True | ||
|
||
if request.ws_extension_processors is not None: | ||
for extension_processor in request.ws_extension_processors: | ||
if extension_processor.name() == "deflate": | ||
extension_processor.set_client_no_context_takeover(True) | ||
deflate_found = True | ||
if deflate_found is False: | ||
raise ValueError('deflate extension processor not found') | ||
|
||
if deflate_found is False: | ||
raise ValueError('deflate extension processor not found') | ||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) |
32 changes: 17 additions & 15 deletions
32
dom/websocket/tests/file_websocket_permessage_deflate_rejected_wsh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
from mod_pywebsocket import msgutil | ||
from mod_pywebsocket import common | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
deflate_removed = False | ||
deflate_removed = False | ||
|
||
if request.ws_extension_processors is not None: | ||
for extension_processor in request.ws_extension_processors: | ||
if extension_processor.name() == "deflate": | ||
request.ws_extension_processors.remove(extension_processor) | ||
deflate_removed = True | ||
|
||
if request.ws_extension_processors is not None: | ||
for extension_processor in request.ws_extension_processors: | ||
if extension_processor.name() == "deflate": | ||
request.ws_extension_processors.remove(extension_processor) | ||
deflate_removed = True | ||
if deflate_removed is False: | ||
raise ValueError('deflate extension processor not found') | ||
|
||
if deflate_removed is False: | ||
raise ValueError('deflate extension processor not found') | ||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) |
30 changes: 16 additions & 14 deletions
30
dom/websocket/tests/file_websocket_permessage_deflate_wsh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
from mod_pywebsocket import msgutil | ||
from mod_pywebsocket import common | ||
|
||
|
||
def web_socket_do_extra_handshake(request): | ||
pmce_offered = False | ||
pmce_offered = False | ||
|
||
if request.ws_requested_extensions is not None: | ||
for extension_request in request.ws_requested_extensions: | ||
if extension_request.name() == "permessage-deflate": | ||
pmce_offered = True | ||
|
||
if request.ws_requested_extensions is not None: | ||
for extension_request in request.ws_requested_extensions: | ||
if extension_request.name() == "permessage-deflate": | ||
pmce_offered = True | ||
if pmce_offered is False: | ||
raise ValueError('permessage-deflate not offered') | ||
|
||
if pmce_offered is False: | ||
raise ValueError('permessage-deflate not offered') | ||
|
||
def web_socket_transfer_data(request): | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) | ||
while True: | ||
rcvd = msgutil.receive_message(request) | ||
opcode = request.ws_stream.get_last_received_opcode() | ||
if (opcode == common.OPCODE_BINARY): | ||
msgutil.send_message(request, rcvd, binary=True) | ||
elif (opcode == common.OPCODE_TEXT): | ||
msgutil.send_message(request, rcvd) |
Oops, something went wrong.