Created
May 2, 2011 13:33
-
-
Save yangacer/951614 to your computer and use it in GitHub Desktop.
Send request via evhttp (1.4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void onCompleted(evhttp_request *req, void* arg) | |
{ | |
fprintf(stderr, "Request completed\n"); | |
fwrite(req->input_buffer->buffer, 1, req->input_buffer->off, stderr); | |
fprintf(stderr, "\n"); | |
} | |
int main(int argc, char **argv) | |
{ | |
char const *address = argv[1]; | |
short port = atoi(argv[2]); | |
char *remote_addr(0); | |
unsigned short remote_port; | |
event_init(); | |
evhttp_request *req = evhttp_request_new(&onCompleted, (void*)0); | |
evhttp_connection* conn = evhttp_connection_new(address, port); | |
evhttp_add_header(req->output_headers, "Accept", "text/html"); | |
evhttp_add_header(req->output_headers, "Host", "yangacer.twbbs.org"); | |
evhttp_make_request(conn, req, EVHTTP_REQ_GET, "/"); | |
event_dispatch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment