简体   繁体   English

如何在C程序中设置CURLOPT_HTTPHEADER的值,以免在HTTP Post请求中发送HTTP标头?

[英]How to set the value of CURLOPT_HTTPHEADER in a C program so as to not sent the HTTP Header in the HTTP Post request?

I am sending a post request in http but I don't want to send the HTTP header, and I came to know that by setting some value for CURLOPT_HTTPHEADER in a C program we can avoid sending the HTTP header. 我正在用http发送发帖请求,但是我不想发送HTTP标头,并且我知道通过在C程序中为CURLOPT_HTTPHEADER设置一些值,我们可以避免发送HTTP标头。 I want to know how I can do this. 我想知道我该怎么做。

To remove an internal default header, set the header with no value right of the colon. 要删除内部默认标头,请将标头的冒号设置为无值。 Ie, if " Content-Type " is a default header and you want it to not be sent, you would "add" the header " Content-Type: " to the headers that you set with CURLOPT_HTTPHEADER . 即,如果“ Content-Type ”是默认标头,并且您不希望发送它,则可以将标头“ Content-Type: ”“添加”到您使用CURLOPT_HTTPHEADER设置的标头中。

Your question is very confusing. 您的问题非常令人困惑。 You want to send an HTTP request without sending any HTTP headers at all ? 您要发送HTTP请求而根本不发送任何HTTP标头吗? That's not possible - the headers are PART of the definition of the HTTP request. 这是不可能的-标头是HTTP请求定义的一部分。

In fact, you can send a blank HTTP request with no content but w/ the correct HTTP headers and that would be a valid HTTP request. 实际上,您可以发送不带任何内容但带有正确HTTP标头的空白HTTP请求,这将是有效的HTTP请求。 But you simply can't send an HTTP request that has no headers (at all) but has a body, because without them, it's not an HTTP request. 但是,您根本无法发送完全没有标题但具有正文的HTTP请求,因为没有标题,就不是HTTP请求。

Perhaps you just need to send a TCP message. 也许您只需要发送一个TCP消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM