Пример #1
0
static inline void
call_wsgi_app(client_t *client, picoev_loop* loop)
{
    int ret;
    ret = process_wsgi_app(client);

#ifdef DEBUG
    printf("call_wsgi_app result %d \n", ret);
#endif
    switch(ret){
        case -1:
            //Internal Server Error
            client->bad_request_code = 500;
            send_error_page(client);
            close_conn(client, loop);
            return;
        case 0:
            // suspend
            return;
        default:
            break;
    }
    
    
    if(client->response_closed){
        //closed
        close_conn(client, loop);
        return;
    }
    ret = response_start(client);
#ifdef DEBUG
    printf("response_start result %d \n", ret);
#endif
    switch(ret){
        case -1:
            // Internal Server Error
            client->bad_request_code = 500;
            send_error_page(client);
            close_conn(client, loop);
            return;
        case 0:
            // continue
            // set callback
#ifdef DEBUG
            printf("set write callback %d \n", ret);
#endif
            //clear event
            picoev_del(loop, client->fd);
            picoev_add(loop, client->fd, PICOEV_WRITE, 0, w_callback, (void *)client);
            return;
        default:
            // send OK
            close_conn(client, loop);
    }
    
    
}
Пример #2
0
static void
call_rack_app(client_t *client, picoev_loop* loop)
{
  int ret;
  if(!process_rack_app(client)){
    //Internal Server Error
    client->bad_request_code = 500;
    send_error_page(client);
    close_conn(client, loop);
    return;
  }

  ret = response_start(client);
  /* printf("response_start done: %d\n", ret); */
  switch(ret){
  case -1:
    // Internal Server Error
    client->bad_request_code = 500;
    send_error_page(client);
    close_conn(client, loop);
    return;
  case 0:
    // continue
    // set callback
#ifdef DEBUG
    printf("set write callback %d \n", ret);
#endif
    //clear event
    picoev_del(loop, client->fd);
    picoev_add(loop, client->fd, PICOEV_WRITE, WRITE_TIMEOUT_SECS, w_callback, (void *)client);
    return;
  default:
    // send OK
    close_conn(client, loop);
  }
}