Message ID | 90A8B813-C97C-4585-A1C3-E91CBBC8D669@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2] channel_curl: Fix getting the protocol for curl >= 7.85.0 | expand |
'Storm, Christian' via swupdate wrote on Tue, Jun 11, 2024 at 11:09:19AM +0000: > CURLINFO_PROTOCOL, deprecated in 7.85.0, uses a long to represent > the protocol used while the newer CURLINFO_SCHEME uses a string. > > See https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html > and https://curl.se/libcurl/c/CURLINFO_SCHEME.html > > Signed-off-by: Christian Storm <christian.storm@siemens.com> Thanks for v2! Reviewed-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > corelib/channel_curl.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c > index 368330bd..36db2284 100644 > --- a/corelib/channel_curl.c > +++ b/corelib/channel_curl.c > @@ -307,7 +307,11 @@ char *channel_get_redirect_url(channel_t *this) > channel_op_res_t channel_map_http_code(channel_t *this, long *http_response_code) > { > char *url = NULL; > - long protocol; > +#if LIBCURL_VERSION_NUM >= 0x75500 > + char *protocol = NULL; > +#else > + long protocol = 0; > +#endif > channel_curl_t *channel_curl = this->priv; > CURLcode curlrc = > curl_easy_getinfo(channel_curl->handle, CURLINFO_RESPONSE_CODE, > @@ -329,7 +333,14 @@ channel_op_res_t channel_map_http_code(channel_t *this, long *http_response_code > CURLINFO_PROTOCOL, > #endif > &protocol); > - if (curlrc == CURLE_OK && protocol == CURLPROTO_FILE) { > + if (curlrc == CURLE_OK > +#if LIBCURL_VERSION_NUM >= 0x75500 > + && protocol > + && !strcasecmp(protocol, "file") > +#else > + && protocol == CURLPROTO_FILE > +#endif > + ) { > return CHANNEL_OK; > } > DEBUG("No HTTP response code has been received yet!");
diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 368330bd..36db2284 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -307,7 +307,11 @@ char *channel_get_redirect_url(channel_t *this) channel_op_res_t channel_map_http_code(channel_t *this, long *http_response_code) { char *url = NULL; - long protocol; +#if LIBCURL_VERSION_NUM >= 0x75500 + char *protocol = NULL; +#else + long protocol = 0; +#endif channel_curl_t *channel_curl = this->priv; CURLcode curlrc = curl_easy_getinfo(channel_curl->handle, CURLINFO_RESPONSE_CODE, @@ -329,7 +333,14 @@ channel_op_res_t channel_map_http_code(channel_t *this, long *http_response_code CURLINFO_PROTOCOL, #endif &protocol); - if (curlrc == CURLE_OK && protocol == CURLPROTO_FILE) { + if (curlrc == CURLE_OK +#if LIBCURL_VERSION_NUM >= 0x75500 + && protocol + && !strcasecmp(protocol, "file") +#else + && protocol == CURLPROTO_FILE +#endif + ) { return CHANNEL_OK; } DEBUG("No HTTP response code has been received yet!");
CURLINFO_PROTOCOL, deprecated in 7.85.0, uses a long to represent the protocol used while the newer CURLINFO_SCHEME uses a string. See https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html and https://curl.se/libcurl/c/CURLINFO_SCHEME.html Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/channel_curl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)