[英]writing proper “HEAD” and “GET” request in winsock c++
Actually I was coding for downloading the files in HTTP using winsock c++ and to get the details I fired "HEAD" header.. 实际上,我正在编写代码,使用Winsock C ++在HTTP中下载文件,并获取详细信息,然后启动了“ HEAD”标题。
(this is what actually I did) (这实际上是我所做的)
HEAD /files/ODBC%20Programming%20in%20C%2B%2B.pdf HTTP/1.0 Host: devmentor-unittest.googlecode.com
Response was: 回应是:
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
But if I do: 但是,如果我这样做:
GET /files/ODBC%20Programming%20in%20C%2B%2B.pdf HTTP/1.0 Host: devmentor-unittest.googlecode.com
The file sucessfully gets downloaded.... 文件已成功下载。
After then after I download, again if I fire the HEAD request... it also brings up the following 之后,在我下载之后,再次触发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.....
Question: why "HEAD" is returning the false "error not found" at first but the file gets downloaded in using "GET" and after downloading "HEAD" also returns goodies i need...where have i mistaken.. 问题:为什么“ HEAD”首先返回错误的“找不到错误”,但使用“ GET”下载文件,而在下载“ HEAD”后也返回我需要的东西……我错了。
The file I am trying to download here is " http://devmentor-unittest.googlecode.com/files/ODBC%20Programming%20in%20C%2B%2B.pdf " (just for example) 我要在此处下载的文件是“ http://devmentor-unittest.googlecode.com/files/ODBC%20Programming%20in%20C%2B%2B.pdf ”(仅作为示例)
The problem is not on your end. 问题不在于您。 Google Code simply does not implement HEAD correctly.
Google代码根本无法正确实现HEAD。 This was reported 5 years ago and is still an open issue:
这是5年前的报道,仍然是一个未解决的问题:
Issue 660: support HTTP HEAD method for file download urls 问题660:支持HTTP HEAD方法用于文件下载URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.