
import cgi
from mod_pywebsocket import msgutil


def web_socket_do_extra_handshake(request):
  r = request.ws_resource.split('?', 1)
  if len(r) == 1:
    return
  param = cgi.parse_qs(r[1])
  if 'protocol' in param:
    request.ws_protocol = param['protocol'][0]


def web_socket_transfer_data(request):
  msgutil.send_message(request, request.ws_protocol)


import cgi
from mod_pywebsocket import msgutil


def web_socket_do_extra_handshake(request):
  r = request.ws_resource.split('?', 1)
  if len(r) == 1:
    return
  param = cgi.parse_qs(r[1])
  if 'protocol' in param:
    request.ws_protocol = param['protocol'][0]


def web_socket_transfer_data(request):
  msgutil.send_message(request, request.ws_protocol)
  # Wait for a close message.
  unused = request.ws_stream.receive_message()

Make Pepper WebSocket UtilityGetProtocol test less flaky by making the wsh wait for close
Make Pepper WebSocket UtilityGetProtocol test less flaky by making the wsh wait for close

Attempt to fix the flakiness by making sure the server handler doesn't exit
before the client closes.

BUG=389084
R=jgraettinger,yhirano

Review URL: https://codereview.chromium.org/410383003

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@285500 0039d316-1c4b-4281-b951-d872f2087c98

  
  import cgi
  from mod_pywebsocket import msgutil
  
  
  def web_socket_do_extra_handshake(request):
    r = request.ws_resource.split('?', 1)
    if len(r) == 1:
      return
    param = cgi.parse_qs(r[1])
    if 'protocol' in param:
      request.ws_protocol = param['protocol'][0]
  
  
  def web_socket_transfer_data(request):
    msgutil.send_message(request, request.ws_protocol)
+   # Wait for a close message.
+   unused = request.ws_stream.receive_message()
  
Make Pepper WebSocket UtilityGetProtocol test less flaky by making the wsh wait for close
## Code Before:

import cgi
from mod_pywebsocket import msgutil


def web_socket_do_extra_handshake(request):
  r = request.ws_resource.split('?', 1)
  if len(r) == 1:
    return
  param = cgi.parse_qs(r[1])
  if 'protocol' in param:
    request.ws_protocol = param['protocol'][0]


def web_socket_transfer_data(request):
  msgutil.send_message(request, request.ws_protocol)

## Instruction:
Make Pepper WebSocket UtilityGetProtocol test less flaky by making the wsh wait for close
## Code After:

import cgi
from mod_pywebsocket import msgutil


def web_socket_do_extra_handshake(request):
  r = request.ws_resource.split('?', 1)
  if len(r) == 1:
    return
  param = cgi.parse_qs(r[1])
  if 'protocol' in param:
    request.ws_protocol = param['protocol'][0]


def web_socket_transfer_data(request):
  msgutil.send_message(request, request.ws_protocol)
  # Wait for a close message.
  unused = request.ws_stream.receive_message()
