javila2311 / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

Should NOT send if-none-match on PUT, PATCH or POST requests #245

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The PHP client will add a if-none-match header for every request, if it finds 
that it has cached that resource before.  This works well for get() (GET) 
methods, but is wrong for update() (PUT), patch() (PATCH) and insert() (POST).

For example:
$someApi->someCollection->get();
   response gets cached
$someApi->someCollection->patch();
   sends along an if-none-match header with the etag obtained in the previous get.  This request gets rejected with a "412 Precondition Failed"
In this case, the header sent should be if-match instead, or no condition used 
at all.

The same thing happens for
$someApi->someCollection->update();
Except that some APIs do not enforce the condition, so the request succeeds.  
If/when the API enforces the condition, clients will receive a 412 instead.
In this case, the header sent should be if-match instead, or no condition used 
at all.

insert() (POST) is a bit strange.
$someApi->someCollection->listSomeCollection();
    response gets cached
$someApi->someCollection->insert()
     sends along an if-none-match header with the etag of the collection from the previous list method call.  It uses the etag of the list because typically, an insert() is a POST to the URL of a collection:
POST /some_collection/
which is the same URL of the list() method:
GET /some_collection/
Sending along the etag for the collection on an insert() (POST) request may or 
may not make sense.  But it should use an if-match header if it's done at all.

What works: get() (GET) works as expected:
$someApi->someCollection->get();
   response gets cached
$someApi->someCollection->get();
   sends along if-none-match header, server replies with "304 Not Modified" and PHP client grabs the resource from the cache.

Original issue reported on code.google.com by dar...@google.com on 9 Jan 2013 at 4:36

GoogleCodeExporter commented 8 years ago

Original comment by ianbar...@google.com on 22 Mar 2013 at 4:42

GoogleCodeExporter commented 8 years ago

Original comment by ianbar...@google.com on 28 Mar 2013 at 5:20

GoogleCodeExporter commented 8 years ago
This issue tracker is now closing. Development on the Google PHP client library 
moved to GitHub with the release of the 1.0.0-alpha, and now the 1.0 branch has 
reached beta status there will be no further releases of the 0.6 branch of the 
library. 

Please take a look at the latest version on 
https://github.com/google/google-api-php-client

For information on migrating, please take a look at this guide: 
https://developers.google.com/api-client-library/php/guide/migration

For general library support please ask a question on StackOverflow: 
http://stackoverflow.com/questions/tagged/google-api-php-client

If you are looking for support with a specific API, please contact the team 
working with that API via StackOverflow or their preferred support mechanism. 

If your issue still exists with the new version of the library, please raise a 
bug in the GitHub issue tracker with a minimal code sample. 

Thanks!

Original comment by ianbar...@google.com on 22 Jan 2014 at 4:53