使用HttpAddRequestHeaders设置的标头与在HttpSendRequest函数中设置的标头之间有什么区别? [英] What's the difference between the headers set with HttpAddRequestHeaders and that ones set within HttpSendRequest function?
问题描述
我正在试图找出设置我的http标头的正确位置。 WinInet API有两个功能,我可以设置它们。使用
设置标题 HttpAddRequestHeaders 就像魅力一样,但是,例如,如果我
移动我的内容类型:text / XML; charset = utf-8 标题(在 HttpAddRequestHeaders 之前成功设置)到
HttpSendRequest ( lpszHeaders参数)我收到错误
12150 ( ERROR_HTTP_HEADER_NOT_FOUND )。为什么?
b
$
我猜,有一些特殊的"种类"我可以用HttpSendRequest设置的标题......但我不知道......任何人都可以解释一下吗?
Carlos Barreto Feitoza Filho - Delphi开发人员
嗨卡洛斯,
我假设你关注的是
https://中概述的步骤msdn.microsoft.com/en-us/library/windows/desktop/aa384322%28v=vs.85%29.aspx
密钥在此声明中" HttpOpenRequest 在调用时不会将请求发送到Internet。在 
HttpSendRequest 功能发送请求并通过网络建立连接。"
看一看关于StacKOverflow的答案(
https:/ /stackoverflow.com/questions/20726723/download-file-from-the-internet-httpsendrequest-fails-with-error-code )因为我认为它可以识别您的问题。
此致,
IoTGirl
I'm trying to figure what is the correct place to set my http headers. The WinInet API has two functions where I can set them. Setting the headers with HttpAddRequestHeaders works like a charm, but, for example, if I move my Content-Type: text/xml; charset=utf-8 header (successfully set before with HttpAddRequestHeaders) to HttpSendRequest (lpszHeaders parameter) I receive the error 12150 (ERROR_HTTP_HEADER_NOT_FOUND). Why?
I guess, so, that there are some special "kind" of headers I can set with HttpSendRequest... But I do not know... Can anyone explain?
Carlos Barreto Feitoza Filho - Delphi Developer
Hi Carlos,
I assume you are following the steps as outlined at https://msdn.microsoft.com/en-us/library/windows/desktop/aa384322%28v=vs.85%29.aspx
The key is in this statement "HttpOpenRequest does not send the request to the Internet when called. The HttpSendRequest function sends the request and establishes a connection over the network."
Take a look at this answer on StacKOverflow ( https://stackoverflow.com/questions/20726723/download-file-from-the-internet-httpsendrequest-fails-with-error-code ) as I think it identifies your issue.
Sincerely,
IoTGirl
这篇关于使用HttpAddRequestHeaders设置的标头与在HttpSendRequest函数中设置的标头之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!