124 |
124 |
125 |
125 |
126 SessionHandler* create_basic_session_handler() { |
126 SessionHandler* create_basic_session_handler() { |
127 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); |
127 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); |
128 handler->threadpool = threadpool_new(4, 8); |
128 handler->threadpool = threadpool_new(4, 8); |
|
129 threadpool_start(handler->threadpool); // TODO: handle error |
129 handler->sh.enqueue_connection = basic_enq_conn; |
130 handler->sh.enqueue_connection = basic_enq_conn; |
130 handler->sh.keep_alive = basic_keep_alive; |
131 handler->sh.keep_alive = basic_keep_alive; |
131 handler->sh.create_iostream = create_connection_iostream; |
132 handler->sh.create_iostream = create_connection_iostream; |
132 |
133 |
133 return (SessionHandler*)handler; |
134 return (SessionHandler*)handler; |
349 buf->cursize += r; |
350 buf->cursize += r; |
350 state = http_parser_process(parser); |
351 state = http_parser_process(parser); |
351 if(state == 2) { |
352 if(state == 2) { |
352 // parse error |
353 // parse error |
353 fatal_error(request, 400); |
354 fatal_error(request, 400); |
|
355 log_ereport(LOG_VERBOSE, "http parser: bad request"); |
|
356 //printf("\n\n%.*s\n\n", parser->request->netbuf->cursize, parser->request->netbuf->inbuf); |
|
357 //fflush(stdout); |
354 event->finish = evt_request_error; |
358 event->finish = evt_request_error; |
355 io->error = 2; |
359 io->error = 2; |
356 return 0; |
360 return 0; |
357 } else if(state == 1) { |
361 } else if(state == 1) { |
358 /* |
362 /* |