metmuseum / openaccess

The Metropolitan Museum of Art's Open Access Initiative
Creative Commons Zero v1.0 Universal
1.19k stars 213 forks source link

HPE_INVALID_HEADER_TOKEN on Departments Request #39

Open peterpme opened 3 years ago

peterpme commented 3 years ago

Hi,

I'm debugging an issue with the following request: https://collectionapi.metmuseum.org/public/collection/v1/departments

Modern versions of Node and tools like Postman use a strict http parser that turns an HPE_INVALID_HEADER_TOKEN. The only way around this is by disabling the parser, but that comes with its own consequences.

Do you have any insight on this? Should I be calling the endpoint differently? Thank you

stephenhmarsh commented 2 years ago

@spencerk this is indeed a problem:

> fetch("https://collectionapi.metmuseum.org/public/collection/v1/departments").then(res=>console.log(res))
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 229,
  [Symbol(trigger_async_id_symbol)]: 195
}
> (node:36678) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Uncaught TypeError: fetch failed
    at Object.processResponse (node:internal/deps/undici/undici:5555:34)
    at node:internal/deps/undici/undici:5877:42 {
  cause: HTTPParserError: Invalid header value char
      at Parser.execute (node:internal/deps/undici/undici:3107:19)
      at Parser.readMore (node:internal/deps/undici/undici:3066:16)
      at TLSSocket.onSocketReadable (node:internal/deps/undici/undici:3379:14)
      at TLSSocket.emit (node:events:537:28)
      at TLSSocket.emit (node:domain:545:15)
      at emitReadable_ (node:internal/streams/readable:590:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
    code: 'HPE_INVALID_HEADER_TOKEN',
    data: '\x01UioU; path=/; Max-Age=900\r\n' +
      'Set-Cookie: ___utmvbmlBuKBSmB=ZZE\r\n' +
      '    XLTOXalo: AtM; path=/; Max-Age=900\r\n' +
      'X-CDN: Imperva\r\n' +
      'Content-Encoding: gzip\r\n' +
      'Transfer-Encoding: chunked\r\n' +
      'X-Iinfo: 11-49800697-49800701 NNYN CT(2 11 0) RT(1661484216052 21) q(0 0 0 0) r(2 2) U12\r\n' +
      '\r\n' +
      '162\r\n' +
      "\x1F�\b\x00\x00\x00\x00\x00\x00���Mk\x021\x10��Jس����&*EP+���ø;���X&\x13�����B)�,�m�y�y'��T��\x02�Fî\x18}����u1*\x07E-]��\x02�Ũ\x18k$Y�\x11S�,\x01�\x03�1\x05�<買\tk*\x19��\x15\x02�\x198F2\x11ΰw\tK�\t0u�ז2�}J�\x13v'ƻhx ^+\x04#�GT�&ؾ������9\t}^\x1F���A|���\x03�ԟ��u�5��q,�3f��.8%��f\x7F��5I�]Dy��f�c��\x13���g�l\x1B�O�!4�-sذ\x17{��j�\x13^����2\t�\x0B!~]���Γ�̝\x02-���$6q\x17\x1B�Eb��&v�X��biMN �J\x14X�-\x01I̎��e���\x03�>�I^�ޅ�KV�_�n�K�n,�=A����֗��}���\x1FŽ��,\x04\x00\x00\r\n" +
      '0\r\n' +
      '\r\n'
  }
}
>