2013-10-08 56 views
1

我正在測試使用Drive API v2的應用程序,並且我注意到我並不是 在PATCH請求的響應中獲取新的ETag。ETag未在PATCH響應中更新

我使用Google API Explorer進行了一些測試。這是補丁請求:

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"的開頭:

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", 

但是,如果我做一個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", 

這是預期的行爲?我期待在 PATCH響應中獲得更新的ETag,以避免再往返服務器。還要注意我使用PUT而不是PATCH經歷了相同的行爲。

回答

1

不幸的是,Drive在引擎蓋下有些異步。在PATCH完成後,像etags和一些URL之類的東西會異步填充。