From 72a3902e5c25272c0c6f690971633c5be947a392 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Tue, 29 Apr 2008 00:24:00 +0000 Subject: [PATCH] test some primitives from http.c svn:r739 --- evhttp.h | 11 +++++++++++ http.c | 2 +- test/regress_http.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/evhttp.h b/evhttp.h index 54c504b5..01d6395a 100644 --- a/evhttp.h +++ b/evhttp.h @@ -362,6 +362,17 @@ void evhttp_parse_query(const char *uri, struct evkeyvalq *); */ char *evhttp_htmlescape(const char *html); +/** + * Separate the host, port and path component from a URL. + * + * @param url the url for which to separate the components + * @param phost pointer in which to store the pointer to the host + * @param pport pointer in which to store the port number + * @param pfile pointer in which to store the pointer to the path + * @return 0 on success and -1 on failure + */ +int evhttp_hostportfile(char *url, char **phost, u_short *pport, char **pfile); + #ifdef __cplusplus } #endif diff --git a/http.c b/http.c index a0df7712..1695d610 100644 --- a/http.c +++ b/http.c @@ -465,7 +465,7 @@ evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req) } } -/* Separated host, port and file from URI */ +/* Separate host, port and file from URI */ int evhttp_hostportfile(char *url, char **phost, u_short *pport, char **pfile) diff --git a/test/regress_http.c b/test/regress_http.c index c25cd3c6..75a5bbf0 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -1384,9 +1384,56 @@ http_connection_retry(void) fprintf(stdout, "OK\n"); } +static void +http_primitives(void) +{ + char *escaped; + char *host = NULL, *path = NULL; + unsigned short port = 0; + fprintf(stdout, "Testing HTTP Primitives: "); + + escaped = evhttp_htmlescape("