def http_emitter(message, log, agentConfig, endpoint):
    "Send payload"
    url = agentConfig['sd_url']

    log.debug('http_emitter: attempting postback to ' + url)

    # Post back the data
    try:
        payload = json.dumps(message)
    except __HOLE__:
        message = remove_control_chars(message)
        payload = json.dumps(message)

    #zipped = zlib.compress(payload)
    zipped = payload

    log.debug("payload_size=%d, compressed_size=%d, compression_ratio=%.3f"
              % (len(payload), len(zipped), float(len(payload))/float(len(zipped))))

    agentKey = message.get('agentKey', None)
    if not agentKey:
        raise Exception("The http emitter requires an agent key")

    url = "{0}/intake/{1}?agent_key={2}".format(url, endpoint, agentKey)

    try:
        headers = post_headers(agentConfig, zipped)
        r = requests.post(url, data=zipped, timeout=5, headers=headers)

        r.raise_for_status()

        if r.status_code >= 200 and r.status_code < 205:
            log.debug("Payload accepted")

    except Exception:
        log.exception("Unable to post payload.")
        try:
            log.error("Received status code: {0}".format(r.status_code))
        except Exception:
            pass
dataset/ETHPy150Open serverdensity/sd-agent/emitter.py/http_emitter