2012-09-14 44 views
1

我正在使用Google文檔列表API來上傳文件以及元數據。Google文檔列表API 308恢復不完整

只要文件小於512KB,我就可以正常工作。在512KB之後,我必須以512KB大小發送它。在每個塊後,我都會收到一個308的HTTP狀態碼,這是正確的。

但是,在我發出最終請求後,我仍然得到308響應,而不是我期望的201響應。以下是發送和接收的HTTP頭。也許其他人可以看到我缺少的東西。

POST /feeds/upload/create-session/default/private/full HTTP/1.1 
Host: docs.google.com 
Accept: */* 
Content-Type: application/atom+xml 
Authorization: Bearer <CODE> 
GData-Version: 3.0 
Content-Type: application/atom+xml 
X-Upload-Content-Length: 1436480 
X-Upload-Content-Type: text/csv 
Content-Length: 302 

HTTP/1.1 200 OK 
Server: HTTP Upload Server Built on Sep 5 2012 17:14:59 (1346890499) 
Location: https://docs.google.com/feeds/upload/create-session/default/private/full?upload_id=<ID> 
Date: Fri, 14 Sep 2012 17:34:50 GMT 
Pragma: no-cache 
Expires: Fri, 01 Jan 1990 00:00:00 GMT 
Cache-Control: no-cache, no-store, must-revalidate 
Content-Length: 0 
Content-Type: text/html; charset=UTF-8 

PUT /feeds/upload/create-session/default/private/full?upload_id=<ID> HTTP/1.1 
Host: docs.google.com 
Accept: */* 
Authorization: Bearer <CODE> 
GData-Version: 3.0 
Content-Type: text/csv 
Content-Range: bytes 0-524288/1436480 
Content-Length: 524288 
Expect: 100-continue 

HTTP/1.1 308 Resume Incomplete 
Server: HTTP Upload Server Built on Sep 5 2012 17:14:59 (1346890499) 
Range: bytes=0-524287 
X-Range-MD5: 8f470cff00adda7c22b8b34287d2cc1b 
Date: Fri, 14 Sep 2012 17:34:52 GMT 
Pragma: no-cache 
Expires: Fri, 01 Jan 1990 00:00:00 GMT 
Cache-Control: no-cache, no-store, must-revalidate 
Content-Length: 0 
Content-Type: text/html; charset=UTF-8 

PUT /feeds/upload/create-session/default/private/full?upload_id=<ID> HTTP/1.1 
Host: docs.google.com 
Accept: */* 
Authorization: Bearer <CODE> 
GData-Version: 3.0 
Content-Type: text/csv 
Content-Range: bytes 524288-1048576/1436480 
Content-Length: 524288 
Expect: 100-continue 

HTTP/1.1 308 Resume Incomplete 
Server: HTTP Upload Server Built on Sep 5 2012 17:14:59 (1346890499) 
Range: bytes=0-1048575 
X-Range-MD5: 4af215a3ff92258bb1c8d05dc52cf77d 
Date: Fri, 14 Sep 2012 17:34:54 GMT 
Pragma: no-cache 
Expires: Fri, 01 Jan 1990 00:00:00 GMT 
Cache-Control: no-cache, no-store, must-revalidate 
Content-Length: 0 
Content-Type: text/html; charset=UTF-8 

PUT /feeds/upload/create-session/default/private/full?upload_id=<ID> HTTP/1.1 
Host: docs.google.com 
Accept: */* 
Authorization: Bearer <CODE> 
GData-Version: 3.0 
Content-Type: text/csv 
Content-Length: 387904 
Expect: 100-continue 

HTTP/1.1 308 Resume Incomplete 
Server: HTTP Upload Server Built on Sep 5 2012 17:14:59 (1346890499) 
Range: bytes=0-1048575 
X-Range-MD5: 4af215a3ff92258bb1c8d05dc52cf77d 
Date: Fri, 14 Sep 2012 17:34:55 GMT 
Pragma: no-cache 
Expires: Fri, 01 Jan 1990 00:00:00 GMT 
Cache-Control: no-cache, no-store, must-revalidate 
Content-Length: 0 
Content-Type: text/html; charset=UTF-8 

編輯

下面是最後一個頭,如果我做的含量範圍上的最後一個PUT請求被髮送。

PUT /feeds/upload/create-session/default/private/full?upload_id=<ID< HTTP/1.1 
Host: docs.google.com 
Accept: */* 
Authorization: Bearer <CODE> 
GData-Version: 3.0 
Content-Type: text/csv 
Content-Range: bytes 1048576-1436480/1436480 
Content-Length: 387904 
Expect: 100-continue 

Got 
HTTP/1.1 400 Bad Request 
Server: HTTP Upload Server Built on Sep 5 2012 17:14:59 (1346890499) 
Content-Type: text/html; charset=UTF-8 
Date: Fri, 14 Sep 2012 19:12:06 GMT 
Pragma: no-cache 
Expires: Fri, 01 Jan 1990 00:00:00 GMT 
Cache-Control: no-cache, no-store, must-revalidate 
Content-Length: 15 
Connection: close 

回答

2

看來您的最後一個請求沒有發送Content-Range。我認爲這是問題,但不確定,因爲我以前從未使用過此API。我只是將我在HTTP規範中知道的內容脫掉。

+0

我將內容範圍添加到最後一個請求,並導致400錯誤。 – Jason

+0

你對內容範圍是正確的。紅色的400個錯誤。 – Jason