2017-03-03 5 views
1

私はlibeventとevhttpを使ってクライアントのPOST要求本体をストリーミングしたいと思います。私は固定機関でリクエストを送信する例を見つけましたが、未定義の期間、継続的に書き込みおよび更新する必要がある身体でリクエストをセットアップする方法がわかりません。これは可能でしょうか?現在のコードベースラインは次のようになります。libevent evhttpを使用したスト​​リームクライアント要求本文?

#include <evhttp.h> 
#include <event2/event.h> 
#include <event2/http.h> 

void http_request_done(struct evhttp_request *req, void *arg) { 
    printf("DONE!\n"); 
} 

int main(int argc, char **argv) { 
    struct event_base *base = event_base_new(); 
    struct evhttp_connection *conn = evhttp_connection_base_new(base, NULL, "127.0.0.1", 3000); 
    struct evhttp_request *req = evhttp_request_new(http_request_done, NULL); 

    evhttp_make_request(conn, req, EVHTTP_REQ_POST, "/"); 
    evhttp_connection_set_timeout(req->evcon, 600); 
    event_base_loop(base, EVLOOP_NONBLOCK); 
    event_base_dispatch(base); 

    return 0; 
} 

ストリーミングボディでPOSTリクエストを送信するにはどうすればよいですか?

答えて

0

LibEventにはチャンク関数があります。あなたは私たちがin documentationこれらの機能を見ることができるコード例を参照してくださいlike thisthis one

することができます - チャンク()ループのスタートの間()/終了(): `

evhttp_send_reply_start(構造体evhttp_request * REQ)

evhttp_send_reply_chunk(構造体evhttp_request * REQ、構造体evbuffer * databuf)

evhttp_send_reply_end(struct evhttp_request * req) `。

者は、送信のためのもの、そしてあなたが入ってくるチャンクデータを取得する必要がある場合evhttp_request_set_chunked_cb()

あり
関連する問題