• Home
  • Raw
  • Download

Lines Matching refs:evcon

185 	struct evhttp_connection *evcon);
187 struct evhttp_connection *evcon);
189 struct evhttp_connection *evcon);
190 static void evhttp_request_dispatch(struct evhttp_connection* evcon);
191 static void evhttp_read_firstline(struct evhttp_connection *evcon,
193 static void evhttp_read_header(struct evhttp_connection *evcon,
369 evhttp_write_buffer(struct evhttp_connection *evcon, in evhttp_write_buffer() argument
375 evcon->cb = cb; in evhttp_write_buffer()
376 evcon->cb_arg = arg; in evhttp_write_buffer()
381 bufferevent_setcb(evcon->bufev, in evhttp_write_buffer()
385 evcon); in evhttp_write_buffer()
387 bufferevent_enable(evcon->bufev, EV_READ|EV_WRITE); in evhttp_write_buffer()
391 evhttp_send_continue_done(struct evhttp_connection *evcon, void *arg) in evhttp_send_continue_done() argument
393 bufferevent_disable(evcon->bufev, EV_WRITE); in evhttp_send_continue_done()
397 evhttp_send_continue(struct evhttp_connection *evcon, in evhttp_send_continue() argument
400 bufferevent_enable(evcon->bufev, EV_WRITE); in evhttp_send_continue()
401 evbuffer_add_printf(bufferevent_get_output(evcon->bufev), in evhttp_send_continue()
404 evcon->cb = evhttp_send_continue_done; in evhttp_send_continue()
405 evcon->cb_arg = NULL; in evhttp_send_continue()
406 bufferevent_setcb(evcon->bufev, in evhttp_send_continue()
410 evcon); in evhttp_send_continue()
415 evhttp_connected(struct evhttp_connection *evcon) in evhttp_connected() argument
417 switch (evcon->state) { in evhttp_connected()
437 evhttp_make_header_request(struct evhttp_connection *evcon, in evhttp_make_header_request() argument
449 evbuffer_add_printf(bufferevent_get_output(evcon->bufev), in evhttp_make_header_request()
527 evhttp_make_header_response(struct evhttp_connection *evcon, in evhttp_make_header_response() argument
531 evbuffer_add_printf(bufferevent_get_output(evcon->bufev), in evhttp_make_header_response()
565 && evcon->http_server->default_content_type) { in evhttp_make_header_response()
568 evcon->http_server->default_content_type); in evhttp_make_header_response()
602 evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req) in evhttp_make_header() argument
605 struct evbuffer *output = bufferevent_get_output(evcon->bufev); in evhttp_make_header()
612 evhttp_make_header_request(evcon, req); in evhttp_make_header()
614 evhttp_make_header_response(evcon, req); in evhttp_make_header()
634 evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon, in evhttp_connection_set_max_headers_size() argument
638 evcon->max_headers_size = EV_SIZE_MAX; in evhttp_connection_set_max_headers_size()
640 evcon->max_headers_size = new_max_headers_size; in evhttp_connection_set_max_headers_size()
643 evhttp_connection_set_max_body_size(struct evhttp_connection* evcon, in evhttp_connection_set_max_body_size() argument
647 evcon->max_body_size = EV_UINT64_MAX; in evhttp_connection_set_max_body_size()
649 evcon->max_body_size = new_max_body_size; in evhttp_connection_set_max_body_size()
677 TAILQ_REMOVE(&req->evcon->requests, req, next); in evhttp_connection_incoming_fail()
681 req->evcon = NULL; in evhttp_connection_incoming_fail()
719 evhttp_request_free_(struct evhttp_connection *evcon, struct evhttp_request *req) in evhttp_request_free_() argument
721 TAILQ_REMOVE(&evcon->requests, req, next); in evhttp_request_free_()
730 evhttp_connection_fail_(struct evhttp_connection *evcon, in evhttp_connection_fail_() argument
734 struct evhttp_request* req = TAILQ_FIRST(&evcon->requests); in evhttp_connection_fail_()
741 bufferevent_disable(evcon->bufev, EV_READ|EV_WRITE); in evhttp_connection_fail_()
743 if (evcon->flags & EVHTTP_CON_INCOMING) { in evhttp_connection_fail_()
753 evhttp_connection_free(evcon); in evhttp_connection_fail_()
773 evhttp_request_free_(evcon, req); in evhttp_connection_fail_()
776 evhttp_connection_reset_(evcon); in evhttp_connection_fail_()
779 if (TAILQ_FIRST(&evcon->requests) != NULL) in evhttp_connection_fail_()
780 evhttp_connection_connect_(evcon); in evhttp_connection_fail_()
800 struct evhttp_connection *evcon = arg; in evhttp_write_cb() local
803 if (evcon->cb != NULL) in evhttp_write_cb()
804 (*evcon->cb)(evcon, evcon->cb_arg); in evhttp_write_cb()
815 evhttp_connection_done(struct evhttp_connection *evcon) in evhttp_connection_done() argument
817 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_connection_done()
818 int con_outgoing = evcon->flags & EVHTTP_CON_OUTGOING; in evhttp_connection_done()
824 TAILQ_REMOVE(&evcon->requests, req, next); in evhttp_connection_done()
825 req->evcon = NULL; in evhttp_connection_done()
827 evcon->state = EVCON_IDLE; in evhttp_connection_done()
831 evhttp_connection_reset_(evcon); in evhttp_connection_done()
833 if (TAILQ_FIRST(&evcon->requests) != NULL) { in evhttp_connection_done()
838 if (!evhttp_connected(evcon)) in evhttp_connection_done()
839 evhttp_connection_connect_(evcon); in evhttp_connection_done()
841 evhttp_request_dispatch(evcon); in evhttp_connection_done()
847 evhttp_connection_start_detectclose(evcon); in evhttp_connection_done()
848 } else if ((evcon->flags & EVHTTP_CON_AUTOFREE)) { in evhttp_connection_done()
860 evcon->state = EVCON_WRITING; in evhttp_connection_done()
877 if (free_evcon && TAILQ_FIRST(&evcon->requests) == NULL) { in evhttp_connection_done()
878 evhttp_connection_free(evcon); in evhttp_connection_done()
944 if (req->body_size + (size_t)ntoread > req->evcon->max_body_size) { in evhttp_handle_chunked_read()
988 evhttp_read_trailer(struct evhttp_connection *evcon, struct evhttp_request *req) in evhttp_read_trailer() argument
990 struct evbuffer *buf = bufferevent_get_input(evcon->bufev); in evhttp_read_trailer()
995 evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); in evhttp_read_trailer()
998 bufferevent_disable(evcon->bufev, EV_READ); in evhttp_read_trailer()
999 evhttp_connection_done(evcon); in evhttp_read_trailer()
1009 evhttp_lingering_close(struct evhttp_connection *evcon, in evhttp_lingering_close() argument
1012 struct evbuffer *buf = bufferevent_get_input(evcon->bufev); in evhttp_lingering_close()
1025 evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); in evhttp_lingering_close()
1028 evhttp_lingering_fail(struct evhttp_connection *evcon, in evhttp_lingering_fail() argument
1031 if (evcon->flags & EVHTTP_CON_LINGERING_CLOSE) in evhttp_lingering_fail()
1032 evhttp_lingering_close(evcon, req); in evhttp_lingering_fail()
1034 evhttp_connection_fail_(evcon, EVREQ_HTTP_DATA_TOO_LONG); in evhttp_lingering_fail()
1038 evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req) in evhttp_read_body() argument
1040 struct evbuffer *buf = bufferevent_get_input(evcon->bufev); in evhttp_read_body()
1046 evcon->state = EVCON_READING_TRAILER; in evhttp_read_body()
1047 evhttp_read_trailer(evcon, req); in evhttp_read_body()
1052 evhttp_connection_fail_(evcon, in evhttp_read_body()
1066 evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); in evhttp_read_body()
1085 if (req->body_size > req->evcon->max_body_size || in evhttp_read_body()
1087 (size_t)req->ntoread > req->evcon->max_body_size)) { in evhttp_read_body()
1091 evhttp_lingering_fail(evcon, req); in evhttp_read_body()
1108 bufferevent_disable(evcon->bufev, EV_READ); in evhttp_read_body()
1110 evhttp_connection_done(evcon); in evhttp_read_body()
1115 #define get_deferred_queue(evcon) \ argument
1116 ((evcon)->base)
1125 struct evhttp_connection *evcon = arg; in evhttp_read_cb() local
1126 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_read_cb()
1129 event_deferred_cb_cancel_(get_deferred_queue(evcon), in evhttp_read_cb()
1130 &evcon->read_more_deferred_cb); in evhttp_read_cb()
1132 switch (evcon->state) { in evhttp_read_cb()
1134 evhttp_read_firstline(evcon, req); in evhttp_read_cb()
1139 evhttp_read_header(evcon, req); in evhttp_read_cb()
1144 evhttp_read_body(evcon, req); in evhttp_read_cb()
1149 evhttp_read_trailer(evcon, req); in evhttp_read_cb()
1157 input = bufferevent_get_input(evcon->bufev); in evhttp_read_cb()
1165 evhttp_connection_reset_(evcon); in evhttp_read_cb()
1173 __func__, evcon->state); in evhttp_read_cb()
1180 struct evhttp_connection *evcon = data; in evhttp_deferred_read_cb() local
1181 struct bufferevent *bev = evcon->bufev; in evhttp_deferred_read_cb()
1183 (bev->readcb)(evcon->bufev, evcon); in evhttp_deferred_read_cb()
1187 evhttp_write_connectioncb(struct evhttp_connection *evcon, void *arg) in evhttp_write_connectioncb() argument
1190 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_write_connectioncb()
1191 struct evbuffer *output = bufferevent_get_output(evcon->bufev); in evhttp_write_connectioncb()
1194 EVUTIL_ASSERT(evcon->state == EVCON_WRITING); in evhttp_write_connectioncb()
1204 evhttp_start_read_(evcon); in evhttp_write_connectioncb()
1212 evhttp_connection_free(struct evhttp_connection *evcon) in evhttp_connection_free() argument
1218 if (evcon->fd != -1) { in evhttp_connection_free()
1219 if (evhttp_connected(evcon) && evcon->closecb != NULL) in evhttp_connection_free()
1220 (*evcon->closecb)(evcon, evcon->closecb_arg); in evhttp_connection_free()
1228 while ((req = TAILQ_FIRST(&evcon->requests)) != NULL) { in evhttp_connection_free()
1229 evhttp_request_free_(evcon, req); in evhttp_connection_free()
1232 if (evcon->http_server != NULL) { in evhttp_connection_free()
1233 struct evhttp *http = evcon->http_server; in evhttp_connection_free()
1234 TAILQ_REMOVE(&http->connections, evcon, next); in evhttp_connection_free()
1237 if (event_initialized(&evcon->retry_ev)) { in evhttp_connection_free()
1238 event_del(&evcon->retry_ev); in evhttp_connection_free()
1239 event_debug_unassign(&evcon->retry_ev); in evhttp_connection_free()
1242 event_deferred_cb_cancel_(get_deferred_queue(evcon), in evhttp_connection_free()
1243 &evcon->read_more_deferred_cb); in evhttp_connection_free()
1245 if (evcon->bufev != NULL) { in evhttp_connection_free()
1247 !(bufferevent_get_options_(evcon->bufev) & BEV_OPT_CLOSE_ON_FREE); in evhttp_connection_free()
1248 if (evcon->fd == -1) in evhttp_connection_free()
1249 evcon->fd = bufferevent_getfd(evcon->bufev); in evhttp_connection_free()
1251 bufferevent_free(evcon->bufev); in evhttp_connection_free()
1254 if (evcon->fd != -1) { in evhttp_connection_free()
1255 shutdown(evcon->fd, EVUTIL_SHUT_WR); in evhttp_connection_free()
1257 evutil_closesocket(evcon->fd); in evhttp_connection_free()
1260 if (evcon->bind_address != NULL) in evhttp_connection_free()
1261 mm_free(evcon->bind_address); in evhttp_connection_free()
1263 if (evcon->address != NULL) in evhttp_connection_free()
1264 mm_free(evcon->address); in evhttp_connection_free()
1266 mm_free(evcon); in evhttp_connection_free()
1270 evhttp_connection_free_on_completion(struct evhttp_connection *evcon) { in evhttp_connection_free_on_completion() argument
1271 evcon->flags |= EVHTTP_CON_AUTOFREE; in evhttp_connection_free_on_completion()
1275 evhttp_connection_set_local_address(struct evhttp_connection *evcon, in evhttp_connection_set_local_address() argument
1278 EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); in evhttp_connection_set_local_address()
1279 if (evcon->bind_address) in evhttp_connection_set_local_address()
1280 mm_free(evcon->bind_address); in evhttp_connection_set_local_address()
1281 if ((evcon->bind_address = mm_strdup(address)) == NULL) in evhttp_connection_set_local_address()
1286 evhttp_connection_set_local_port(struct evhttp_connection *evcon, in evhttp_connection_set_local_port() argument
1289 EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); in evhttp_connection_set_local_port()
1290 evcon->bind_port = port; in evhttp_connection_set_local_port()
1294 evhttp_request_dispatch(struct evhttp_connection* evcon) in evhttp_request_dispatch() argument
1296 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_request_dispatch()
1305 evhttp_connection_stop_detectclose(evcon); in evhttp_request_dispatch()
1308 EVUTIL_ASSERT(evcon->state == EVCON_IDLE); in evhttp_request_dispatch()
1310 evcon->state = EVCON_WRITING; in evhttp_request_dispatch()
1313 evhttp_make_header(evcon, req); in evhttp_request_dispatch()
1315 evhttp_write_buffer(evcon, evhttp_write_connectioncb, NULL); in evhttp_request_dispatch()
1321 evhttp_connection_reset_(struct evhttp_connection *evcon) in evhttp_connection_reset_() argument
1326 bufferevent_setcb(evcon->bufev, NULL, NULL, NULL, NULL); in evhttp_connection_reset_()
1339 bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE); in evhttp_connection_reset_()
1341 if (evcon->fd == -1) in evhttp_connection_reset_()
1342 evcon->fd = bufferevent_getfd(evcon->bufev); in evhttp_connection_reset_()
1344 if (evcon->fd != -1) { in evhttp_connection_reset_()
1346 if (evhttp_connected(evcon) && evcon->closecb != NULL) in evhttp_connection_reset_()
1347 (*evcon->closecb)(evcon, evcon->closecb_arg); in evhttp_connection_reset_()
1349 shutdown(evcon->fd, EVUTIL_SHUT_WR); in evhttp_connection_reset_()
1350 evutil_closesocket(evcon->fd); in evhttp_connection_reset_()
1351 evcon->fd = -1; in evhttp_connection_reset_()
1353 err = bufferevent_setfd(evcon->bufev, -1); in evhttp_connection_reset_()
1357 tmp = bufferevent_get_output(evcon->bufev); in evhttp_connection_reset_()
1360 tmp = bufferevent_get_input(evcon->bufev); in evhttp_connection_reset_()
1364 evcon->flags &= ~EVHTTP_CON_READING_ERROR; in evhttp_connection_reset_()
1366 evcon->state = EVCON_DISCONNECTED; in evhttp_connection_reset_()
1370 evhttp_connection_start_detectclose(struct evhttp_connection *evcon) in evhttp_connection_start_detectclose() argument
1372 evcon->flags |= EVHTTP_CON_CLOSEDETECT; in evhttp_connection_start_detectclose()
1373 bufferevent_enable(evcon->bufev, EV_READ); in evhttp_connection_start_detectclose()
1377 evhttp_connection_stop_detectclose(struct evhttp_connection *evcon) in evhttp_connection_stop_detectclose() argument
1379 evcon->flags &= ~EVHTTP_CON_CLOSEDETECT; in evhttp_connection_stop_detectclose()
1380 bufferevent_disable(evcon->bufev, EV_READ); in evhttp_connection_stop_detectclose()
1386 struct evhttp_connection *evcon = arg; in evhttp_connection_retry() local
1388 evcon->state = EVCON_DISCONNECTED; in evhttp_connection_retry()
1389 evhttp_connection_connect_(evcon); in evhttp_connection_retry()
1393 evhttp_connection_cb_cleanup(struct evhttp_connection *evcon) in evhttp_connection_cb_cleanup() argument
1397 evhttp_connection_reset_(evcon); in evhttp_connection_cb_cleanup()
1398 if (evcon->retry_max < 0 || evcon->retry_cnt < evcon->retry_max) { in evhttp_connection_cb_cleanup()
1399 struct timeval tv_retry = evcon->initial_retry_timeout; in evhttp_connection_cb_cleanup()
1401 evtimer_assign(&evcon->retry_ev, evcon->base, evhttp_connection_retry, evcon); in evhttp_connection_cb_cleanup()
1403 for (i=0; i < evcon->retry_cnt; ++i) { in evhttp_connection_cb_cleanup()
1415 event_add(&evcon->retry_ev, &tv_retry); in evhttp_connection_cb_cleanup()
1416 evcon->retry_cnt++; in evhttp_connection_cb_cleanup()
1427 while (TAILQ_FIRST(&evcon->requests) != NULL) { in evhttp_connection_cb_cleanup()
1428 struct evhttp_request *request = TAILQ_FIRST(&evcon->requests); in evhttp_connection_cb_cleanup()
1429 TAILQ_REMOVE(&evcon->requests, request, next); in evhttp_connection_cb_cleanup()
1437 request->evcon = NULL; in evhttp_connection_cb_cleanup()
1446 evhttp_connection_read_on_write_error(struct evhttp_connection *evcon, in evhttp_connection_read_on_write_error() argument
1452 if (evcon->flags & EVHTTP_CON_READING_ERROR) { in evhttp_connection_read_on_write_error()
1453 evcon->flags &= ~EVHTTP_CON_READING_ERROR; in evhttp_connection_read_on_write_error()
1454 evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); in evhttp_connection_read_on_write_error()
1460 buf = bufferevent_get_output(evcon->bufev); in evhttp_connection_read_on_write_error()
1465 evhttp_start_read_(evcon); in evhttp_connection_read_on_write_error()
1466 evcon->flags |= EVHTTP_CON_READING_ERROR; in evhttp_connection_read_on_write_error()
1472 struct evhttp_connection *evcon = arg; in evhttp_error_cb() local
1473 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_error_cb()
1475 if (evcon->fd == -1) in evhttp_error_cb()
1476 evcon->fd = bufferevent_getfd(bufev); in evhttp_error_cb()
1478 switch (evcon->state) { in evhttp_error_cb()
1483 __func__, evcon->address, evcon->port, in evhttp_error_cb()
1484 EV_SOCK_ARG(evcon->fd))); in evhttp_error_cb()
1485 evhttp_connection_cb_cleanup(evcon); in evhttp_error_cb()
1494 evhttp_connection_done(evcon); in evhttp_error_cb()
1512 if (evcon->flags & EVHTTP_CON_CLOSEDETECT) { in evhttp_error_cb()
1513 evcon->flags &= ~EVHTTP_CON_CLOSEDETECT; in evhttp_error_cb()
1514 EVUTIL_ASSERT(evcon->http_server == NULL); in evhttp_error_cb()
1519 EVUTIL_ASSERT(evcon->state == EVCON_IDLE); in evhttp_error_cb()
1520 evhttp_connection_reset_(evcon); in evhttp_error_cb()
1527 if (TAILQ_FIRST(&evcon->requests) == NULL in evhttp_error_cb()
1528 && (evcon->flags & EVHTTP_CON_OUTGOING) in evhttp_error_cb()
1529 && (evcon->flags & EVHTTP_CON_AUTOFREE)) { in evhttp_error_cb()
1530 evhttp_connection_free(evcon); in evhttp_error_cb()
1536 evhttp_connection_fail_(evcon, EVREQ_HTTP_TIMEOUT); in evhttp_error_cb()
1539 evcon->flags & EVHTTP_CON_READ_ON_WRITE_ERROR) { in evhttp_error_cb()
1540 evhttp_connection_read_on_write_error(evcon, req); in evhttp_error_cb()
1545 evcon->flags & EVHTTP_CON_READ_ON_WRITE_ERROR && in evhttp_error_cb()
1547 event_deferred_cb_schedule_(get_deferred_queue(evcon), in evhttp_error_cb()
1548 &evcon->read_more_deferred_cb); in evhttp_error_cb()
1552 evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); in evhttp_error_cb()
1555 evhttp_connection_fail_(evcon, EVREQ_HTTP_BUFFER_ERROR); in evhttp_error_cb()
1565 struct evhttp_connection *evcon = arg; in evhttp_connection_cb() local
1569 if (evcon->fd == -1) in evhttp_connection_cb()
1570 evcon->fd = bufferevent_getfd(bufev); in evhttp_connection_cb()
1585 if (evcon->fd == -1) { in evhttp_connection_cb()
1592 if (getsockopt(evcon->fd, SOL_SOCKET, SO_ERROR, (void*)&error, in evhttp_connection_cb()
1595 __func__, evcon->address, evcon->port, in evhttp_connection_cb()
1596 EV_SOCK_ARG(evcon->fd))); in evhttp_connection_cb()
1603 __func__, evcon->address, evcon->port, in evhttp_connection_cb()
1604 EV_SOCK_ARG(evcon->fd), in evhttp_connection_cb()
1611 __func__, evcon->address, evcon->port, in evhttp_connection_cb()
1612 EV_SOCK_ARG(evcon->fd))); in evhttp_connection_cb()
1615 evcon->retry_cnt = 0; in evhttp_connection_cb()
1616 evcon->state = EVCON_IDLE; in evhttp_connection_cb()
1619 bufferevent_setcb(evcon->bufev, in evhttp_connection_cb()
1623 evcon); in evhttp_connection_cb()
1625 if (!evutil_timerisset(&evcon->timeout)) { in evhttp_connection_cb()
1628 bufferevent_set_timeouts(evcon->bufev, &read_tv, &write_tv); in evhttp_connection_cb()
1630 bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); in evhttp_connection_cb()
1634 evhttp_request_dispatch(evcon); in evhttp_connection_cb()
1638 evhttp_connection_cb_cleanup(evcon); in evhttp_connection_cb()
1883 !evhttp_find_vhost(req->evcon->http_server, NULL, hostname)) in evhttp_parse_request_line()
2025 if (req->evcon != NULL && in evhttp_parse_firstline_()
2026 evbuffer_get_length(buffer) > req->evcon->max_headers_size) in evhttp_parse_firstline_()
2032 if (req->evcon != NULL && len > req->evcon->max_headers_size) { in evhttp_parse_firstline_()
2101 if (req->evcon != NULL && in evhttp_parse_headers_()
2102 req->headers_size > req->evcon->max_headers_size) { in evhttp_parse_headers_()
2137 if (req->evcon != NULL && in evhttp_parse_headers_()
2138 req->headers_size + evbuffer_get_length(buffer) > req->evcon->max_headers_size) in evhttp_parse_headers_()
2179 EV_SIZE_ARG(evbuffer_get_length(bufferevent_get_input(req->evcon->bufev))))); in evhttp_get_body_length()
2206 evhttp_get_body(struct evhttp_connection *evcon, struct evhttp_request *req) in evhttp_get_body() argument
2213 evhttp_connection_done(evcon); in evhttp_get_body()
2216 evcon->state = EVCON_READING_BODY; in evhttp_get_body()
2223 evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); in evhttp_get_body()
2229 evhttp_connection_done(evcon); in evhttp_get_body()
2245 if ((req->evcon->max_body_size <= EV_INT64_MAX) && in evhttp_get_body()
2246 (ev_uint64_t)req->ntoread > req->evcon->max_body_size) { in evhttp_get_body()
2247 evhttp_lingering_fail(evcon, req); in evhttp_get_body()
2251 if (!evbuffer_get_length(bufferevent_get_input(evcon->bufev))) in evhttp_get_body()
2252 evhttp_send_continue(evcon, req); in evhttp_get_body()
2260 evhttp_read_body(evcon, req); in evhttp_get_body()
2265 evhttp_read_firstline(struct evhttp_connection *evcon, in evhttp_read_firstline() argument
2270 res = evhttp_parse_firstline_(req, bufferevent_get_input(evcon->bufev)); in evhttp_read_firstline()
2274 __func__, EV_SOCK_ARG(evcon->fd))); in evhttp_read_firstline()
2275 evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); in evhttp_read_firstline()
2282 evcon->state = EVCON_READING_HEADERS; in evhttp_read_firstline()
2283 evhttp_read_header(evcon, req); in evhttp_read_firstline()
2287 evhttp_read_header(struct evhttp_connection *evcon, in evhttp_read_header() argument
2291 evutil_socket_t fd = evcon->fd; in evhttp_read_header()
2293 res = evhttp_parse_headers_(req, bufferevent_get_input(evcon->bufev)); in evhttp_read_header()
2298 evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); in evhttp_read_header()
2308 evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); in evhttp_read_header()
2318 evhttp_get_body(evcon, req); in evhttp_read_header()
2325 struct evbuffer *output = bufferevent_get_output(evcon->bufev); in evhttp_read_header()
2327 evhttp_start_write_(evcon); in evhttp_read_header()
2333 evhttp_connection_done(evcon); in evhttp_read_header()
2338 evhttp_get_body(evcon, req); in evhttp_read_header()
2347 evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER); in evhttp_read_header()
2373 struct evhttp_connection *evcon = NULL; in evhttp_connection_base_bufferevent_new() local
2377 if ((evcon = mm_calloc(1, sizeof(struct evhttp_connection))) == NULL) { in evhttp_connection_base_bufferevent_new()
2382 evcon->fd = -1; in evhttp_connection_base_bufferevent_new()
2383 evcon->port = port; in evhttp_connection_base_bufferevent_new()
2385 evcon->max_headers_size = EV_SIZE_MAX; in evhttp_connection_base_bufferevent_new()
2386 evcon->max_body_size = EV_SIZE_MAX; in evhttp_connection_base_bufferevent_new()
2388 evutil_timerclear(&evcon->timeout); in evhttp_connection_base_bufferevent_new()
2389 evcon->retry_cnt = evcon->retry_max = 0; in evhttp_connection_base_bufferevent_new()
2391 if ((evcon->address = mm_strdup(address)) == NULL) { in evhttp_connection_base_bufferevent_new()
2403 bufferevent_setcb(bev, evhttp_read_cb, evhttp_write_cb, evhttp_error_cb, evcon); in evhttp_connection_base_bufferevent_new()
2404 evcon->bufev = bev; in evhttp_connection_base_bufferevent_new()
2406 evcon->state = EVCON_DISCONNECTED; in evhttp_connection_base_bufferevent_new()
2407 TAILQ_INIT(&evcon->requests); in evhttp_connection_base_bufferevent_new()
2409 evcon->initial_retry_timeout.tv_sec = 2; in evhttp_connection_base_bufferevent_new()
2410 evcon->initial_retry_timeout.tv_usec = 0; in evhttp_connection_base_bufferevent_new()
2413 evcon->base = base; in evhttp_connection_base_bufferevent_new()
2415 bufferevent_base_set(base, evcon->bufev); in evhttp_connection_base_bufferevent_new()
2419 &evcon->read_more_deferred_cb, in evhttp_connection_base_bufferevent_new()
2421 evhttp_deferred_read_cb, evcon); in evhttp_connection_base_bufferevent_new()
2423 evcon->dns_base = dnsbase; in evhttp_connection_base_bufferevent_new()
2424 evcon->ai_family = AF_UNSPEC; in evhttp_connection_base_bufferevent_new()
2426 return (evcon); in evhttp_connection_base_bufferevent_new()
2429 if (evcon != NULL) in evhttp_connection_base_bufferevent_new()
2430 evhttp_connection_free(evcon); in evhttp_connection_base_bufferevent_new()
2434 struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon) in evhttp_connection_get_bufferevent() argument
2436 return evcon->bufev; in evhttp_connection_get_bufferevent()
2440 evhttp_connection_get_server(struct evhttp_connection *evcon) in evhttp_connection_get_server() argument
2442 return evcon->http_server; in evhttp_connection_get_server()
2452 void evhttp_connection_set_family(struct evhttp_connection *evcon, in evhttp_connection_set_family() argument
2455 evcon->ai_family = family; in evhttp_connection_set_family()
2458 int evhttp_connection_set_flags(struct evhttp_connection *evcon, in evhttp_connection_set_flags() argument
2467 evcon->flags &= ~avail_flags; in evhttp_connection_set_flags()
2469 evcon->flags |= flags; in evhttp_connection_set_flags()
2475 evhttp_connection_set_base(struct evhttp_connection *evcon, in evhttp_connection_set_base() argument
2478 EVUTIL_ASSERT(evcon->base == NULL); in evhttp_connection_set_base()
2479 EVUTIL_ASSERT(evcon->state == EVCON_DISCONNECTED); in evhttp_connection_set_base()
2480 evcon->base = base; in evhttp_connection_set_base()
2481 bufferevent_base_set(base, evcon->bufev); in evhttp_connection_set_base()
2485 evhttp_connection_set_timeout(struct evhttp_connection *evcon, in evhttp_connection_set_timeout() argument
2489 evhttp_connection_set_timeout_tv(evcon, NULL); in evhttp_connection_set_timeout()
2494 evhttp_connection_set_timeout_tv(evcon, &tv); in evhttp_connection_set_timeout()
2499 evhttp_connection_set_timeout_tv(struct evhttp_connection *evcon, in evhttp_connection_set_timeout_tv() argument
2503 evcon->timeout = *tv; in evhttp_connection_set_timeout_tv()
2504 bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); in evhttp_connection_set_timeout_tv()
2508 evutil_timerclear(&evcon->timeout); in evhttp_connection_set_timeout_tv()
2509 bufferevent_set_timeouts(evcon->bufev, &read_tv, &write_tv); in evhttp_connection_set_timeout_tv()
2514 evhttp_connection_set_initial_retry_tv(struct evhttp_connection *evcon, in evhttp_connection_set_initial_retry_tv() argument
2518 evcon->initial_retry_timeout = *tv; in evhttp_connection_set_initial_retry_tv()
2520 evutil_timerclear(&evcon->initial_retry_timeout); in evhttp_connection_set_initial_retry_tv()
2521 evcon->initial_retry_timeout.tv_sec = 2; in evhttp_connection_set_initial_retry_tv()
2526 evhttp_connection_set_retries(struct evhttp_connection *evcon, in evhttp_connection_set_retries() argument
2529 evcon->retry_max = retry_max; in evhttp_connection_set_retries()
2533 evhttp_connection_set_closecb(struct evhttp_connection *evcon, in evhttp_connection_set_closecb() argument
2536 evcon->closecb = cb; in evhttp_connection_set_closecb()
2537 evcon->closecb_arg = cbarg; in evhttp_connection_set_closecb()
2541 evhttp_connection_get_peer(struct evhttp_connection *evcon, in evhttp_connection_get_peer() argument
2544 *address = evcon->address; in evhttp_connection_get_peer()
2545 *port = evcon->port; in evhttp_connection_get_peer()
2549 evhttp_connection_get_addr(struct evhttp_connection *evcon) in evhttp_connection_get_addr() argument
2551 return bufferevent_socket_get_conn_address_(evcon->bufev); in evhttp_connection_get_addr()
2555 evhttp_connection_connect_(struct evhttp_connection *evcon) in evhttp_connection_connect_() argument
2557 int old_state = evcon->state; in evhttp_connection_connect_()
2558 const char *address = evcon->address; in evhttp_connection_connect_()
2559 const struct sockaddr *sa = evhttp_connection_get_addr(evcon); in evhttp_connection_connect_()
2562 if (evcon->state == EVCON_CONNECTING) in evhttp_connection_connect_()
2565 evhttp_connection_reset_(evcon); in evhttp_connection_connect_()
2567 EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING)); in evhttp_connection_connect_()
2568 evcon->flags |= EVHTTP_CON_OUTGOING; in evhttp_connection_connect_()
2570 if (evcon->bind_address || evcon->bind_port) { in evhttp_connection_connect_()
2571 evcon->fd = bind_socket( in evhttp_connection_connect_()
2572 evcon->bind_address, evcon->bind_port, 0 /*reuse*/); in evhttp_connection_connect_()
2573 if (evcon->fd == -1) { in evhttp_connection_connect_()
2575 __func__, evcon->bind_address)); in evhttp_connection_connect_()
2579 if (bufferevent_setfd(evcon->bufev, evcon->fd)) in evhttp_connection_connect_()
2582 if (bufferevent_setfd(evcon->bufev, -1)) in evhttp_connection_connect_()
2587 bufferevent_setcb(evcon->bufev, in evhttp_connection_connect_()
2591 evcon); in evhttp_connection_connect_()
2592 if (!evutil_timerisset(&evcon->timeout)) { in evhttp_connection_connect_()
2594 bufferevent_set_timeouts(evcon->bufev, &conn_tv, &conn_tv); in evhttp_connection_connect_()
2596 bufferevent_set_timeouts(evcon->bufev, &evcon->timeout, &evcon->timeout); in evhttp_connection_connect_()
2599 if (bufferevent_enable(evcon->bufev, EV_WRITE)) in evhttp_connection_connect_()
2602 evcon->state = EVCON_CONNECTING; in evhttp_connection_connect_()
2604 if (evcon->flags & EVHTTP_CON_REUSE_CONNECTED_ADDR && in evhttp_connection_connect_()
2611 ret = bufferevent_socket_connect(evcon->bufev, sa, socklen); in evhttp_connection_connect_()
2613 ret = bufferevent_socket_connect_hostname(evcon->bufev, in evhttp_connection_connect_()
2614 evcon->dns_base, evcon->ai_family, address, evcon->port); in evhttp_connection_connect_()
2618 evcon->state = old_state; in evhttp_connection_connect_()
2619 event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed", in evhttp_connection_connect_()
2620 __func__, evcon->address); in evhttp_connection_connect_()
2625 evhttp_connection_cb_cleanup(evcon); in evhttp_connection_connect_()
2639 evhttp_make_request(struct evhttp_connection *evcon, in evhttp_make_request() argument
2660 EVUTIL_ASSERT(req->evcon == NULL); in evhttp_make_request()
2661 req->evcon = evcon; in evhttp_make_request()
2664 TAILQ_INSERT_TAIL(&evcon->requests, req, next); in evhttp_make_request()
2667 if (evcon->retry_cnt) in evhttp_make_request()
2671 if (!evhttp_connected(evcon)) { in evhttp_make_request()
2672 int res = evhttp_connection_connect_(evcon); in evhttp_make_request()
2678 TAILQ_REMOVE(&evcon->requests, req, next); in evhttp_make_request()
2688 if (TAILQ_FIRST(&evcon->requests) == req) in evhttp_make_request()
2689 evhttp_request_dispatch(evcon); in evhttp_make_request()
2697 struct evhttp_connection *evcon = req->evcon; in evhttp_cancel_request() local
2698 if (evcon != NULL) { in evhttp_cancel_request()
2700 if (TAILQ_FIRST(&evcon->requests) == req) { in evhttp_cancel_request()
2704 evhttp_connection_fail_(evcon, in evhttp_cancel_request()
2713 TAILQ_REMOVE(&evcon->requests, req, next); in evhttp_cancel_request()
2726 evhttp_start_read_(struct evhttp_connection *evcon) in evhttp_start_read_() argument
2728 bufferevent_disable(evcon->bufev, EV_WRITE); in evhttp_start_read_()
2729 bufferevent_enable(evcon->bufev, EV_READ); in evhttp_start_read_()
2731 evcon->state = EVCON_READING_FIRSTLINE; in evhttp_start_read_()
2733 bufferevent_setcb(evcon->bufev, in evhttp_start_read_()
2737 evcon); in evhttp_start_read_()
2741 if (evbuffer_get_length(bufferevent_get_input(evcon->bufev))) { in evhttp_start_read_()
2742 event_deferred_cb_schedule_(get_deferred_queue(evcon), in evhttp_start_read_()
2743 &evcon->read_more_deferred_cb); in evhttp_start_read_()
2748 evhttp_start_write_(struct evhttp_connection *evcon) in evhttp_start_write_() argument
2750 bufferevent_disable(evcon->bufev, EV_WRITE); in evhttp_start_write_()
2751 bufferevent_enable(evcon->bufev, EV_READ); in evhttp_start_write_()
2753 evcon->state = EVCON_WRITING; in evhttp_start_write_()
2754 evhttp_write_buffer(evcon, evhttp_write_connectioncb, NULL); in evhttp_start_write_()
2758 evhttp_send_done(struct evhttp_connection *evcon, void *arg) in evhttp_send_done() argument
2761 struct evhttp_request *req = TAILQ_FIRST(&evcon->requests); in evhttp_send_done()
2762 TAILQ_REMOVE(&evcon->requests, req, next); in evhttp_send_done()
2777 evhttp_connection_free(evcon); in evhttp_send_done()
2782 if (evhttp_associate_new_request_with_connection(evcon) == -1) { in evhttp_send_done()
2783 evhttp_connection_free(evcon); in evhttp_send_done()
2804 evhttp_connection_free(req->evcon); in evhttp_send_error()
2826 struct evhttp_connection *evcon = req->evcon; in evhttp_send() local
2828 if (evcon == NULL) { in evhttp_send()
2833 EVUTIL_ASSERT(TAILQ_FIRST(&evcon->requests) == req); in evhttp_send()
2843 evhttp_make_header(evcon, req); in evhttp_send()
2845 evhttp_write_buffer(evcon, evhttp_send_done, NULL); in evhttp_send()
2863 if (req->evcon == NULL) in evhttp_send_reply_start()
2880 evhttp_make_header(req->evcon, req); in evhttp_send_reply_start()
2881 evhttp_write_buffer(req->evcon, NULL, NULL); in evhttp_send_reply_start()
2888 struct evhttp_connection *evcon = req->evcon; in evhttp_send_reply_chunk_with_cb() local
2891 if (evcon == NULL) in evhttp_send_reply_chunk_with_cb()
2894 output = bufferevent_get_output(evcon->bufev); in evhttp_send_reply_chunk_with_cb()
2908 evhttp_write_buffer(evcon, cb, arg); in evhttp_send_reply_chunk_with_cb()
2919 struct evhttp_connection *evcon = req->evcon; in evhttp_send_reply_end() local
2922 if (evcon == NULL) { in evhttp_send_reply_end()
2927 output = bufferevent_get_output(evcon->bufev); in evhttp_send_reply_end()
2934 evhttp_write_buffer(req->evcon, evhttp_send_done, NULL); in evhttp_send_reply_end()
2938 evhttp_send_done(evcon, NULL); in evhttp_send_reply_end()
2941 evcon->cb = evhttp_send_done; in evhttp_send_reply_end()
2942 evcon->cb_arg = NULL; in evhttp_send_reply_end()
3462 bufferevent_disable(req->evcon->bufev, EV_READ); in evhttp_handle_request()
3504 evhttp_connection_free(req->evcon); in evhttp_handle_request()
3510 evhttp_connection_free(req->evcon); in evhttp_handle_request()
3722 struct evhttp_connection *evcon; in evhttp_free() local
3736 while ((evcon = TAILQ_FIRST(&http->connections)) != NULL) { in evhttp_free()
3738 evhttp_connection_free(evcon); in evhttp_free()
4069 return req->evcon; in evhttp_request_get_connection()
4216 struct evhttp_connection *evcon; in evhttp_get_request_connection() local
4241 evcon = evhttp_connection_base_bufferevent_new( in evhttp_get_request_connection()
4245 if (evcon == NULL) in evhttp_get_request_connection()
4248 evcon->max_headers_size = http->default_max_headers_size; in evhttp_get_request_connection()
4249 evcon->max_body_size = http->default_max_body_size; in evhttp_get_request_connection()
4251 evcon->flags |= EVHTTP_CON_LINGERING_CLOSE; in evhttp_get_request_connection()
4253 evcon->flags |= EVHTTP_CON_INCOMING; in evhttp_get_request_connection()
4254 evcon->state = EVCON_READING_FIRSTLINE; in evhttp_get_request_connection()
4256 evcon->fd = fd; in evhttp_get_request_connection()
4258 if (bufferevent_setfd(evcon->bufev, fd)) in evhttp_get_request_connection()
4260 if (bufferevent_enable(evcon->bufev, EV_READ)) in evhttp_get_request_connection()
4262 if (bufferevent_disable(evcon->bufev, EV_WRITE)) in evhttp_get_request_connection()
4264 bufferevent_socket_set_conn_address_(evcon->bufev, sa, salen); in evhttp_get_request_connection()
4266 return (evcon); in evhttp_get_request_connection()
4269 evhttp_connection_free(evcon); in evhttp_get_request_connection()
4274 evhttp_associate_new_request_with_connection(struct evhttp_connection *evcon) in evhttp_associate_new_request_with_connection() argument
4276 struct evhttp *http = evcon->http_server; in evhttp_associate_new_request_with_connection()
4281 if ((req->remote_host = mm_strdup(evcon->address)) == NULL) { in evhttp_associate_new_request_with_connection()
4286 req->remote_port = evcon->port; in evhttp_associate_new_request_with_connection()
4288 req->evcon = evcon; /* the request ends up owning the connection */ in evhttp_associate_new_request_with_connection()
4298 TAILQ_INSERT_TAIL(&evcon->requests, req, next); in evhttp_associate_new_request_with_connection()
4303 evhttp_start_read_(evcon); in evhttp_associate_new_request_with_connection()
4312 struct evhttp_connection *evcon; in evhttp_get_request() local
4314 evcon = evhttp_get_request_connection(http, fd, sa, salen); in evhttp_get_request()
4315 if (evcon == NULL) { in evhttp_get_request()
4324 evhttp_connection_set_timeout_tv(evcon, &http->timeout); in evhttp_get_request()
4330 evcon->http_server = http; in evhttp_get_request()
4331 TAILQ_INSERT_TAIL(&http->connections, evcon, next); in evhttp_get_request()
4333 if (evhttp_associate_new_request_with_connection(evcon) == -1) in evhttp_get_request()
4334 evhttp_connection_free(evcon); in evhttp_get_request()