That is more complicated. Ithinkyou could callevhttp_request_get_output_buffer()and check how much data is still in that buffer, and then decide to write more now, or sleep for a fraction of a second and check again. This is obviously not an optimal pattern, just a hacky start ... ...
unsigned chunked:1,/*a chunked request*/userdone:1;/*the user has sent all data*/structevbuffer *output_buffer;/*outgoing post or data*//*Callback*/void(*cb)(structevhttp_request *,void*);void*cb_arg;/** Chunked data callback - call for each completed chunk if * specified. If not...
print_request(request); //const char *uri=evhttp_request_get_uri(request); struct evbuffer *buffer=evbuffer_new(); //evbuffer_add(buffer,"coucou !",8); evbuffer_add_printf(buffer,"Hello World!"); evhttp_add_header(evhttp_request_get_output_headers(request),"Content-Type","test/plain");...
structevhttp_request: evkeyvalq*input_headers evkeyvalq*output_headers char*remote_host shortremote_port intkind inttype char*uri charmajor charminor evbuffer*input_buffer structconn_t"evhttp_connection": pass #headers intevhttp_add_header(evkeyvalq*q,char*name,char*val) ...
global->request->push(aireq); evhttp_clear_headers(&options); } 开发者ID:l33tmyst,项目名称:pentagod-forked,代码行数:31,代码来源:pentagohttpd.cpp 示例2: filter_query_into ▲点赞 5▼ staticvoidfilter_query_into(struct evbuffer *buf,constchar*full_url){structevkeyvalqparams;constchar*val;/*...
But you can emulate this manually, i.e. do not send new chunks if the output buffer is greater then some threshold, i.e. something like this (totally untested): voidreply_chunk_resched_cb(evutil_socket_tfd,shortevents,void*arg) {structconn_ctx*cctx=ctx;reply_chunk_cb(cctx->conn,ctx...
}voidReadChunkCallback(structevhttp_request*remote_rsp,void*arg){charbuf[4096];structevbuffer*evbuf=evhttp_request_get_input_buffer(remote_rsp);intn=0;while((n=evbuffer_remove(evbuf,buf,4096))>0){fwrite(buf,n,1,stdout);}}voidRemoteRequestErrorCallback(enumevhttp_request_errorerror,void*arg...
}/* Add the information that we care about */evhttp_add_header(req->output_headers,"Host","somehost");if(evhttp_make_request(evcon, req, EVHTTP_REQ_GET,"/?arg=val") ==-1) {fprintf(stdout,"FAILED\n");exit(1); } event_dispatch(); ...
struct evbuffer *buf = evhttp_request_get_output_buffer(this->req); evbuffer_add_printf(buf,"%s\n", iframe_header.c_str()); evhttp_send_reply_chunk(this->req, buf); }// send buffered messagesif(this->seq_next ==0){this->seq_next = channel->seq_next; ...