Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Unified Diff: net/data/websocket/echo_wsh.py

Issue 11087027: WebSocket test server migration on ExtensionApiTest.WebSocket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/data/websocket/echo_wsh.py
diff --git a/third_party/python_gflags/setup.py b/net/data/websocket/echo_wsh.py
old mode 100755
new mode 100644
similarity index 68%
copy from third_party/python_gflags/setup.py
copy to net/data/websocket/echo_wsh.py
index 573db2d410c8dc94bcc990e6f79685753b08f277..38646c32ceb515f15dd572622689c79ee61e543f
--- a/third_party/python_gflags/setup.py
+++ b/net/data/websocket/echo_wsh.py
@@ -1,6 +1,4 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2007, Google Inc.
+# Copyright 2011, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -29,16 +27,28 @@
# (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 setuptools import setup
-
-setup(name='python-gflags',
- version='2.0',
- description='Google Commandline Flags Module',
- license='BSD',
- author='Google Inc. and others',
- author_email='google-gflags@googlegroups.com',
- url='http://code.google.com/p/python-gflags',
- py_modules=["gflags", "gflags_validators"],
- data_files=[("bin", ["gflags2man.py"])],
- include_package_data=True,
- )
+
+_GOODBYE_MESSAGE = u'Goodbye'
+
+
+def web_socket_do_extra_handshake(request):
+ # This example handler accepts any request. See origin_check_wsh.py for how
+ # to reject access from untrusted scripts based on origin value.
+
+ pass # Always accept.
+
+
+def web_socket_transfer_data(request):
+ while True:
+ line = request.ws_stream.receive_message()
+ if line is None:
+ return
+ if isinstance(line, unicode):
+ request.ws_stream.send_message(line, binary=False)
+ if line == _GOODBYE_MESSAGE:
+ return
+ else:
+ request.ws_stream.send_message(line, binary=True)
+
+
+# vi:sts=4 sw=4 et

Powered by Google App Engine
This is Rietveld 408576698