簡體   English   中英

在Winsock C ++中編寫正確的“ HEAD”和“ GET”請求

[英]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年前的報道,仍然是一個未解決的問題:

問題660:支持HTTP HEAD方法用於文件下載URL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM