async *iterateHttpRequests(conn) {
    const reader = new BufReader(conn);
    const writer = new BufWriter(conn);
    while (!this.closing) {
      let request;
      try {
        request = await readRequest(conn, reader);
      } catch (error) {
        if (
          error instanceof Deno.errors.InvalidData ||
          error instanceof Deno.errors.UnexpectedEof
        ) {
          // An error was thrown while parsing request headers.
          await writeResponse(writer, {
            status: 400,
            body: encode(`${error.message}\r\n\r\n`),
          });
        }
        break;
      }
      if (request === null) {
        break;
      }
      request.w = writer;
      yield request;
      // Wait for the request to be processed before we accept a new request on
      // this connection.
      const responseError = await request.done;
      if (responseError) {
        // Something bad happened during response.
        // (likely other side closed during pipelined req)
        // req.done implies this connection already closed, so we can just return.
        this.untrackConnection(request.conn);
        return;
      }
      // Consume unread body and trailers if receiver didn't consume those data
      await request.finalize();
    }
    this.untrackConnection(conn);
    try {
      conn.close();
    } catch (e) {
      // might have been already closed
    }
  }
// Yields all HTTP requests on a single TCP connection.
Yields all HTTP requests on a single TCP connection.
Yields all HTTP requests on a single TCP connection .
async *iterateHttpRequests(conn) {
    const reader = new BufReader(conn);
    const writer = new BufWriter(conn);
    while (!this.closing) {
      let request;
      try {
        request = await readRequest(conn, reader);
      } catch (error) {
        if (
          error instanceof Deno.errors.InvalidData ||
          error instanceof Deno.errors.UnexpectedEof
        ) {
          await writeResponse(writer, {
            status: 400,
            body: encode(`${error.message}\r\n\r\n`),
          });
        }
        break;
      }
      if (request === null) {
        break;
      }
      request.w = writer;
      yield request;
      const responseError = await request.done;
      if (responseError) {
        this.untrackConnection(request.conn);
        return;
      }
      await request.finalize();
    }
    this.untrackConnection(conn);
    try {
      conn.close();
    } catch (e) {
    }
  }
async * iterateHttpRequests ( conn ) { const reader = new BufReader ( conn ) ; const writer = new BufWriter ( conn ) ; while ( ! this . closing ) { let request ; try { request = await readRequest ( conn , reader ) ; } catch ( error ) { if ( error instanceof Deno . errors . InvalidData || error instanceof Deno . errors . UnexpectedEof ) { await writeResponse ( writer , { status : 400 , body : encode ( ` ${ error . message } \r \n \r \n ` ) , } ) ; } break ; } if ( request === null ) { break ; } request . w = writer ; yield request ; const responseError = await request . done ; if ( responseError ) { this . untrackConnection ( request . conn ) ; return ; } await request . finalize ( ) ; } this . untrackConnection ( conn ) ; try { conn . close ( ) ; } catch ( e ) { } }
Yields all HTTP requests on a single TCP connection.
Yields all HTTP requests on a single TCP connection .
// An error was thrown while parsing request headers. // Wait for the request to be processed before we accept a new request on // this connection. // Something bad happened during response. // (likely other side closed during pipelined req) // req.done implies this connection already closed, so we can just return. // Consume unread body and trailers if receiver didn't consume those data // might have been already closed