restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
Other
654 stars 284 forks source link

Construction of ClientResource creates an initial GET request #657

Open rwallingsford opened 12 years ago

rwallingsford commented 12 years ago

// Request MyResource resource =new ClientResource("http://127.0.0.1:8889/rest/xxxx ").wrap(MyResource.class); resource.post(myObject);

Construction of a ClientResource with URI as parameter creates an initial GET request.

ClientResource cr = new ClientResource("http://127.0.0.1:8889/rest/xxxx") ; <- creates an initial GET request prior to post being invoked on the resource. Then when post is invoked makes another request with the proper HTTP Method. I receive a HTTP response status of 405 when the server only accepts POST method.

JavaSE 6.x Restlet Bundle-Version: 2.0.14.0 Bundle-Vendor: Restlet S.A.S.

Is there a way to eliminate the initial GET request?

Tembrel commented 12 years ago

I'm not seeing an additional request from the call to wrap() using Restlet 2.1-RC6, so maybe this is something to do with 2.0? But I'm confused by your sample code:

ClientResource cr = new ClientResource("http://127.0.0.1:8889/rest/xxxx ").wrap(MyResource.class);

This shouldn't compile unless MyResource extends ClientResource. And if MyResource does extend ClientResource, it's not an interface, and the program shouldn't run.

--tim

On Thu, Sep 20, 2012 at 6:12 AM, rwallingsford notifications@github.comwrote:

Construction of a ClientResource with URI as parameter creates an initial GET request.

ClientResource cr = new ClientResource(" http://127.0.0.1:8889/rest/xxxx").wrap(MyResource.class) ; <- creates an initial GET request prior to wrap being invoked. Then when wrap is invoked makes another request with the proper HTTP Method. I receive a HTTP response status of 405 when the server only accepts POST method.

JavaSE 6.x Restlet Bundle-Version: 2.0.14.0 Bundle-Vendor: Restlet S.A.S.

Is there a way to eliminate the initial GET request?

— Reply to this email directly or view it on GitHubhttps://github.com/restlet/restlet-framework-java/issues/657.

rwallingsford commented 12 years ago

Sorry, I updated the description as follows:

// Request ArbitraryResource ar = new ClientResource(" http://127.0.0.1:8889/rest/xxxx").wrap(NameKeyRecordListResource.class); ar.post(ar)

Construction of a ClientResource with URI as parameter creates an initial GET request.

ClientResource cr = new ClientResource("http://127.0.0.1:8889/rest/xxxx") ; <- creates an initial GET request prior to post being invoked on the resource. Then when post is invoked makes another request with the proper HTTP Method. I receive a HTTP response status of 405 when the server only accepts POST method.

JavaSE 6.x Restlet Bundle-Version: 2.0.14.0 Bundle-Vendor: Restlet S.A.S.

Is there a way to eliminate the initial GET request?

On Thu, Sep 20, 2012 at 8:21 AM, Tim Peierls notifications@github.comwrote:

I'm not seeing an additional request from the call to wrap() using Restlet 2.1-RC6, so maybe this is something to do with 2.0? But I'm confused by your sample code:

ClientResource cr = new ClientResource("http://127.0.0.1:8889/rest/xxxx ").wrap(MyResource.class);

This shouldn't compile unless MyResource extends ClientResource. And if MyResource does extend ClientResource, it's not an interface, and the program shouldn't run.

--tim

On Thu, Sep 20, 2012 at 6:12 AM, rwallingsford notifications@github.comwrote:

Construction of a ClientResource with URI as parameter creates an initial GET request.

ClientResource cr = new ClientResource(" http://127.0.0.1:8889/rest/xxxx").wrap(MyResource.class) ; <- creates an initial GET request prior to wrap being invoked. Then when wrap is invoked makes another request with the proper HTTP Method. I receive a HTTP response status of 405 when the server only accepts POST method.

JavaSE 6.x Restlet Bundle-Version: 2.0.14.0 Bundle-Vendor: Restlet S.A.S.

Is there a way to eliminate the initial GET request?

— Reply to this email directly or view it on GitHub< https://github.com/restlet/restlet-framework-java/issues/657>.

— Reply to this email directly or view it on GitHubhttps://github.com/restlet/restlet-framework-java/issues/657#issuecomment-8726615.

rwallingsford commented 12 years ago

MyResource resource =new ClientResource("http://127.0.0.1:8889/rest/xxxx").wrap(MyResource.class); resource.post(myObject);

copy and pasting code fragments didn't work so well.

On Thu, Sep 20, 2012 at 8:21 AM, Tim Peierls notifications@github.comwrote:

I'm not seeing an additional request from the call to wrap() using Restlet 2.1-RC6, so maybe this is something to do with 2.0? But I'm confused by your sample code:

ClientResource cr = new ClientResource("http://127.0.0.1:8889/rest/xxxx ").wrap(MyResource.class);

This shouldn't compile unless MyResource extends ClientResource. And if MyResource does extend ClientResource, it's not an interface, and the program shouldn't run.

--tim

On Thu, Sep 20, 2012 at 6:12 AM, rwallingsford notifications@github.comwrote:

Construction of a ClientResource with URI as parameter creates an initial GET request.

ClientResource cr = new ClientResource(" http://127.0.0.1:8889/rest/xxxx").wrap(MyResource.class) ; <- creates an initial GET request prior to wrap being invoked. Then when wrap is invoked makes another request with the proper HTTP Method. I receive a HTTP response status of 405 when the server only accepts POST method.

JavaSE 6.x Restlet Bundle-Version: 2.0.14.0 Bundle-Vendor: Restlet S.A.S.

Is there a way to eliminate the initial GET request?

— Reply to this email directly or view it on GitHub< https://github.com/restlet/restlet-framework-java/issues/657>.

— Reply to this email directly or view it on GitHubhttps://github.com/restlet/restlet-framework-java/issues/657#issuecomment-8726615.

Tembrel commented 12 years ago

I wasn't able to reproduce this on 2.1-RC6.

rwallingsford commented 12 years ago

What about 2.0.14? 2.1 isn't stable yet, so I can't simply roll into my codebase. Are you saying to download 2.1? I see it's in the test phase - when will it be marked stable?

On Thu, Sep 20, 2012 at 8:45 AM, Tim Peierls notifications@github.comwrote:

I wasn't able to reproduce this on 2.1-RC6.

— Reply to this email directly or view it on GitHubhttps://github.com/restlet/restlet-framework-java/issues/657#issuecomment-8727200.

Tembrel commented 12 years ago

Not saying anything except that anyone else trying to reproduce this shouldn't bother checking against recent code. I have no idea when 2.1 will have a general release. (I've been using it in production for months.)

Here's my test code: https://pastebin.com/2MhRHquv

It passes on 2.1-RC6. Could someone run it on 2.0.14?