ETAG未在PATCH响应中更新

时间:2013-10-08 20:42:51

标签: google-drive-api

我正在测试使用Drive API v2的应用程序,我注意到我不是 在PATCH请求的响应中获取新的ETag。

我使用Google API Explorer进行了一些测试。这是PATCH请求:

PATCH https://www.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28?key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ...
X-JavaScript-User-Agent:  Google APIs Explorer

{
  "title": "file.tmp"
}

这是显示ETag "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ"

的PATCH响应的开始
200 OK

Cache-Control:  no-cache, no-store, max-age=0, must-revalidate
Content-Encoding:  gzip
Content-Length:  1019
Content-Type:  application/json; charset=UTF-8
Date:  Tue, 08 Oct 2013 19:46:36 GMT
Etag:  "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ"
Expires:  Fri, 01 Jan 1990 00:00:00 GMT
Pragma:  no-cache
Server:  GSE

{
  "kind": "drive#file",
  "id": "0B-TenPiSMBplMTJnVlYxTEEwQ28",
  "etag": "\"EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ\"",
  "selfLink": "https://content.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28",
  "webContentLink": "https://docs.google.com/uc?id=0B-TenPiSMBplMTJnVlYxTEEwQ28&export=download",
  "alternateLink": "https://docs.google.com/file/d/0B-TenPiSMBplMTJnVlYxTEEwQ28/edit?usp=drivesdk",
  "iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png",
  "title": "file.tmp",

但是如果我在PATCH之后做了GET请求:

GET https://www.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28?key={YOUR_API_KEY}

Authorization:  Bearer ...
X-JavaScript-User-Agent:  Google APIs Explorer

在回复中,我获得了更新的ETag("EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg"):

200 OK

Cache-Control:  private, max-age=0, must-revalidate, no-transform
Content-Encoding:  gzip
Content-Length:  1021
Content-Type:  application/json; charset=UTF-8
Date:  Tue, 08 Oct 2013 19:48:44 GMT
Etag:  "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg"
Expires:  Tue, 08 Oct 2013 19:48:44 GMT
Server:  GSE

{
  "kind": "drive#file",
  "id": "0B-TenPiSMBplMTJnVlYxTEEwQ28",
  "etag": "\"EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg\"",
  "selfLink": "https://content.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28",
  "webContentLink": "https://docs.google.com/uc?id=0B-TenPiSMBplMTJnVlYxTEEwQ28&export=download",
  "alternateLink": "https://docs.google.com/file/d/0B-TenPiSMBplMTJnVlYxTEEwQ28/edit?usp=drivesdk",
  "iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png",
  "title": "file.tmp",

这是预期的行为吗?我期待着获得更新的ETag PATCH响应以避免另一次往返服务器。另请注意我 使用PUT而不是PATCH经历了相同的行为。

1 个答案:

答案 0 :(得分:1)

可悲的是,Drive在某种程度上是异步的。在PATCH完成后,etags和一些URL等异步填充。