From: Niels Provos Date: Sat, 10 Jun 2006 22:28:21 +0000 (+0000) Subject: rename http.h to http-internal.h - i wish there were decent refactoring tools X-Git-Tag: release-2.0.1-alpha~734 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=147b71e33c34bd8fae7ea339b7ecdb742768656f;p=libevent rename http.h to http-internal.h - i wish there were decent refactoring tools for open source programmers. svn:r213 --- diff --git a/Makefile.am b/Makefile.am index c9ec0481..14ec3f66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ EXTRA_DIST = acconfig.h event.h event-internal.h log.h evsignal.h event.3 \ lib_LTLIBRARIES = libevent.la libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c event_tagging.c \ - http.c http.h + http.c http-internal.h libevent_la_LIBADD = @LTLIBOBJS@ libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:3:0 diff --git a/http-internal.h b/http-internal.h new file mode 100644 index 00000000..29e87b20 --- /dev/null +++ b/http-internal.h @@ -0,0 +1,125 @@ +/* + * Copyright 2001 Niels Provos + * All rights reserved. + * + * This header file contains definitions for dealing with HTTP requests + * that are internal to libevent. As user of the library, you should not + * need to know about these. + */ + +#ifndef _HTTP_H_ +#define _HTTP_H_ + +#define HTTP_CONNECT_TIMEOUT 45 +#define HTTP_WRITE_TIMEOUT 50 +#define HTTP_READ_TIMEOUT 50 + +#define HTTP_PREFIX "http://" +#define HTTP_DEFAULTPORT 80 + +struct evbuffer; +struct addrinfo; + +/* A stupid connection object - maybe make this a bufferevent later */ + +struct evhttp_connection { + int fd; + struct event ev; + + char *address; + u_short port; + + void (*cb)(struct evhttp_connection *, void *); + void *cb_arg; +}; + +enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE }; + +struct evhttp_request { + struct evkeyvalq *input_headers; + struct evkeyvalq *output_headers; + + char *remote_host; + u_short remote_port; + + enum evhttp_request_kind kind; + enum evhttp_cmd_type type; + + char *uri; /* uri after HTTP request was parsed */ + + char major; /* HTTP Major number */ + char minor; /* HTTP Minor number */ + + int got_firstline; + int response_code; /* HTTP Response code */ + char *response_code_line; /* Readable response */ + + int fd; + + struct event ev; + + struct evbuffer *buffer; + int ntoread; + + /* Callback */ + void (*cb)(struct evhttp_request *, void *); + void *cb_arg; + + void (*save_cb)(struct evhttp_request *, void *); + void *save_cbarg; +}; + +struct evhttp_cb { + TAILQ_ENTRY(evhttp_cb) next; + + char *what; + + void (*cb)(struct evhttp_request *req, void *); + void *cbarg; +}; + +struct evhttp { + struct event bind_ev; + + TAILQ_HEAD(httpcbq, evhttp_cb) callbacks; + + void (*gencb)(struct evhttp_request *req, void *); + void *gencbarg; +}; + +void evhttp_get_request(int, struct sockaddr *, socklen_t, + void (*)(struct evhttp_request *, void *), void *); + +/* + * Starts a connection to the specified address and invokes the callback + * if everything is fine. + */ +struct evhttp_connection *evhttp_connect( + const char *address, unsigned short port, + void (*cb)(struct evhttp_connection *, void *), void *cb_arg); + +/* Frees an http connection */ +void evhttp_connection_free(struct evhttp_connection *evcon); + +int evhttp_make_request(struct evhttp_connection *evcon, + struct evhttp_request *req, + enum evhttp_cmd_type type, const char *uri); + +int evhttp_hostportfile(char *, char **, u_short *, char **); + +int evhttp_parse_lines(struct evhttp_request *, struct evbuffer*); + +void evhttp_start_read(struct evhttp_request *); +void evhttp_read_header(int, short, void *); +void evhttp_make_header(struct evbuffer *, struct evhttp_request *); + +void evhttp_form_response(struct evbuffer *, struct evhttp_request *); +void evhttp_write_buffer(struct evhttp_request *, struct evbuffer *, + void (*)(struct evhttp_request *, void *), void *); + +/* response sending HTML the data in the buffer */ +void evhttp_response_code(struct evhttp_request *, int, const char *); +void evhttp_send_page(struct evhttp_request *, struct evbuffer *); +void evhttp_fail(struct evhttp_request *); + +#endif /* _HTTP_H */ diff --git a/http.c b/http.c index 9ff4dc4a..61f3b70f 100644 --- a/http.c +++ b/http.c @@ -67,7 +67,7 @@ #include "event.h" #include "log.h" -#include "http.h" +#include "http-internal.h" extern int debug; diff --git a/test/regress.c b/test/regress.c index 3f515838..32f2f2f6 100644 --- a/test/regress.c +++ b/test/regress.c @@ -54,7 +54,7 @@ #include "event.h" #include "log.h" -#include "http.h" +#include "http-internal.h" #include "regress.h" #include "regress.gen.h" diff --git a/test/regress_http.c b/test/regress_http.c index f96fa69d..8801bb21 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -54,7 +54,7 @@ #include "event.h" #include "log.h" -#include "http.h" +#include "http-internal.h" extern int pair[]; extern int test_ok;