已发送 Wininet headers

Wininet get sent headers

要收到 headers,我可以使用 HttpQueryInfoHTTP_QUERY_RAW_HEADERS_CRLF。例如:

HTTP/1.1 200 OK
P3P: CP="Facebook does not have a P3P policy. Learn why here: redacted"
X-Frame-Options: DENY
X-XSS-Protection: 0
Cache-Control: private, no-cache, no-store, must-revalidate
Access-Control-Allow-Credentials: true
Pragma: no-cache
Vary: Origin
X-UA-Compatible: IE=edge,chrome=1
Access-Control-Allow-Origin: https://www.facebook.com
Access-Control-Expose-Headers: X-FB-Debug, X-Loader-Length
public-key-pins-report-only: max-age=500; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="; pin-sha256="q4PO2G2cbkZhZ82+JgmRUyGMoAeozA+BSXVXQWB8XWQ="; report-uri="http://reports.fb.com/hpkp/"
access-control-allow-method: OPTIONS
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Strict-Transport-Security: max-age=15552000; preload
Content-Type: application/x-javascript; charset=utf-8
X-Content-Type-Options: nosniff
Set-Cookie: wd=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=-1484605344; path=/; domain=.facebook.com
X-FB-Debug: /OHaVJSuytlHcr5FJIHmFiJqDzXnpxG/byzwfSyKVoVEapJ7CB18C31eP/nCS26tXOIGAWFmqrswR4yA4QaJIQ==
Date: Mon, 16 Jan 2017 22:22:25 GMT
Transfer-Encoding: chunked
Connection: keep-alive

但是如何发送 headers?例如:

POST /ajax/bz HTTP/1.1
Host: www.facebook.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Referer: https://www.facebook.com/
Content-Length: 610
Cookie: datr=KpR3WHnG8o9SSyjynboqoEFi; fr=0cgVuSHdECAqWqoBP..BYd5Qq.1M.AAA.0.0.BYfAc8.AWVTBVEg; _js_reg_fb_ref=https%3A%2F%2Fwww.facebook.com%2F; _js_reg_fb_gate=https%3A%2F%2Fwww.facebook.com%2F
Connection: keep-alive

抱歉,如果我的 post 大部分被识别为代码,因为我知道我有时不清楚,我想确保人们理解我想要将 headers 发送到服务器收到的那些。

发送请求后(或至少收到 INTERNET_STATUS_REQUEST_SENT 状态事件后),您可以使用 HttpQueryInfo() 同时指定 HTTP_QUERY_RAW_HEADERS/_CRLFHTTP_QUERY_FLAG_REQUEST_HEADERS 标志。