def post_http_server(test, host, port, data, expected_response='ok'):
 def make_post(host, port, data):
  request = post('http://{host}:{port}'.format(host=host, port=port), data=data, timeout=SOCKET_TIMEOUT_FOR_POLLING, persistent=False)
  def failed(failure):
   Message.new(message_type=u'acceptance:http_query_failed', reason=unicode(failure)).write()
   return False
  request.addCallbacks(content, failed)
  return request
 d = verify_socket(host, port)
 d.addCallback((lambda _: loop_until(reactor, (lambda : make_post(host, port, data)))))
 d.addCallback(test.assertEqual, expected_response)
 return d

def post_http_server ( test , host , port , data , expected_response = 'ok' ) : def make_post ( host , port , data ) : request = post ( 'http://{host}:{port}' . format ( host = host , port = port ) , data = data , timeout = SOCKET_TIMEOUT_FOR_POLLING , persistent = False ) def failed ( failure ) : Message . new ( message_type = u'acceptance:http_query_failed' , reason = unicode ( failure ) ) . write ( ) return False request . addCallbacks ( content , failed ) return request d = verify_socket ( host , port ) d . addCallback ( ( lambda _ : loop_until ( reactor , ( lambda : make_post ( host , port , data ) ) ) ) ) d . addCallback ( test . assertEqual , expected_response ) return d
make a post request to an http server on the given host and port and assert that the response body matches the expected response .