Esempio n. 1
0
def consume_event(response: http.client.HTTPResponse) -> Tuple[str, Any]:
    _, event = consume_line(response)
    _, raw_data = consume_line(response)

    # Swallow the intermediate line
    response.readline()

    return event, json.loads(raw_data)
Esempio n. 2
0
def consume_line(response: http.client.HTTPResponse) -> Tuple[str, str]:
    name, _, data = response.readline().decode('utf-8').rstrip('\n').partition(':')
    return name.strip(), data.strip()