def parse(m):
  """parse parses an HTTP message into 3 parts: first line, headers, body."""
  while m.startswith('HTTP/1.1 100 Continue\r\n'):
    m = m[m.find('\r\n\r\n')+4:]
  p = m.find('\r\n')
  if p == -1:
    return
  first = m[:p]
  q = m.find('\r\n\r\n')
  headers = m[p+2:q]
  body = m[q+4:]
  return first, headers, body