rdf-ext-archive / rdf-fetch-lite

Deprecated - Uses Fetch to send and receive RDF-Ext Graphs over HTTP
2 stars 2 forks source link

Accept header being overriden #4

Open PulsarFox opened 5 years ago

PulsarFox commented 5 years ago

I'm using rdf-store-sparql, and it uses this library. When i'm doing client.selectQuery(sparqlQuery, {headers:{'Accept':'application/sparql-results+json'}}), the header just disappears before the request is send

The line delete context.options.headers.Accept in patch-request.js deletes the right header and leaves me with text/turtle instead.

I've hardcoded a nasty fix

  if (context.options.accept === 'application/sparql-results+json'){
    delete context.options.headers.accept
  } else {
    delete context.options.headers.Accept
  }
bergos commented 5 years ago

rdf-store-sparql should be upgraded to use the new @rdfjs/fetch-lite library. Until this is done, can you try to manually replace the fetch library? I hope it's easy like shown below, but it's a new major version so I'm not sure if there was any breaking change. The new package should be less error prone.

const formats = require('@rdfjs/formats-common')
const fetch = require('@rdfjs/fetch-lite')

client.fetch = (url, options) => fetch(url, { formats, ...options })
PulsarFox commented 5 years ago

Perfect, it works fine thank you :)