rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

headers['accept'] does not work on Headers object?

Open josephguillaume opened this issue 4 years ago • 0 comments

The problem I ran into was that fetch was always sending Accept=*/*, which meant I was receiving html instead of ttl.

I traced this to the statement https://github.com/linkeddata/rdflib.js/blob/14c93f5cd18fd4658561f243c2f4b3f33a9216df/src/fetcher.ts#L1045

Apparently for a Headers object, we have to use headers.append, or alternatively just use a plain object?

This seems to be the case in Chrome 83.0.4103.116 (Official Build) (64-bit) (cohort: Stable) and Brave | 1.4.95 Chromium: 80.0.3987.122 (Official Build) (64-bit)

A workaround when using solid is to specify a headers object, e.g. fetcher.load(folder, {headers: { accept: "text/turtle" }}); This then means that a Headers object is not used: https://github.com/linkeddata/rdflib.js/blob/14c93f5cd18fd4658561f243c2f4b3f33a9216df/src/fetcher.ts#L1034

josephguillaume avatar Jun 27 '20 08:06 josephguillaume