curl_url_set(3) | libcurl Manual | curl_url_set(3) |
curl_url_set - set a URL part
#include <curl/curl.h>
CURLUcode curl_url_set(CURLU *url,
CURLUPart part,
const char *content,
unsigned int flags)
Given the url handle of an already parsed URL, this function lets the user set/update individual pieces of it.
The part argument should identify the particular URL part (see list below) to set or change, with content pointing to a zero terminated string with the new contents for that URL part. The contents should be in the form and encoding they'd use in a URL: URL encoded.
Setting a part to a NULL pointer will effectively remove that part's contents from the CURLU handle.
The flags argument is a bitmask with independent features.
When successfully setting a new URL, relative or absolute, the handle contents will be replaced with the information of the newly set URL.
Pass a pointer to a zero terminated string to the url parameter. The string must point to a correctly formatted "RFC 3986+" URL or be a NULL pointer.
If used together with the CURLU_APPENDQUERY bit, the provided part will be appended on the end of the existing query - and if the previous part didn't end with an ampersand (&), an ampersand will be inserted before the new appended part.
When CURLU_APPENDQUERY is used together with CURLU_URLENCODE, the first '=' symbol will not be URL encoded.
The question mark in the URL is not part of the actual query contents.
The flags argument is zero, one or more bits set in a bitmask.
When setting the path component with URL encoding enabled, the slash character will be skipped.
The query part gets space-to-plus conversion before the URL conversion.
This URL encoding is charset unaware and will convert the input on a byte-by-byte manner.
Returns a CURLUcode error value, which is CURLUE_OK (0) if everything went fine.
If this function returns an error, no URL part is returned.
CURLUcode rc;
CURLU *url = curl_url();
rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
if(!rc) {
char *scheme;
/* change it to an FTP URL */
rc = curl_url_set(url, CURLUPART_SCHEME, "ftp", 0);
}
curl_url_cleanup(url);
Added in curl 7.62.0
curl_url_cleanup(3), curl_url(3), curl_url_get(3), curl_url_dup(3),
November 6, 2018 | libcurl 7.64.0 |