[英]writing proper “HEAD” and “GET” request in winsock c++
实际上,我正在编写代码,使用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 ”(仅作为示例)
问题不在于您。 Google代码根本无法正确实现HEAD。 这是5年前的报道,仍然是一个未解决的问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.