推荐一个 C/C++ 中的 HTTP 解析库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2617515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Recommendation for a HTTP parsing library in C/C++
提问by michael
I am looking for HTTP parsing library for C/C++. I have looked curl library, but it seems it is a http client library. I am looking for a library which parses HTTP header (e.g. a way to get the query string, get cookie, get request url, get Post Data)?
我正在寻找 C/C++ 的 HTTP 解析库。我看过 curl 库,但它似乎是一个 http 客户端库。我正在寻找一个解析 HTTP 标头的库(例如获取查询字符串、获取 cookie、获取请求 url、获取发布数据的方法)?
Thank you.
谢谢你。
采纳答案by clyfe
Check out libebb, it has a parsergenerated with Ragelusing the easy yet powerful PEG(it's based on Zed Shaw's mongrel parser)
查看libebb,它有一个使用简单而强大的PEG由Ragel生成的解析器(它基于 Zed Shaw 的 mongrel 解析器)
libebb is a lightweight HTTP server library for C. It lays the foundation for writing a web server by providing the socket juggling and request parsing. By implementing the HTTP/1.1 grammar provided in RFC2612, libebb understands most most valid HTTP/1.1 connections (persistent, pipelined, and chunked requests included) and rejects invalid or malicious requests. libebb supports SSL over HTTP.
libebb 是一个用于 C 的轻量级 HTTP 服务器库。它通过提供套接字处理和请求解析为编写 Web 服务器奠定了基础。通过实现 RFC2612 中提供的 HTTP/1.1 语法,libebb 理解大多数最有效的 HTTP/1.1 连接(包括持久性、管道化和分块请求)并拒绝无效或恶意请求。libebb 通过 HTTP 支持 SSL。
Also check this speedy parser
还要检查这个快速解析器
回答by dicroce
About 6 months ago, I was looking for the same exact thing. Then I found this page: HTTP Made Really Really Easyand I just wrote my own... Works great, surprisingly simple to implement...
大约 6 个月前,我正在寻找完全相同的东西。然后我找到了这个页面: HTTP Made真的很简单,我只是写了我自己的......效果很好,实现起来非常简单......
回答by authchir
I would suggest you to have a look to cpp-netlib, which is based on Boost.Asio.
我建议您查看基于Boost.Asio 的cpp-netlib。