def cleanHeaders(headers, method, body, host, port):
    if headers is None:
        headers = []

    # Add the required Host request header if not present.
    # [This specifies the host:port of the server, not the client.]
    found = False
    for k, v in headers:
        if k.lower() == 'host':
            found = True
            break
    if not found:
        if port == 80:
            headers.append(("Host", host))
        else:
            headers.append(("Host", "%s:%s" % (host, port)))

    if method in methods_with_bodies:
        # Stick in default type and length headers if not present
        found = False
        for k, v in headers:
            if k.lower() == 'content-type':
                found = True
                break
        if not found:
            headers.append(("Content-Type", "application/x-www-form-urlencoded"))
            headers.append(("Content-Length", str(len(body or ""))))

    return headers
Model signalling
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/cherrypy/cherrypy/test/webtest.py/cleanHeaders--crossover with--dataset/ETHPy150Open mitsuhiko/solace/solace/tests/signals.py/SignalTestCase.test_model_signals