diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..70f2867054198471182cc8619663a684d958f6ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.pyc +build/ +*.egg-info/ +dist/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..2065a644dd6b60797128b09998f67b5135b1189e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: python +python: + - 2.7 + - 3.5 + - 3.6 + - 3.7 + - 3.8 + - nightly + +matrix: + allow_failures: + - python: 3.5, nightly +install: + - pip install six yapf +script: + - python test/run_all.py + - yapf --diff --recursive . diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 0000000000000000000000000000000000000000..f975be126fb4589c865994c59d613e3d41a7a966 --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,30 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. +For instructions for contributing code, please read: +https://github.com/google/pywebsocket/wiki/CodeReviewInstruction + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google/conduct/). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c91bea9025428779e164459c2a120e1a07aa85c8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +Copyright 2020, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000000000000000000000000000000000..19256882c56feb72812c99c8a8379979e63e4a0c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include COPYING +include MANIFEST.in +include README +recursive-include example *.py +recursive-include mod_pywebsocket *.py +recursive-include test *.py diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8684f2cc7ee36960ef3ba9a7dafeef8db591a6f7 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ + +# pywebsocket3 # + +The pywebsocket project aims to provide a [WebSocket](https://tools.ietf.org/html/rfc6455) standalone server. + +pywebsocket is intended for **testing** or **experimental** purposes. + +Run this to read the general document: +``` +$ pydoc mod_pywebsocket +``` + +Please see [Wiki](https://github.com/GoogleChromeLabs/pywebsocket3/wiki) for more details. + +# INSTALL # + +To install this package to the system, run this: +``` +$ python setup.py build +$ sudo python setup.py install +``` + +To install this package as a normal user, run this instead: + +``` +$ python setup.py build +$ python setup.py install --user +``` +# LAUNCH # + +To use pywebsocket as standalone server, run this to read the document: +``` +$ pydoc mod_pywebsocket.standalone +``` +# Disclaimer # +This is not an officially supported Google product diff --git a/example/abort_handshake_wsh.py b/example/abort_handshake_wsh.py new file mode 100644 index 0000000000000000000000000000000000000000..1b719ca89737105719c71c2a42eaff0d464478c7 --- /dev/null +++ b/example/abort_handshake_wsh.py @@ -0,0 +1,43 @@ +# Copyright 2012, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from __future__ import absolute_import +from mod_pywebsocket import handshake + + +def web_socket_do_extra_handshake(request): + raise handshake.AbortedByUserException( + "Aborted in web_socket_do_extra_handshake") + + +def web_socket_transfer_data(request): + pass + + +# vi:sts=4 sw=4 et diff --git a/example/abort_wsh.py b/example/abort_wsh.py new file mode 100644 index 0000000000000000000000000000000000000000..d4c240bf2c1cb0bd538ec37bf551c11256396b8c --- /dev/null +++ b/example/abort_wsh.py @@ -0,0 +1,43 @@ +# Copyright 2012, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from __future__ import absolute_import +from mod_pywebsocket import handshake + + +def web_socket_do_extra_handshake(request): + pass + + +def web_socket_transfer_data(request): + raise handshake.AbortedByUserException( + "Aborted in web_socket_transfer_data") + + +# vi:sts=4 sw=4 et diff --git a/example/arraybuffer_benchmark.html b/example/arraybuffer_benchmark.html new file mode 100644 index 0000000000000000000000000000000000000000..869cd7e1ee653d59f04b802ff34c8d081317ca89 --- /dev/null +++ b/example/arraybuffer_benchmark.html @@ -0,0 +1,134 @@ + + + + +ArrayBuffer benchmark + + + + + + + diff --git a/example/bench_wsh.py b/example/bench_wsh.py new file mode 100644 index 0000000000000000000000000000000000000000..2df50e77db276cca1de472059a074071b81a93cc --- /dev/null +++ b/example/bench_wsh.py @@ -0,0 +1,59 @@ +# Copyright 2011, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"""A simple load tester for WebSocket clients. + +A client program sends a message formatted as "