我正在使用 Google Document List API 上传文件和元数据。
只要文件小于 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