LI_API liStream* li_stream_http_response_handle(liStream *http_in, liVRequest *vr, gboolean accept_cgi, gboolean accept_nph) { liStreamHttpResponse *shr = g_slice_new0(liStreamHttpResponse); shr->response_headers_finished = FALSE; shr->vr = vr; li_stream_init(&shr->stream, &vr->wrk->loop, stream_http_response_cb); li_http_response_parser_init(&shr->parse_response_ctx, &vr->response, http_in->out, accept_cgi, accept_nph); li_stream_connect(http_in, &shr->stream); return &shr->stream; }
static proxy_connection* proxy_connection_new(liVRequest *vr, proxy_context *ctx) { proxy_connection* pcon = g_slice_new0(proxy_connection); proxy_context_acquire(ctx); pcon->ctx = ctx; pcon->vr = vr; pcon->fd = -1; ev_init(&pcon->fd_watcher, proxy_fd_cb); ev_io_set(&pcon->fd_watcher, -1, 0); pcon->fd_watcher.data = pcon; pcon->proxy_in = li_chunkqueue_new(); pcon->proxy_out = li_chunkqueue_new(); pcon->state = SS_WAIT_FOR_REQUEST; li_http_response_parser_init(&pcon->parse_response_ctx, &vr->response, pcon->proxy_in, FALSE, FALSE); pcon->response_headers_finished = FALSE; return pcon; }
static fastcgi_connection* fastcgi_connection_new(liVRequest *vr, fastcgi_context *ctx) { fastcgi_connection* fcon = g_slice_new0(fastcgi_connection); fastcgi_context_acquire(ctx); fcon->ctx = ctx; fcon->vr = vr; fcon->fd = -1; ev_init(&fcon->fd_watcher, fastcgi_fd_cb); ev_io_set(&fcon->fd_watcher, -1, 0); fcon->fd_watcher.data = fcon; fcon->fcgi_in = li_chunkqueue_new(); fcon->fcgi_out = li_chunkqueue_new(); fcon->stdout = li_chunkqueue_new(); fcon->buf_in_record = g_byte_array_sized_new(FCGI_HEADER_LEN); fcon->requestid = 1; fcon->state = FS_WAIT_FOR_REQUEST; li_http_response_parser_init(&fcon->parse_response_ctx, &vr->response, fcon->stdout, TRUE, FALSE); fcon->response_headers_finished = FALSE; return fcon; }