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.
*/
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
}
}
-/* 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)
http_primitives(void)
{
char *escaped;
- char *host = NULL, *path = NULL;
- unsigned short port = 0;
fprintf(stdout, "Testing HTTP Primitives: ");
escaped = evhttp_htmlescape("<script>");
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;