X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Furlhandling.c;fp=libcitadel%2Flib%2Furlhandling.c;h=44be3f598a6aa1e77dffb2b6ea684ecefaca4d57;hb=f05150ceed3e6b58f07173a40b54862754761dac;hp=6f7ebb58c628b945e7d20a36a668fba2b79b132c;hpb=ddd73c55e1c30f256b7a539d0a994232fc6bf318;p=citadel.git diff --git a/libcitadel/lib/urlhandling.c b/libcitadel/lib/urlhandling.c index 6f7ebb58c..44be3f598 100644 --- a/libcitadel/lib/urlhandling.c +++ b/libcitadel/lib/urlhandling.c @@ -23,6 +23,8 @@ void FreeURL(ParsedURL** Url) { if (*Url != NULL) { FreeStrBuf(&(*Url)->URL); + FreeStrBuf(&(*Url)->UrlWithoutCred); + FreeStrBuf(&(*Url)->CurlCreds); if ((*Url)->Next != NULL) FreeURL(&(*Url)->Next); free(*Url); @@ -109,3 +111,25 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) *Url = url; return 1; } + +void CurlPrepareURL(ParsedURL *Url) +{ + if (!strcmp(ChrPtr(Url->URL), "http")) + Url->UrlWithoutCred = NewStrBufPlain(ChrPtr(Url->URL), -1); + else + Url->UrlWithoutCred = NewStrBufPlain(HKEY("http://")); + StrBufAppendBufPlain(Url->UrlWithoutCred, Url->Host, -1, 0); + StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY(":"), 0); + + StrBufAppendPrintf(Url->UrlWithoutCred, "%u", Url->Port); + StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY("/"), 0); + if (Url->LocalPart) + StrBufAppendBufPlain(Url->UrlWithoutCred, Url->LocalPart, -1, 0); + if (Url->User != NULL) + { + Url->CurlCreds = NewStrBufPlain(Url->User, -1); + StrBufAppendBufPlain(Url->CurlCreds, HKEY(":"), 0); + if (Url->Pass != NULL) + StrBufAppendBufPlain(Url->CurlCreds, Url->Pass, -1, 0); + } +}