实际上我正在编写使用winsock c ++在HTTP中下载文件的代码并获取详细信息我解雇了“HEAD”标题..
(这实际上是我做的)
HEAD /files/ODBC%20Programming%20in%20C%2B%2B.pdf HTTP/1.0 Host: devmentor-unittest.googlecode.com
回应是:
HTTP/1.0 404 Not Found Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=feeed8106df5e5f1:TM=1370157208:LM=1370157208:S=10bN4nrXqkcCDN5n; expires=Tue, 02-Jun-2015 07:13:28 GMT; path=/; domain=devmentor-unittest.googlecode.com X-Content-Type-Options: nosniff Date: Sun, 02 Jun 2013 07:13:28 GMT Server: codesite_downloads Content-Length: 974 X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN
但如果我这样做:
GET /files/ODBC%20Programming%20in%20C%2B%2B.pdf HTTP/1.0 Host: devmentor-unittest.googlecode.com
文件成功下载....
在我下载之后,再次,如果我触发HEAD请求......它还会显示以下内容
HTTP/1.0 200 OK Content-Length: 320381 Content-Type: application/pdf Content-Disposition: attachment; filename="ODBC Programming in C++.pdf" Accept-Ranges: bytes Date: Sun, 02 Jun 2013 05:47:11 GMT Last-Modified: Sun, 11 Nov 2007 03:17:59 GMT Expires: Sun, 09 Jun 2013 05:47:11 GMT Cache-Control: public, max-age=604800 Server: DFE/largefile //something like this.....
问题:为什么“HEAD”首先返回错误的“错误未找到”,但是使用“GET”下载文件,下载“HEAD”后还返回我需要的好东西......哪里有错误..
我想在这里下载的文件是“http://devmentor-unittest.googlecode.com/files/ODBC%20Programming%20in%20C%2B%2B.pdf”(仅举例)
答案 0 :(得分:0)
问题不在于你。 Google代码只是没有正确实现HEAD。据报道 5年前,这仍是一个悬而未决的问题: