1
我试图使用libevent来模拟多个HTTP客户端。下面的代码片段有效,但不幸的是,它似乎不支持HTTP rediect(301,302)。不知道它是否由libevent HTTP包支持,如果是的话,我该如何启用它。libevent支持HTTP重定向
在此先感谢。
void http_request_done(struct evhttp_request *req, void *arg){
printf("http_request_done\n");
}
int http_req(char *uri, int i) {
struct evhttp_connection *conn = evhttp_connection_base_new(base, NULL, host, port);
struct evhttp_request *req = evhttp_request_new(http_request_done, base);
req->cb_arg = (void*) i;
evhttp_add_header(req->output_headers, "Host", "localhost");
evhttp_add_header(req->output_headers, "Connection", "KeepAlive");
evhttp_make_request(conn, req, EVHTTP_REQ_GET, uri);
}