libevent HTTP client 的实现
my_conn_ = evhttp_connection_base_new(ev_base_,ev_dns_,host,port); 47 48 49 50 struct evhttp_request *http_req; 51 http_req = evhttp_request_new(rspCallback,(void *)arg); //rspCallback接收消息 52 struct evkeyvalq *head = evhttp_request_get_output_headers(http_req); 53 55 evhttp_add_header(head,"User-Agent","My Device"); 56 evhttp_add_header(head,"Connection","Keep-Alive"); 57 char buf[16]; 58 snprintf(buf,15,"%d",req.terminaltype); 59 evhttp_add_header(head,"terminaltype",buf); 60 evhttp_add_header(head,"versioninfo",req.version_info.c_str()); 61 evhttp_add_header(head,"osinfo",req.osinfo.c_str()); 62 evhttp_add_header(head,"despasswd",req.despasswd.c_str()); 63 66 evhttp_add_header(head,"Host",host); 67 68 int ret = evhttp_make_request(my_conn_,http_req,EVHTTP_REQ_PUT,"/myurl"); 69 evhttp_uri_free(uri);