mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 14:26:30 -04:00
r15346@tombo: nickm | 2008-04-29 17:19:18 -0400
Remove the never-exported, never-used, never-threadsafe evhttp_hostportfile() svn:r746
This commit is contained in:
parent
9626a421de
commit
98dc98c59f
@ -78,7 +78,7 @@ Changes in current version:
|
||||
o introduce bufferevent_setcb and bufferevent_setfd to allow better manipulation of bufferevents
|
||||
o convert evhttp_connection to use bufferevents.
|
||||
o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy.
|
||||
|
||||
o Remove the never-exported, never-used evhttp_hostportfile function.
|
||||
|
||||
Changes in 1.4.0:
|
||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||
|
12
evhttp.h
12
evhttp.h
@ -362,18 +362,6 @@ 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.
|
||||
* XXXX This interface will change before release to become threadsafe.
|
||||
*
|
||||
* @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(const char *url, char **phost, u_short *pport, char **pfile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
57
http.c
57
http.c
@ -466,63 +466,6 @@ evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
/* Separate host, port and file from URI */
|
||||
|
||||
int
|
||||
evhttp_hostportfile(const char *url, char **phost, u_short *pport, char **pfile)
|
||||
{
|
||||
/* XXX not threadsafe. */
|
||||
static char host[1024];
|
||||
static char file[1024];
|
||||
char *p;
|
||||
const char *p2;
|
||||
int len;
|
||||
u_short port;
|
||||
|
||||
len = strlen(HTTP_PREFIX);
|
||||
if (strncasecmp(url, HTTP_PREFIX, len))
|
||||
return (-1);
|
||||
|
||||
url += len;
|
||||
|
||||
/* We might overrun */
|
||||
if (strlcpy(host, url, sizeof (host)) >= sizeof(host))
|
||||
return (-1);
|
||||
|
||||
p = strchr(host, '/');
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
p2 = p + 1;
|
||||
} else
|
||||
p2 = NULL;
|
||||
|
||||
if (pfile != NULL) {
|
||||
/* Generate request file */
|
||||
if (p2 == NULL)
|
||||
p2 = "";
|
||||
snprintf(file, sizeof(file), "/%s", p2);
|
||||
}
|
||||
|
||||
p = strchr(host, ':');
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
port = atoi(p + 1);
|
||||
|
||||
if (port == 0)
|
||||
return (-1);
|
||||
} else
|
||||
port = HTTP_DEFAULTPORT;
|
||||
|
||||
if (phost != NULL)
|
||||
*phost = host;
|
||||
if (pport != NULL)
|
||||
*pport = port;
|
||||
if (pfile != NULL)
|
||||
*pfile = file;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
evhttp_connection_incoming_fail(struct evhttp_request *req,
|
||||
enum evhttp_connection_error error)
|
||||
|
@ -1632,8 +1632,6 @@ static void
|
||||
http_primitives(void)
|
||||
{
|
||||
char *escaped;
|
||||
char *host = NULL, *path = NULL;
|
||||
unsigned short port = 0;
|
||||
fprintf(stdout, "Testing HTTP Primitives: ");
|
||||
|
||||
escaped = evhttp_htmlescape("<script>");
|
||||
@ -1646,24 +1644,6 @@ http_primitives(void)
|
||||
goto failed;
|
||||
free(escaped);
|
||||
|
||||
if (evhttp_hostportfile("fto://some", NULL, NULL, NULL) != -1)
|
||||
goto failed;
|
||||
|
||||
if (evhttp_hostportfile("http://www.foo.com/path.html",
|
||||
&host, &port, &path) == -1)
|
||||
goto failed;
|
||||
|
||||
if (strcmp(host, "www.foo.com") || port != 80 ||
|
||||
strcmp(path, "/path.html"))
|
||||
goto failed;
|
||||
|
||||
if (evhttp_hostportfile("http://foo.com:8080",
|
||||
&host, &port, &path) == -1)
|
||||
goto failed;
|
||||
|
||||
if (strcmp(host, "foo.com") || port != 8080 || strcmp(path, "/"))
|
||||
goto failed;
|
||||
|
||||
fprintf(stdout, "OK\n");
|
||||
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user