谷歌硬盘没有gzipping响应

时间:2013-09-13 06:47:21

标签: windows-phone-8 google-drive-api dotnet-httpclient

我正在为Windows Phone编写SDK以与Google云端硬盘进行互动,但我无法让服务器返回gzipped响应。我可以从我的请求中看到它的简要提及here in the documentation,但我仍然只获得原始数据:

请求:

GET https://www.googleapis.com/drive/v2/files/ HTTP/1.1
Accept: */*
User-Agent: my program (gzip)
Authorization: Bearer [removed]
Accept-Encoding: gzip
Host: www.googleapis.com
If-None-Match: "PA40KOhMf9e-1Hypww_TkG8doNA/jgiBh3LdSV9a9DAu8kcM87C_SgA"
Connection: Keep-Alive

响应:

HTTP/1.1 200 OK
Expires: Fri, 13 Sep 2013 06:31:47 GMT
Date: Fri, 13 Sep 2013 06:31:47 GMT
Cache-Control: private, max-age=0, must-revalidate, no-transform
ETag: "PA40KOhMf9e-1Hypww_TkG8doNA/P9KtUv7cYy7pQSattesAaw0ejBM"
Content-Type: application/json; charset=UTF-8
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 215811
Server: GSE
Alternate-Protocol: 443:quic

以上两种都是使用Fiddler拍摄的。

创建和使用HttpClient的代码,我最初也包括deflate方法,但是当Google提供的示例不包含它时将其删除:

HttpClientHandler Handler = new HttpClientHandler();

if (Handler.SupportsAutomaticDecompression)
{
    Handler.AutomaticDecompression = DecompressionMethods.GZip;
}

HttpClient Client = new HttpClient(Handler);
Client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + Token.AccessToken);
if (Handler.SupportsAutomaticDecompression)
{
    Client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "my program (gzip)" /*"DriveClient (gzip)"*/);
}

HttpResponseMessage Responce = await DriveAuthorisation.DriveHttpClient.GetAsync("https://www.googleapis.com/drive/v2/files/");

谢谢!

0 个答案:

没有答案