C ++ winsock - 从响应中排除服务器头? (HTTP GET) [英] C++ winsock - exclude server header from response ? (HTTP GET)

查看:92
本文介绍了C ++ winsock - 从响应中排除服务器头? (HTTP GET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我正试图从服务器获得响应。目前,它返回:

https://pastebin.com/raw/1K8iZT74





但是,我不希望服务器头的完整响应。

我只想要Hello world!要退回的部分。

如何处理?有任何想法吗 ?



我的代码到目前为止:

https://pastebin.com/raw/LTuJ4fP5



谢谢!



我尝试过:



尝试更改请求。

我真的不知道如何以正确的方式处理这个问题:(

Hi!
I'm trying to get response from a server. At the moment, it returns this:
https://pastebin.com/raw/1K8iZT74


However, I don't want the full response with server header.
I only wan't the "Hello world!" part to be returned.
How do I approach this ? Any ideas ?

My Code so far:
https://pastebin.com/raw/LTuJ4fP5

Thank you!

What I have tried:

Tried changing the request.
I really don't have much idea how to approach this the correct way :(

推荐答案

响应标头是HTTP规范的一部分。您不会修改响应;而是根据规范对其进行解析。



Google有大量的点击率C ++解析http响应 - 例如: tinyhttp - 最小的HTTP响应解析器 [ ^ ]
The response headers are part of the HTTP specification. You don't modify the response; instead, you parse it according to the specification.

Google has plenty of hits for "C++ parse http response" - for example: tinyhttp - A minimal HTTP response parser[^]


这可能会澄清 HTTP GET 的工作原理: HTTP真的很容易 [ ^ ]

您可以使用它进行测试: Hurl.it - 发出HTTP请求 [ ^ ]
Maybe this will clarify the working of HTTP GET: HTTP Made Really Easy[^]
You can use this for testing: Hurl.it - Make HTTP requests[^]


看。

我只需要在没有服务器头的情况下获得简单的响应。这就是我想用winsock实现的目标。



这与请求无关。这是关于正确解析响应(在我的情况下省略了服务器头)。
Look.
I just need to get simple response without the server header. That's all Im trying to achieve with winsock.

It's not about the request. It's about parsing the response correctly (leaving out the server header in my case).


这篇关于C ++ winsock - 从响应中排除服务器头? (HTTP GET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆