Setting custom HTTP headers and managing HTTPClient parameters

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Setting custom HTTP headers and managing HTTPClient parameters

Philip Coates
Hi,

I've had a good trawl through the archives and haven't been able to find any matching answers (and maybe one unanswered question, http://sourceforge.net/mailarchive/forum.php?thread_name=CAOV7yvB-z4_5Qrosp-s8_7dzgZbR3a%2BUgK3R62SPyBnXxbBhPQ%40mail.gmail.com&forum_name=sesame-general)

We have a requirement to send a transaction ID as an HTTP header with every request we make to a Repository over HTTP (RepositoryConnection operations as well as query/update)

I can see that HTTPClient has set/getAdditionalHttpHeaders methods, but the HTTPClient belonging to the HTTPRepository and HTTP operations isn't public.

Is there a way we can access the client to set these headers on a per-request basis?

More generally, how can we manage the underlying HttpClient settings - timeouts, keepalives, etc.?

Many thanks,

Phil.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting custom HTTP headers and managing HTTPClient parameters

Matteo Moci
Hi, 
I have a similar requirement, where I'd like to limit execution times of some queries over HTTP, 
e.g. all queries to the repository should respond in less than 1000 msecs, 
otherwise they should fail. 

Digging through the codebase, I found it could be done setting the socket timeout to the 
underlying org.apache.commons.httpclient.HttpClient. 

I didn't find docs about it, and I speculate this would be really simple if the method
org.openrdf.http.client.HTTPClient.initialize() would set something like the following: 
params.setSoTimeout(milliseconds). 

Trying to do it in my code didn't help, since it seems there's no way to pass a custom SesameHTTPClient() to the HTTPRepository. 

Has anyone performed something like this? 

Thanks, 
Matteo




On Mon, Jan 27, 2014 at 6:44 PM, Philip Coates <[hidden email]> wrote:
Hi,

I've had a good trawl through the archives and haven't been able to find any matching answers (and maybe one unanswered question, http://sourceforge.net/mailarchive/forum.php?thread_name=CAOV7yvB-z4_5Qrosp-s8_7dzgZbR3a%2BUgK3R62SPyBnXxbBhPQ%40mail.gmail.com&forum_name=sesame-general)

We have a requirement to send a transaction ID as an HTTP header with every request we make to a Repository over HTTP (RepositoryConnection operations as well as query/update)

I can see that HTTPClient has set/getAdditionalHttpHeaders methods, but the HTTPClient belonging to the HTTPRepository and HTTP operations isn't public.

Is there a way we can access the client to set these headers on a per-request basis?

More generally, how can we manage the underlying HttpClient settings - timeouts, keepalives, etc.?

Many thanks,

Phil.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general




--
Matteo Moci
http://mox.fm


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting custom HTTP headers and managing HTTPClient parameters

Matteo Moci
Hi All, 
I saw that on this topic there's a jira at [SES-950]. 

Not really sure it's the right way to go, 
but in attachment you can see that I put together a really minimal patch over branch 2.7.x
in order to let the HTTPRepository be configurable in terms of the socket timeout 
(not connection timeout, the one in [SES-978]). 

If you think it can be useful and matches a specific open issue, 
I can send a pull request following the instructions at [1]. 

Thanks, 
Matteo




On Mon, Apr 14, 2014 at 3:09 PM, Matteo Moci <[hidden email]> wrote:
Hi, 
I have a similar requirement, where I'd like to limit execution times of some queries over HTTP, 
e.g. all queries to the repository should respond in less than 1000 msecs, 
otherwise they should fail. 

Digging through the codebase, I found it could be done setting the socket timeout to the 
underlying org.apache.commons.httpclient.HttpClient. 

I didn't find docs about it, and I speculate this would be really simple if the method
org.openrdf.http.client.HTTPClient.initialize() would set something like the following: 
params.setSoTimeout(milliseconds). 

Trying to do it in my code didn't help, since it seems there's no way to pass a custom SesameHTTPClient() to the HTTPRepository. 

Has anyone performed something like this? 

Thanks, 
Matteo




On Mon, Jan 27, 2014 at 6:44 PM, Philip Coates <[hidden email]> wrote:
Hi,

I've had a good trawl through the archives and haven't been able to find any matching answers (and maybe one unanswered question, http://sourceforge.net/mailarchive/forum.php?thread_name=CAOV7yvB-z4_5Qrosp-s8_7dzgZbR3a%2BUgK3R62SPyBnXxbBhPQ%40mail.gmail.com&forum_name=sesame-general)

We have a requirement to send a transaction ID as an HTTP header with every request we make to a Repository over HTTP (RepositoryConnection operations as well as query/update)

I can see that HTTPClient has set/getAdditionalHttpHeaders methods, but the HTTPClient belonging to the HTTPRepository and HTTP operations isn't public.

Is there a way we can access the client to set these headers on a per-request basis?

More generally, how can we manage the underlying HttpClient settings - timeouts, keepalives, etc.?

Many thanks,

Phil.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general




--
Matteo Moci
http://mox.fm




--
Matteo Moci
http://mox.fm


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general

HTTPRepository-with-socket-timeout.patch (6K) Download Attachment
Loading...