AppEngine中的Go语言在使用urlfetch.Head时没有返回Content-Length。

huangapple go评论87阅读模式
英文:

AppEngine in Go not returning Content-Length from urlfetch.Head

问题

我正在尝试对一个URL执行HEAD请求,以便获取Content-Length头,并进行范围请求。

然而,我发现在使用urlfetch.Head时,AppEngine不会返回Content-Length头。文档对于响应是明确的,但对于请求则没有提到。

以下是使用Go库的net/http时的正确工作示例:

Last-Modified:[Fri, 09 Aug 2013 23:54:35 GMT]
Server:[ECS (iad/182A)]
Content-Length:[1270]
Accept-Ranges:[bytes]
Cache-Control:[max-age=604800]
Date:[Thu, 09 Oct 2014 20:38:01 GMT]
X-Cache:[HIT]
X-Ec-Custom-Error:[1]
Content-Type:[text/html]
Etag:["359670651"]
Expires:[Thu, 16 Oct 2014 20:38:01 GMT]

在我看来,没有Content-LengthHEAD请求有点无用。是否有任何解决方案?

谢谢。

英文:

I am trying to perform a HEAD request to a URL so I can get the Content-Length header and then do Range requests.

However I found out AppEngine doesn't return the Content-Length header when doing urlfetch.Head. The documentation is explicit about it for responses, but not for requests.

Etag:["359670651"]
Expires:[Thu, 16 Oct 2014 20:41:52 GMT]
Server:[ECS (mdw/1275)]
X-Cache:[HIT]
X-Ec-Custom-Error:[1]
X-Google-Cache-Control:[remote-fetch]
Accept-Ranges:[bytes]
Cache-Control:[max-age=604800]
Content-Type:[text/html]
Date:[Thu, 09 Oct 2014 20:41:52 GMT]
Last-Modified:[Fri, 09 Aug 2013 23:54:35 GMT]

It works correctly when using net/http of the Go library.

Last-Modified:[Fri, 09 Aug 2013 23:54:35 GMT]
Server:[ECS (iad/182A)]
Content-Length:[1270]
Accept-Ranges:[bytes]
Cache-Control:[max-age=604800]
Date:[Thu, 09 Oct 2014 20:38:01 GMT]
X-Cache:[HIT]
X-Ec-Custom-Error:[1]
Content-Type:[text/html]
Etag:["359670651"]
Expires:[Thu, 16 Oct 2014 20:38:01 GMT]

Is there any solution to this? A HEAD request without the Content-Length is kind of useless in my opinion.

Thanks.

答案1

得分: 0

出于我理解之外的原因,App Engine在任何请求方法的响应头中不包含内容长度。

英文:

For reasons beyond my understanding, App Engine does not include the content length in the response Header for any request method.

huangapple
  • 本文由 发表于 2014年10月10日 04:47:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/26287665.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定