code: def read_http_header(sock):
      
      buf = []
      hdr_end = '\r\n\r\n'
  
      while True:
          buf.append(sock.recv(bufsize).decode('utf-8'))
          data = ''.join(buf)
          i = data.find(hdr_end)
          if i == -1:
              continue
          return data[:i], data[i + len(hdr_end):]
docs: Read HTTP header from socket, return header and rest of data.