intevhttp_make_request(structevhttp_connection*evcon,structevhttp_request*req,enumevhttp_cmd_type type,constchar*uri); 派发事件 intevent_base_dispatch(structevent_base*); 完整代码 #include"event2/http.h"#include"event2/http_struct.h"#include"event2/event.h"#include"event2/buffer.h"#include"e...
= NULL); ret = evhttp_make_request(conn, req, method, uri); assert(ret == 0); } int main(int argc, char **argv) { base = event_init(); rest_process(EVHTTP_REQ_GET, "127.0.0.1", 8080, "/path", NULL ); event_base_loop(base, 0); assert(resp != NULL); evhttp_request_...
I am using libevent 2.1.8 for an HTTP client and found that some times requests go missing. The callback passed to evhttp_make_request will just never get called. I tracked it down to bufferevent_writecb getting called with event WRITE_E...
intevhttp_make_request(conn_t*c,evhttp_request*req, intcmd_type,char*uri) cdefclass__start_response: cdefevhttp_request*req cdefintheaders_sent cdefobjectcode,reason def__init__(self): self.headers_sent=0 self.code=self.reason=None
headers = evhttp_request_get_output_headers(req);evhttp_add_header(headers,"Host", hostname_port);evhttp_add_header(headers,"Connection","close");/*evhttp_add_header(headers, "User-Agent", "***");*/returnevhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path); ...
* server using our make request method. */req = evhttp_request_new(http_dispatcher_test_done,NULL);if(req ==NULL) {fprintf(stdout,"FAILED\n");exit(1); }/* Add the information that we care about */evhttp_add_header(req->output_headers,"Host","somehost");if(evhttp_make_request(evc...
2. I refcount bufev while the thread is writing. In particular,evhttp_send_reply does incref while it's running (decref after, butcarefully because request may have been deleted). This prevents thenetwork thread from deleting the bufferevent in the middle of the send. ...
tt_abort_msg("couldn't make request"); } /* * Tell libevent to free the connection when the request completes * We then set the evcon pointer to NULL since we don't want to free it * when this function ends. */ evhttp_connection_free_on_completion(evcon); ...
That is more complicated. Ithinkyou could callevhttp_request_get_output_buffer()and check how much data is still in that buffer, and then decide to write more now, or sleep for a fraction of a second and check again. This is obviously not an optimal pattern, just a hacky start ... ...
(evutil_make_listen_socket_reuseable(fd) < 0) goto out; } if (ai != NULL) { r = bind(fd, ai->ai_addr, (ev_socklen_t)ai->ai_addrlen); if (r == -1) goto out; } return (fd); out: serrno = EVUTIL_SOCKET_ERROR(); evutil_closesocket(fd); EVUTIL_SET_SOCKET_ERROR(s...