'Called by L{twisted.web.http.Request} objects to write a complete set
of HTTP headers to a stream.
@param version: The HTTP version in use. Unused in HTTP/2.
@type version: L{bytes}
@param code: The HTTP status code to write.
@type code: L{bytes}
@param reason: The HTTP reason phrase to write. Unused in HTTP/2.
@type reason: L{bytes}
@param headers: The headers to write to the stream.
@type headers: L{twisted.web.http_headers.Headers}
@param streamID: The ID of the stream to write the headers to.
@type streamID: L{int}'

def writeHeaders(self, version, code, reason, headers, streamID):

    headers.insert(0, (':status', code))
    try:
        self.conn.send_headers(streamID, headers)
    except h2.exceptions.StreamClosedError:
        return
    else:
        self.transport.write(self.conn.data_to_send())
