You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2011/02/23 10:05:31 UTC

Fluent interface to httpclient in Stanbol, should that move here?

Hi,

(just subscribed here - I'm a committer on Stanbol and Sling, using
httpclient in both for integration testing)

Longish message ahead, here's the short version: I'm currently working
on http-based integration test tools (SLING-1981, STANBOL-19), created
a few utility classes that provide a simplified "fluent" interface [1]
to httpclient, and I was wondering if it would make sense to move that
code to this project as an optional simplified API.

Here's an example that runs a request against a running http server.
executor is a RequestExecutor that's configured with the server's base
URL.

executor.execute(
  builder.buildGetRequest("/foo", "queryParam1", "value1")
  .withBasicCredentials("me", "pwd")
  .withRedirects(true)
  .withHeader("Accept","text/rdf+nt")
)

Then, as my goal is testing, you can run some assertions on the executor:

executor
  .assertStatus(200)
  .assertContentType("text/rdf+nt")
  .assertContentRegexp(
    "foo.*bar",
    "some other [rR]egexp"
  )

etc...you could also have a different executor that just provides
access to the response content, headers etc. if the goal is not
testing.

Would it make sense to have such an API as an optional component in
this project? That would probably not provide access to the whole
httpclient feature set, but rather provide a very simple way of
executing http requests for the most common use cases.

If yes I'm happy to contribute that code here, assuming the stanbol
folks (where this code currently resides [2]) agree to let it go. I'll
be using that code in various testing scenarios in Stanbol, Sling and
$dayjob, so planning to keep maintaining it, it's not just a fun
short-term experiment.

Let me know what you think.

-Bertrand

[1] http://en.wikipedia.org/wiki/Fluent_interface
[2] http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/testing/http

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Oleg,

On Wed, Apr 6, 2011 at 8:28 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> ...Actually I just realized this might make a great Google Summer of Code
> project. Probably we are already too late for this year but I'll raise a
> JIRA for this idea nonetheless....

Sounds great - if that happens you can count on me for feedback and
ideas where needed!
-Bertrand

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2011-03-24 at 13:53 +0100, Bertrand Delacretaz wrote:
> Hi Oleg,
> 
> On Thu, Mar 24, 2011 at 1:44 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> > ...Is this idea still being considered or did you decide against it?...
> 
> Yes, sorry - once again I bite more than I can chew ;-)
> 
> I thought I would have time to make this happen but unexpected work
> came up and it looks like I won't have much time for this in the next
> few weeks.
> 
> ATM the idea would be to create an API with an independent release
> cycle from the rest of httpclient.
> 
> I'll keep this idea on the backburner for now, and come back here once
> I have something concrete. Or, if someone wants to work on this I'm
> happy to share ideas.
> 
> -Bertrand
> 
> 

Bertrand and all

Actually I just realized this might make a great Google Summer of Code
project. Probably we are already too late for this year but I'll raise a
JIRA for this idea nonetheless.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Oleg,

On Thu, Mar 24, 2011 at 1:44 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> ...Is this idea still being considered or did you decide against it?...

Yes, sorry - once again I bite more than I can chew ;-)

I thought I would have time to make this happen but unexpected work
came up and it looks like I won't have much time for this in the next
few weeks.

ATM the idea would be to create an API with an independent release
cycle from the rest of httpclient.

I'll keep this idea on the backburner for now, and come back here once
I have something concrete. Or, if someone wants to work on this I'm
happy to share ideas.

-Bertrand





> On Wed, 2011-02-23 at 20:48 +0100, Oleg Kalnichevski wrote:
>> On Wed, 2011-02-23 at 10:05 +0100, Bertrand Delacretaz wrote:
>>
>> ...
>>
>> > Would it make sense to have such an API as an optional component in
>> > this project?
>>
>> Hi Bertrand
>>
>> In my opinion, it would. Big time. Given the bad rap that HttpClient
>> gets for what some see as being over-complex, a simpler API for common
>> use scenarios would make a lot of sense. However, I always felt such API
>> should come from an external contributor, from someone with new ideas
>> and a different perspective on things.
>>
>>
>> >  That would probably not provide access to the whole
>> > httpclient feature set, but rather provide a very simple way of
>> > executing http requests for the most common use cases.
>> >
>> > If yes I'm happy to contribute that code here, assuming the stanbol
>> > folks (where this code currently resides [2]) agree to let it go. I'll
>> > be using that code in various testing scenarios in Stanbol, Sling and
>> > $dayjob, so planning to keep maintaining it, it's not just a fun
>> > short-term experiment.
>> >
>> > Let me know what you think.
>> >
>>
>> I think it would be a very welcome contribution to the project.
>>
>> There is a few things that need to be looked at before the source code
>> from Stanbol moves over to HC. First of all, you will need to decide
>> whether the new module should have the same release cycle with
>> HttpClient or be developed and released independently. Both approaches
>> have pros and cons. Sharing the same release cycle with HttpClient would
>> likely require more synchronization with the rest of the HC team and
>> probably create pressure to freeze the API rather sooner than later. A
>> separate release cycle would give you more freedom with choosing release
>> dates and making decisions about API compatibility, but would also
>> require more management overhead. Be warned: HC is a small time project
>> with just a handful of committers and getting those three petty bindings
>> votes might be a challenge some times.
>>
>> As soon as you have those things worked out with the rest of Stanbol
>> folks, we can get you the necessary SVN karma and have you hack away ;-)
>>
>> Cheers
>>
>> Oleg
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Oleg Kalnichevski <ol...@apache.org>.
Hi Bertrand

Just a ping...

Is this idea still being considered or did you decide against it?

Cheers

Oleg



On Wed, 2011-02-23 at 20:48 +0100, Oleg Kalnichevski wrote:
> On Wed, 2011-02-23 at 10:05 +0100, Bertrand Delacretaz wrote:
> 
> ...
> 
> > Would it make sense to have such an API as an optional component in
> > this project?
> 
> Hi Bertrand
> 
> In my opinion, it would. Big time. Given the bad rap that HttpClient
> gets for what some see as being over-complex, a simpler API for common
> use scenarios would make a lot of sense. However, I always felt such API
> should come from an external contributor, from someone with new ideas
> and a different perspective on things.
> 
> 
> >  That would probably not provide access to the whole
> > httpclient feature set, but rather provide a very simple way of
> > executing http requests for the most common use cases.
> > 
> > If yes I'm happy to contribute that code here, assuming the stanbol
> > folks (where this code currently resides [2]) agree to let it go. I'll
> > be using that code in various testing scenarios in Stanbol, Sling and
> > $dayjob, so planning to keep maintaining it, it's not just a fun
> > short-term experiment.
> > 
> > Let me know what you think.
> > 
> 
> I think it would be a very welcome contribution to the project. 
> 
> There is a few things that need to be looked at before the source code
> from Stanbol moves over to HC. First of all, you will need to decide
> whether the new module should have the same release cycle with
> HttpClient or be developed and released independently. Both approaches
> have pros and cons. Sharing the same release cycle with HttpClient would
> likely require more synchronization with the rest of the HC team and
> probably create pressure to freeze the API rather sooner than later. A
> separate release cycle would give you more freedom with choosing release
> dates and making decisions about API compatibility, but would also
> require more management overhead. Be warned: HC is a small time project
> with just a handful of committers and getting those three petty bindings
> votes might be a challenge some times.
> 
> As soon as you have those things worked out with the rest of Stanbol
> folks, we can get you the necessary SVN karma and have you hack away ;-)
> 
> Cheers
> 
> Oleg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-02-23 at 10:05 +0100, Bertrand Delacretaz wrote:

...

> Would it make sense to have such an API as an optional component in
> this project?

Hi Bertrand

In my opinion, it would. Big time. Given the bad rap that HttpClient
gets for what some see as being over-complex, a simpler API for common
use scenarios would make a lot of sense. However, I always felt such API
should come from an external contributor, from someone with new ideas
and a different perspective on things.


>  That would probably not provide access to the whole
> httpclient feature set, but rather provide a very simple way of
> executing http requests for the most common use cases.
> 
> If yes I'm happy to contribute that code here, assuming the stanbol
> folks (where this code currently resides [2]) agree to let it go. I'll
> be using that code in various testing scenarios in Stanbol, Sling and
> $dayjob, so planning to keep maintaining it, it's not just a fun
> short-term experiment.
> 
> Let me know what you think.
> 

I think it would be a very welcome contribution to the project. 

There is a few things that need to be looked at before the source code
from Stanbol moves over to HC. First of all, you will need to decide
whether the new module should have the same release cycle with
HttpClient or be developed and released independently. Both approaches
have pros and cons. Sharing the same release cycle with HttpClient would
likely require more synchronization with the rest of the HC team and
probably create pressure to freeze the API rather sooner than later. A
separate release cycle would give you more freedom with choosing release
dates and making decisions about API compatibility, but would also
require more management overhead. Be warned: HC is a small time project
with just a handful of committers and getting those three petty bindings
votes might be a challenge some times.

As soon as you have those things worked out with the rest of Stanbol
folks, we can get you the necessary SVN karma and have you hack away ;-)

Cheers

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Fluent interface to httpclient in Stanbol, should that move here?

Posted by Thom Nichols <tm...@gmail.com>.
FWIW, the HTTPBuilder project also aims to "put a pretty face" on
HttpClient.  However HTTPBuilder is written for Groovy, so...  You have to
write Groovy to use it :)

http://groovy.codehaus.org/modules/http-builder

-Thom


On Wed, Feb 23, 2011 at 4:05 AM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> Hi,
>
> (just subscribed here - I'm a committer on Stanbol and Sling, using
> httpclient in both for integration testing)
>
> Longish message ahead, here's the short version: I'm currently working
> on http-based integration test tools (SLING-1981, STANBOL-19), created
> a few utility classes that provide a simplified "fluent" interface [1]
> to httpclient, and I was wondering if it would make sense to move that
> code to this project as an optional simplified API.
>
> Here's an example that runs a request against a running http server.
> executor is a RequestExecutor that's configured with the server's base
> URL.
>
> executor.execute(
>  builder.buildGetRequest("/foo", "queryParam1", "value1")
>  .withBasicCredentials("me", "pwd")
>  .withRedirects(true)
>  .withHeader("Accept","text/rdf+nt")
> )
>
> Then, as my goal is testing, you can run some assertions on the executor:
>
> executor
>  .assertStatus(200)
>  .assertContentType("text/rdf+nt")
>  .assertContentRegexp(
>    "foo.*bar",
>    "some other [rR]egexp"
>  )
>
> etc...you could also have a different executor that just provides
> access to the response content, headers etc. if the goal is not
> testing.
>
> Would it make sense to have such an API as an optional component in
> this project? That would probably not provide access to the whole
> httpclient feature set, but rather provide a very simple way of
> executing http requests for the most common use cases.
>
> If yes I'm happy to contribute that code here, assuming the stanbol
> folks (where this code currently resides [2]) agree to let it go. I'll
> be using that code in various testing scenarios in Stanbol, Sling and
> $dayjob, so planning to keep maintaining it, it's not just a fun
> short-term experiment.
>
> Let me know what you think.
>
> -Bertrand
>
> [1] http://en.wikipedia.org/wiki/Fluent_interface
> [2]
> http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/testing/http
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>