|
List Info
Thread: Using POST instead of GET for Sparql queries
|
|
| Using POST instead of GET for Sparql
queries |

|
2007-09-22 19:41:06 |
|
Hi ActiveRDF crew,
First off, thanks very much for an excellent library.
I'm using ActiveRDF as a wrapper around hand-written SPARQL queries, a la "results = SPARQL.execute_sparql_query(query_string)"
I39;ve run into the problem that some of my queries are overloading the buffer on my server (currently Jetty, wrapping Joseki) because they are encoded in the URL of a GET request. I know this is a problem with the server, but I think the simpler workaround would be to modify ActiveRDF to put the parameters in the body of a POST request instead of the URL of a GET.
Right now, the SparqlAdapter code encodes the query as follows:
def execute_sparql_query(qs, header=nil, &block) header = header(nil) if header.nil? # encoding query string in URL
url = "# url?query=#{CGI.escape(qs)}"
Has anyone adapted this to put it in the body of a POST request? Is this an easy thing to do?
Thanks! Ted
-- Edward Benson
http://www.edwardbenson.com/
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-09-26 01:48:00 |
On 23.09.2007, at 02:41, Edward Benson wrote:
> I've run into the problem that some of my queries are
overloading
> the buffer on my server (currently Jetty, wrapping
Joseki) because
> they are encoded in the URL of a GET request. I know
this is a
> problem with the server, but I think the simpler
workaround would
> be to modify ActiveRDF to put the parameters in the
body of a POST
> request instead of the URL of a GET.
>
> Right now, the SparqlAdapter code encodes the query as
follows:
>
> def execute_sparql_query(qs, header=nil,
&block)
> header = header(nil) if header.nil?
> # encoding query string in URL
> url = "# url?query=#{CGI.escape(qs)}"
>
> Has anyone adapted this to put it in the body of a POST
request? Is
> this an easy thing to do?
I guess it is possible. Right now neither Eyal nor me has a
lot of
time to look how to implement that. Maybe if you find out
how to
construct a POST query, then I could implement it.
It would also be important to see what the SPARQL spec says:
Is it
important if GET or POST are used? Are there differences?
Does this
have to be negotiated between client and server ?
_______________________________________________
ActiveRDF mailing list
ActiveRDF lists.deri.org
http
://lists.deri.org/mailman/listinfo/activerdf
|
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-09-26 02:39:51 |
|
The Rails team once did the mistake of using POST instead of GET to do what GET is supposed to do. Initially it worked but nevertheless they learned that it is wrong practice. Imagine when a google bot comes in and finds a destructive POST link...
Are you convinced that Joseki would be faster with POST instead of GET? Would it be easier to switch to Virtuoso, which should be faster?
2007/9/26, Benjamin Heitmann <
benjamin.heitmann deri.org">benjamin.heitmann deri.org>: On
23.09.2007, at 02:41, Edward Benson wrote: > I've run into the problem that some of my queries are overloading > the buffer on my server (currently Jetty, wrapping Joseki) because > they are encoded in the URL of a GET request. I know this is a
> problem with the server, but I think the simpler workaround would > be to modify ActiveRDF to put the parameters in the body of a POST > request instead of the URL of a GET. > > Right now, the SparqlAdapter code encodes the query as follows:
> > def execute_sparql_query(qs, header=nil, &block) > header = header(nil) if header.nil? > # encoding query string in URL > url = "# url?query=#{CGI.escape
(qs)}" > > Has anyone adapted this to put it in the body of a POST request? Is > this an easy thing to do?
I guess it is possible. Right now neither Eyal nor me has a lot of time to look how to implement that. Maybe if you find out how to
construct a POST query, then I could implement it.
It would also be important to see what the SPARQL spec says: Is it important if GET or POST are used? Are there differences? Does this have to be negotiated between client and server ?
_______________________________________________ ActiveRDF mailing list ActiveRDF lists.deri.org">ActiveRDF lists.deri.org http://lists.deri.org/mailman/listinfo/activerdf
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-09-26 13:20:43 |
|
Benjamin --
Thanks for your response. I added the ability to choose between POST and GET in the SPARQL adapter. It seems to be working well. I've included my changes below if you'd like to incorporate them into the ActiveRDF code.
Scanning the SPARQL language spec, I can't find the endpoint definition, so I'm not sure if POST is supported. Nevertheless, the inability to perform lengthy SPARQL queries through GET seems to necessitate the need for POST-based queries.
Mikael -> I agree with you 100% that POST & GET should be used in RESTful / Old-Skool HTTP fashion when it comes to the web, but I think SPARQL is a special case. A SPARQL URI does not represent a resource, it represents a service endpoint. It is a service that happens to be offered over HTTP rather than a interlinked part of the WWW. When Seaborne et al's, SPARQL/Update changes are integrated into sparql, they will be done so as part of the language and not using the HTTP commands. So I think this is one case where it is alright to treat HTTP as nothing more than a transport, and the various HTTP commands as just various different sub-types of that transport with different properties.
Cheers, Ted
Changes -----------------
In the initialize constructor, I added the line:
request_method = params[:request_method] || :get
And then in the execute_sparql_query, I replaced some of the existing code with the following:
begin if request_method == :get url = "# url?query=#{CGI.escape(qs)}" url = url.gsub("DISTINCT", "") if yars2 response = ''
open(url, header) do |f| response = f.read end else res = Net::HTTP.post_form(URI.parse( url),{';query'=>qs})
end response = res.body rescue ....
On 9/26/07, Benjamin Heitmann < benjamin.heitmann deri.org">
benjamin.heitmann deri.org> wrote: On 23.09.2007, at 02:41, Edward Benson wrote:
> I've run into the problem that some of my queries are overloading > the buffer on my server (currently Jetty, wrapping Joseki) because > they are encoded in the URL of a GET request. I know this is a
> problem with the server, but I think the simpler workaround would > be to modify ActiveRDF to put the parameters in the body of a POST > request instead of the URL of a GET. > > Right now, the SparqlAdapter code encodes the query as follows:
> > def execute_sparql_query(qs, header=nil, &block) > header = header(nil) if header.nil? > # encoding query string in URL > url = "# url?query=#{CGI.escape
(qs)}" > > Has anyone adapted this to put it in the body of a POST request? Is > this an easy thing to do?
I guess it is possible. Right now neither Eyal nor me has a lot of time to look how to implement that. Maybe if you find out how to
construct a POST query, then I could implement it.
It would also be important to see what the SPARQL spec says: Is it important if GET or POST are used? Are there differences? Does this have to be negotiated between client and server ?
_______________________________________________ ActiveRDF mailing list ActiveRDF lists.deri.org">ActiveRDF lists.deri.org http://lists.deri.org/mailman/listinfo/activerdf
-- Edward Benson http://www.edwardbenson.com/
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-09-26 13:48:37 |
|
Correction:
The line "response = res.body" should have been before the "end" statement. Sorry 'bout that.
Ted
On 9/26/07,
Edward Benson < edward.benson gmail.com">edward.benson gmail.com> wrote:
Benjamin --
Thanks for your response. I added the ability to choose between POST and GET in the SPARQL adapter. It seems to be working well. I've included my changes below if you'd like to incorporate them into the ActiveRDF code.
Scanning the SPARQL language spec, I can't find the endpoint definition, so I'm not sure if POST is supported. Nevertheless, the inability to perform lengthy SPARQL queries through GET seems to necessitate the need for POST-based queries.
Mikael -> I agree with you 100% that POST & GET should be used in RESTful / Old-Skool HTTP fashion when it comes to the web, but I think SPARQL is a special case. A SPARQL URI does not represent a resource, it represents a service endpoint. It is a service that happens to be offered over HTTP rather than a interlinked part of the WWW. When Seaborne et al's, SPARQL/Update changes are integrated into sparql, they will be done so as part of the language and not using the HTTP commands. So I think this is one case where it is alright to treat HTTP as nothing more than a transport, and the various HTTP commands as just various different sub-types of that transport with different properties.
Cheers, Ted
Changes -----------------
In the initialize constructor, I added the line:
request_method = params[:request_method] || :get
And then in the execute_sparql_query, I replaced some of the existing code with the following:
begin if request_method == :get url = "# url?query=#{CGI.escape(qs)}" url = url.gsub("DISTINCT", "") if yars2
response = ''
open(url, header) do |f| response = f.read end else res = Net::HTTP.post_form(URI.parse( url),{';query'=>qs})
end response = res.body rescue ....
On 9/26/07,
Benjamin Heitmann < benjamin.heitmann deri.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
benjamin.heitmann deri.org> wrote: On 23.09.2007, at 02:41, Edward Benson wrote:
> I've run into the problem that some of my queries are overloading > the buffer on my server (currently Jetty, wrapping Joseki) because > they are encoded in the URL of a GET request. I know this is a
> problem with the server, but I think the simpler workaround would > be to modify ActiveRDF to put the parameters in the body of a POST > request instead of the URL of a GET. > > Right now, the SparqlAdapter code encodes the query as follows:
> > def execute_sparql_query(qs, header=nil, &block) > header = header(nil) if header.nil? > # encoding query string in URL > url = "# url?query=#{CGI.escape
(qs)}" > > Has anyone adapted this to put it in the body of a POST request? Is > this an easy thing to do?
I guess it is possible. Right now neither Eyal nor me has a lot of time to look how to implement that. Maybe if you find out how to
construct a POST query, then I could implement it.
It would also be important to see what the SPARQL spec says: Is it important if GET or POST are used? Are there differences? Does this have to be negotiated between client and server ?
_______________________________________________ ActiveRDF mailing list ActiveRDF lists.deri.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ActiveRDF lists.deri.org
http://lists.deri.org/mailman/listinfo/activerdf
-- Edward Benson http://www.edwardbenson.com/
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-10-01 04:35:22 |
On 09/26/07/09/07 14:20 -0400, Edward Benson wrote:
>Benjamin --
>
>Thanks for your response. I added the ability to choose
between POST and GET
>in the SPARQL adapter. It seems to be working well. I've
included my changes
>below if you'd like to incorporate them into the
ActiveRDF code.
thanks for that. Would it maybe be possible for you to send
these changes
in a diff file [1]? Using bzr, diffs are even easier to
generate [2].
>Scanning the SPARQL language spec, I can't find the
endpoint definition, so
>I'm not sure if POST is supported. Nevertheless, the
inability to perform
>lengthy SPARQL queries through GET seems to necessitate
the need for
>POST-based queries.
It's in the SPARQL protocol definition [3], not in the query
language.
Until your email, I didn't even know you could use POSTs.
-eyal
[1] http://laughingmeme.org/2004/02/18/how-to-make-a-pat
ch-file/
[2] http://blogs.gnome.org/jamesh/2007/07/31/bazaar-bundles/
[3] http://www.
w3.org/TR/rdf-sparql-protocol/
_______________________________________________
ActiveRDF mailing list
ActiveRDF lists.deri.org
http
://lists.deri.org/mailman/listinfo/activerdf
|
|
| Re: Using POST instead of GET for
Sparql queries |

|
2007-10-01 04:46:55 |
On 10/01/07/10/07 11:35 +0200, Eyal Oren wrote:
> thanks for that. Would it maybe be possible for you to
send these changes
> in a diff file [1]? Using bzr, diffs are even easier to
generate [2].
Actually, I now incorporated your changes manually already
so you can save
the diff for the next time
I'll release the updated SPARQL adapter gem shortly.
-eyal
_______________________________________________
ActiveRDF mailing list
ActiveRDF lists.deri.org
http
://lists.deri.org/mailman/listinfo/activerdf
|
|
[1-7]
|
|