Mercurial > dovecot > core-2.2
changeset 18964:c1ffec72a134
lib-http: url: Implemented functions to copy/clone URLs including the userinfo part (normally skipped).
author | Stephan Bosch <stephan@rename-it.nl> |
---|---|
date | Tue, 18 Aug 2015 20:39:24 +0300 |
parents | 07ceb84bf899 |
children | aa695f538fd0 |
files | src/lib-http/http-url.c src/lib-http/http-url.h |
diffstat | 2 files changed, 26 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-url.c Tue Aug 18 20:39:24 2015 +0300 +++ b/src/lib-http/http-url.c Tue Aug 18 20:39:24 2015 +0300 @@ -450,7 +450,15 @@ dest->enc_fragment = p_strdup(pool, src->enc_fragment); } -struct http_url *http_url_clone(pool_t pool,const struct http_url *src) +void http_url_copy_with_userinfo(pool_t pool, struct http_url *dest, + const struct http_url *src) +{ + http_url_copy(pool, dest, src); + dest->user = p_strdup(pool, src->user); + dest->password = p_strdup(pool, src->password); +} + +struct http_url *http_url_clone(pool_t pool, const struct http_url *src) { struct http_url *new_url; @@ -460,6 +468,18 @@ return new_url; } +struct http_url *http_url_clone_with_userinfo(pool_t pool, + const struct http_url *src) +{ + struct http_url *new_url; + + new_url = p_new(pool, struct http_url, 1); + http_url_copy_with_userinfo(pool, new_url, src); + + return new_url; +} + + /* * HTTP URL construction */
--- a/src/lib-http/http-url.h Tue Aug 18 20:39:24 2015 +0300 +++ b/src/lib-http/http-url.h Tue Aug 18 20:39:24 2015 +0300 @@ -59,7 +59,12 @@ const struct http_url *src); void http_url_copy(pool_t pool, struct http_url *dest, const struct http_url *src); +void http_url_copy_with_userinfo(pool_t pool, struct http_url *dest, + const struct http_url *src); + struct http_url *http_url_clone(pool_t pool,const struct http_url *src); +struct http_url *http_url_clone_with_userinfo(pool_t pool, + const struct http_url *src); /* * HTTP URL construction