SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

ETAG is not returned by the server #82

Closed AntonioSpalluto closed 8 years ago

AntonioSpalluto commented 8 years ago

Hi All,

I would like to turn on the ETAG into the server response. As you can see in the following link it is not there, but the doc states it should be always there. http://ag-messagebroker.westeurope.cloudapp.azure.com:8080/info/statistics/ag-virtualroulette-1/10?v0.0.1

Is this something missing into the configuration?

Many Thanks

mkjsix commented 8 years ago

Hi, yes, it must be there. Which version of RESTHeart and MongoDB are you running?

AntonioSpalluto commented 8 years ago

Hi Maurizio,

RestHeart 1.0.3 MongoDB 3.0.7

Thanks

On 23 December 2015 at 19:30, Maurizio Turatti notifications@github.com wrote:

Hi, yes, it must be there. Which version of RESTHeart and MongoDB are you running?

— Reply to this email directly or view it on GitHub https://github.com/SoftInstigate/restheart/issues/82#issuecomment-166964716 .

mkjsix commented 8 years ago

If the document was not created by RESTHeart then the ETAG is not there. You can try PATCHing the document using either curl or httpie without changing anything and RESTHeart should create the missing ETAG

AntonioSpalluto commented 8 years ago

Is there any way to enable the auto creation of the etag on mongodb resources? I cannot see any valid reasons to not enable it.

Antonio Spalluto Chief Technology Officer

Authentic Gaming

http://www.authenticgaming.com

ujibang commented 8 years ago

The _etag is auto created by restheart.

This happens on any write operation (PUT, POST and PATCH)

Of course if data has not been created by restheart, you wont find it there unless your client adds { "_etag": new ObjectId() } to the insert.

To fix it you can PATCH your documents and restheart will add it for you.

If you have many documents you can easily add the _etag from the mongo shell with a batch update.

Adding the _etag property on GET requests as well would violate the http protocol that mandates GET to be always a safe method (doesn't change the status of the resource).

AntonioSpalluto commented 8 years ago

Hi Andrea,

This sounds like the solution for me.

AntonioSpalluto commented 8 years ago

Hi All,

I have a problem with the return of the ETag response header parameter. I just upgraded the version to the 2.0.1 but now I am not getting any etag like it was supposed to be. You can test it from this url: http://ag-messagebroker.westeurope.cloudapp.azure.com:8080/info/statistics/agcasino-virtualroulette1/25

Thanks

ujibang commented 8 years ago

I reopen this

AntonioSpalluto commented 8 years ago

Hi Andrea,

This is quite strange, usually the ETag parameter is always returned into the response header in order to cache it at browser level. In this way it is useless for caching purposes.

What do you think about it?

Thanks

ujibang commented 8 years ago

Hi @AntonioSpalluto

you are right, bug confirmed. will fix asap

https://softinstigate.atlassian.net/browse/RH-201

AntonioSpalluto commented 8 years ago

Thanks.

Looking forward for the new release!

ujibang commented 8 years ago

hi, this is fixed now in 2.0.x branch

will release 2.0.2 next week

thanks for reporting

mkjsix commented 8 years ago

@AntonioSpalluto @ujibang Release 2.0.2 is available now. https://github.com/SoftInstigate/restheart/releases/tag/2.0.2

AntonioSpalluto commented 8 years ago

Thanks a lot for the quick fix