':arg stream: an `.IOStream`
:arg bool is_client: client or server
:arg params: a `.HTTP1ConnectionParameters` instance or ``None``
:arg context: an opaque application-defined object that can be accessed
as ``connection.context``.'

def __init__(self, stream, is_client, params=None, context=None):

    self.is_client = is_client
    self.stream = stream
    if (params is None):
        params = HTTP1ConnectionParameters()
    self.params = params
    self.context = context
    self.no_keep_alive = params.no_keep_alive
    self._max_body_size = (self.params.max_body_size or self.stream.max_buffer_size)
    self._body_timeout = self.params.body_timeout
    self._write_finished = False
    self._read_finished = False
    self._finish_future = Future()
    self._disconnect_on_finish = False
    self._clear_callbacks()
    self._request_start_line = None
    self._response_start_line = None
    self._request_headers = None
    self._chunking_output = None
    self._expected_content_remaining = None
    self._pending_write = None
