class_docstr: Implements the HTTP/1.x protocol.
  
  This class can be on its own for clients, or via `HTTP1ServerConnection`
  for servers.
class_docstr_tok: ["Implements","the","HTTP\/1.x","protocol",".","This","class","can","be","on","its","own","for","clients",",","or","via","`","HTTP1ServerConnection","`","for","servers","."]
code: def _read_message(self, delegate):
      need_delegate_close = False
      try:
          header_future = self.stream.read_until_regex(
              b"\r?\n\r?\n", max_bytes=self.params.max_header_size
          )
          if self.params.header_timeout is None:
              header_data = yield header_future
          else:
              try:
                  header_data = yield gen.with_timeout(
                      self.stream.io_loop.time()
                      + self.params.header_timeout,
                      header_future,
                      io_loop=self.stream.io_loop,
                      quiet_exceptions=iostream.StreamClosedError,
                  )
              except gen.TimeoutError:
                  self.close()
                  raise gen.Return(False)
          start_line, headers = self._parse_headers(header_data)
          if self.is_client:
              start_line = httputil.parse_response_start_line(
                  start_line
              )
              self._response_start_line = start_line
          else:
              start_line = httputil.parse_request_start_line(start_line)
              self._request_start_line = start_line
              self._request_headers = headers
  
          self._disconnect_on_finish = not self._can_keep_alive(
              start_line, headers
          )
          need_delegate_close = True
          with _ExceptionLoggingContext(app_log):
              header_future = delegate.headers_received(
                  start_line, headers
              )
              if header_future is not None:
                  yield header_future
          if self.stream is None:
              # We've been detached.
              need_delegate_close = False
              raise gen.Return(False)
          skip_body = False
          if self.is_client:
              if (
                  self._request_start_line is not None
                  and self._request_start_line.method == "HEAD"
              ):
                  skip_body = True
              code = start_line.code
              if code == 304:
                  # 304 responses may include the content-length header
                  # but do not actually have a body.
                  # http://tools.ietf.org/html/rfc7230#section-3.3
                  skip_body = True
              if code >= 100 and code < 200:
                  # 1xx responses should never indicate the presence of
                  # a body.
                  if (
                      "Content-Length" in headers
                      or "Transfer-Encoding" in headers
                  ):
                      raise httputil.HTTPInputError(
                          "Response code %d cannot have body" % code
                      )
                  # TODO: client delegates will get headers_received twice
                  # in the case of a 100-continue.  Document or change?
                  yield self._read_message(delegate)
          else:
              if (
                  headers.get("Expect") == "100-continue"
                  and not self._write_finished
              ):
                  self.stream.write(b"HTTP/1.1 100 (Continue)\r\n\r\n")
          if not skip_body:
              body_future = self._read_body(
                  start_line.code if self.is_client else 0,
                  headers,
                  delegate,
              )
              if body_future is not None:
                  if self._body_timeout is None:
                      yield body_future
                  else:
                      try:
                          yield gen.with_timeout(
                              self.stream.io_loop.time()
                              + self._body_timeout,
                              body_future,
                              self.stream.io_loop,
                              quiet_exceptions=iostream.StreamClosedError,
                          )
                      except gen.TimeoutError:
                          gen_log.info(
                              "Timeout reading body from %s",
                              self.context,
                          )
                          self.stream.close()
                          raise gen.Return(False)
          self._read_finished = True
          if not self._write_finished or self.is_client:
              need_delegate_close = False
              with _ExceptionLoggingContext(app_log):
                  delegate.finish()
          # If we're waiting for the application to produce an asynchronous
          # response, and we're not detached, register a close callback
          # on the stream (we didn't need one while we were reading)
          if (
              not self._finish_future.done()
              and self.stream is not None
              and not self.stream.closed()
          ):
              self.stream.set_close_callback(self._on_connection_close)
              yield self._finish_future
          if self.is_client and self._disconnect_on_finish:
              self.close()
          if self.stream is None:
              raise gen.Return(False)
      except httputil.HTTPInputError as e:
          gen_log.info(
              "Malformed HTTP message from %s: %s", self.context, e
          )
          self.close()
          raise gen.Return(False)
      finally:
          if need_delegate_close:
              with _ExceptionLoggingContext(app_log):
                  delegate.on_connection_close()
          header_future = None
          self._clear_callbacks()
      raise gen.Return(True)
  
imports: from __future__ import absolute_import, division, print_function
  import re
  from tornado.concurrent import Future
  from tornado.escape import native_str, utf8
  from tornado import gen
  from tornado import httputil
  from tornado import iostream
  from tornado.log import gen_log, app_log
  from tornado import stack_context
  from tornado.util import GzipDecompressor, PY3
label_desc: Use image node_id 3 for calling the HTTP1Connection obj's underlying member method code with example usage: obj._read_message(delegate) without return types