Git Product home page Git Product logo

Comments (8)

wikier avatar wikier commented on May 23, 2024

Well, I understand the feature request.

But... the issue is clearly server-side. The idea is to stay bound to the protocol. Small changes for a broader support are fine. But we should put a line where we do not support such wrong behaviors.

What do others (@iherman, @indeyets, @dayures, etc) think?

from sparqlwrapper.

joernhees avatar joernhees commented on May 23, 2024

i didn't want to suggest to encourage bad behavior, but i'm suggesting to allow for easier customization so that developers can use the lib in the real world even if things go slightly wrong.

If you read the thread on stackoverflow, you saw that the endpoint actually follows protocol, but that it doesn't seem to understand the longer than necessary Accept header we send for compatibility reasons: Accept: application/sparql-results+json,text/javascript,application/json. The endpoint doesn't understand the , joined alternatives, but it would understand Accept: application/sparql-results+json.

Why shouldn't we allow a developer to just send one of these alternatives / in general manually set the headers?

At the moment the workaround for this really minor flaw of the endpoint is relatively complicated just cause _createRequest() does it in-line (so it doesn't call another method one could override) and it doesn't check if that header was already set.

from sparqlwrapper.

psychemedia avatar psychemedia commented on May 23, 2024

I need to access an endpoint that requires a custom header attribute to pass an API token.

Am I correct in thinking that I can't do this with SPARQLwrapper as it currently stands?

from sparqlwrapper.

wikier avatar wikier commented on May 23, 2024

@psychemedia, do you need header or parameter?

Because for parameter SPARQLWrapper provides something https://github.com/RDFLib/sparqlwrapper/blob/master/SPARQLWrapper/Wrapper.py#L318

But headers we're not yet there.

from sparqlwrapper.

psychemedia avatar psychemedia commented on May 23, 2024

Header....

I wondered about something hacky like adding a parameter into class initialiser:

  def __init__(self, endpoint, updateEndpoint=None, returnFormat=XML, defaultGraph=None, agent=__agent__, extraheaders=None):

  ...
    self.extraheaders = extraheaders if extraheaders else {}

and then fudging the request code:

    def _createRequest(self):
        ...
        for extraheader in self.extraheaders:
            request.add_header(extraheader, self.extraheaders[extraheader])

from sparqlwrapper.

dayures avatar dayures commented on May 23, 2024

@wikier @iherman @indeyets What do you think to add the functionality explained in #52 (comment) ?

from sparqlwrapper.

wikier avatar wikier commented on May 23, 2024

SGTM

from sparqlwrapper.

dayures avatar dayures commented on May 23, 2024

See pull request #103 with an initial approach

from sparqlwrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.