📌  相关文章
📜  libevent 解析多部分表单数据站点:stackoverflow.com - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:31.690000             🧑  作者: Mango

代码示例3
void upload_cb(struct evhttp_request *req, void *arg){
    struct bufferevent *bev = evhttp_connection_get_bufferevent(req->evcon);
    if (bev) //Prio is initialized with 10 states in main
        bufferevent_priority_set(bev, 9); // set to low priority
    struct evbuffer* post_buffer = evhttp_request_get_input_buffer(req);
    size_t body_size = evbuffer_get_length(post_buffer);
    // a multipart parser takes care of writing the 
    // post_buffer content to a file
    // this takes a few seconds and after completing this 
    // the status_cb is accessible again
}

void status_cb(struct evhttp_request *req, void *arg){
    // send some json
}

evhttp_set_cb(_http, "/upload", upload_cb, NULL);
evhttp_set_cb(_http, "/status", status_cb, NULL);