async readMIMEHeader() {
    const m = new Headers();
    let line;
    // The first line cannot start with a leading space.
    let buf = await this.r.peek(1);
    if (buf === null) {
      return null;
    } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) {
      line = await this.readLineSlice();
    }
    buf = await this.r.peek(1);
    if (buf === null) {
      throw new Deno.errors.UnexpectedEof();
    } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) {
      throw new Deno.errors.InvalidData(
        `malformed MIME header initial line: ${str(line)}`,
      );
    }
    while (true) {
      const kv = await this.readLineSlice(); // readContinuedLineSlice
      if (kv === null) throw new Deno.errors.UnexpectedEof();
      if (kv.byteLength === 0) return m;
      // Key ends at first colon
      let i = kv.indexOf(charCode(":"));
      if (i < 0) {
        throw new Deno.errors.InvalidData(
          `malformed MIME header line: ${str(kv)}`,
        );
      }
      //let key = canonicalMIMEHeaderKey(kv.subarray(0, endKey));
      const key = str(kv.subarray(0, i));
      // As per RFC 7230 field-name is a token,
      // tokens consist of one or more chars.
      // We could throw `Deno.errors.InvalidData` here,
      // but better to be liberal in what we
      // accept, so if we get an empty key, skip it.
      if (key == "") {
        continue;
      }
      // Skip initial spaces in value.
      i++; // skip colon
      while (
        i < kv.byteLength && (kv[i] == charCode(" ") || kv[i] == charCode("\t"))
      ) {
        i++;
      }
      const value = str(kv.subarray(i)).replace(
        invalidHeaderCharRegex,
        encodeURI,
      );
      // In case of invalid header we swallow the error
      // example: "Audio Mode" => invalid due to space in the key
      try {
        m.append(key, value);
      } catch {
        // Pass
      }
    }
  }
/** ReadMIMEHeader reads a MIME-style header from r.
   * The header is a sequence of possibly continued Key: Value lines
   * ending in a blank line.
   * The returned map m maps CanonicalMIMEHeaderKey(key) to a
   * sequence of values in the same order encountered in the input.
   *
   * For example, consider this input:
   *
   *	My-Key: Value 1
   *	Long-Key: Even
   *	       Longer Value
   *	My-Key: Value 2
   *
   * Given that input, ReadMIMEHeader returns the map:
   *
   *	map[string][]string{
   *		"My-Key": {"Value 1", "Value 2"},
   *		"Long-Key": {"Even Longer Value"},
   *	}
   */
ReadMIMEHeader reads a MIME-style header from r.
The header is a sequence of possibly continued Key: Value lines
ending in a blank line.
The returned map m maps CanonicalMIMEHeaderKey(key) to a
sequence of values in the same order encountered in the input.

For example, consider this input.

My-Key: Value 1
Long-Key: Even
Longer Value
My-Key: Value 2

Given that input, ReadMIMEHeader returns the map.


ReadMIMEHeader reads a MIME - style header from r . The header is a sequence of possibly continued Key : Value lines ending in a blank line . The returned map m maps CanonicalMIMEHeaderKey ( key ) to a sequence of values in the same order encountered in the input . For example consider this input . My - Key : Value 1 Long - Key : Even Longer Value My - Key : Value 2 Given that input ReadMIMEHeader returns the map .
async readMIMEHeader() {
    const m = new Headers();
    let line;
    let buf = await this.r.peek(1);
    if (buf === null) {
      return null;
    } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) {
      line = await this.readLineSlice();
    }
    buf = await this.r.peek(1);
    if (buf === null) {
      throw new Deno.errors.UnexpectedEof();
    } else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) {
      throw new Deno.errors.InvalidData(
        `malformed MIME header initial line: ${str(line)}`,
      );
    }
    while (true) {
      const kv = await this.readLineSlice(); 
      if (kv === null) throw new Deno.errors.UnexpectedEof();
      if (kv.byteLength === 0) return m;
      let i = kv.indexOf(charCode(":"));
      if (i < 0) {
        throw new Deno.errors.InvalidData(
          `malformed MIME header line: ${str(kv)}`,
        );
      }
      const key = str(kv.subarray(0, i));
      if (key == "") {
        continue;
      }
      i++; 
      while (
        i < kv.byteLength && (kv[i] == charCode(" ") || kv[i] == charCode("\t"))
      ) {
        i++;
      }
      const value = str(kv.subarray(i)).replace(
        invalidHeaderCharRegex,
        encodeURI,
      );
      try {
        m.append(key, value);
      } catch {
      }
    }
  }
async readMIMEHeader ( ) { const m = new Headers ( ) ; let line ; let buf = await this . r . peek ( 1 ) ; if ( buf === null ) { return null ; } else if ( buf [ 0 ] == charCode ( " " ) || buf [ 0 ] == charCode ( "\t" ) ) { line = await this . readLineSlice ( ) ; } buf = await this . r . peek ( 1 ) ; if ( buf === null ) { throw new Deno . errors . UnexpectedEof ( ) ; } else if ( buf [ 0 ] == charCode ( " " ) || buf [ 0 ] == charCode ( "\t" ) ) { throw new Deno . errors . InvalidData ( ` ${ str ( line ) } ` , ) ; } while ( true ) { const kv = await this . readLineSlice ( ) ; if ( kv === null ) throw new Deno . errors . UnexpectedEof ( ) ; if ( kv . byteLength === 0 ) return m ; let i = kv . indexOf ( charCode ( ":" ) ) ; if ( i < 0 ) { throw new Deno . errors . InvalidData ( ` ${ str ( kv ) } ` , ) ; } const key = str ( kv . subarray ( 0 , i ) ) ; if ( key == "" ) { continue ; } i ++ ; while ( i < kv . byteLength && ( kv [ i ] == charCode ( " " ) || kv [ i ] == charCode ( "\t" ) ) ) { i ++ ; } const value = str ( kv . subarray ( i ) ) . replace ( invalidHeaderCharRegex , encodeURI , ) ; try { m . append ( key , value ) ; } catch { } } }
ReadMIMEHeader reads a MIME-style header from r.
 The header is a sequence of possibly continued Key: Value lines
 ending in a blank line.
ReadMIMEHeader reads a MIME - style header from r . The header is a sequence of possibly continued Key : Value lines ending in a blank line .
// The first line cannot start with a leading space. // readContinuedLineSlice // Key ends at first colon //let key = canonicalMIMEHeaderKey(kv.subarray(0, endKey)); // As per RFC 7230 field-name is a token, // tokens consist of one or more chars. // We could throw `Deno.errors.InvalidData` here, // but better to be liberal in what we // accept, so if we get an empty key, skip it. // Skip initial spaces in value. // skip colon // In case of invalid header we swallow the error // example: "Audio Mode" => invalid due to space in the key // Pass