0

我使用 libevent 的 http.h 实现了一个 http 客户端,但是在尝试 make-http 请求时出现了一些错误。更奇怪的是,下载文件时并不总是发生错误。

我使用evhttp_request_newandevhttp_request_free并且evhttp_request_new有一个回调参数,文档说明“当请求完成或发生错误时执行回调”。发生错误是什么意思,如何检查是否有错误?

4

2 回答 2

0

这不一定是您问题的完整答案,但我在 evhttp 中遇到了与错误处理类似的问题。我在那里的帖子跟踪了错误期间发生的情况。(或者至少在我的错误期间;你的可能不同。)令人沮丧的是它用 NULL 回调你的回调。所以这就是您可以判断存在错误的方式,但它并没有提供太多关于错误是什么的信息。查看 errno 可能有帮助,也可能没有帮助。

于 2013-08-11T10:06:55.640 回答
0

Based on the source code and documentation I found on the matter, you are given an argument of type evhttp_request *. If you look through the linked pages, you will see members such as response_code, which should give you a good idea. Here is a related question if the documentation is too raw for you.

All of this information I just gathered by Googling, and am in no way knowledgeable about this.

于 2013-07-23T04:47:19.310 回答