Message ID | 20180305154006.18122-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/8] channel_curl: add support for Basic Auth credentials | expand |
On 05/03/2018 16:39, Christian Storm wrote: > Implement Basic Auth credentials support in channel_curl > like commit 1243723 has done for the downloader only, in > preparation to make the downloader use channel_curl. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/channel_curl.c | 9 +++++++++ > include/channel_curl.h | 1 + > 2 files changed, 10 insertions(+) > > diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c > index 0dec551..a94243d 100644 > --- a/corelib/channel_curl.c > +++ b/corelib/channel_curl.c > @@ -454,6 +454,15 @@ channel_op_res_t channel_set_options(channel_t *this, > } > } > > + if (channel_data->auth) { > + if (curl_easy_setopt(channel_curl->handle, CURLOPT_USERPWD, > + channel_data->auth) != CURLE_OK) { > + ERROR("Basic Auth credentials could not be set."); > + result = CHANNEL_EINIT; > + goto cleanup; > + } > + } > + > cleanup: > return result; > } > diff --git a/include/channel_curl.h b/include/channel_curl.h > index 2133744..3af470a 100644 > --- a/include/channel_curl.h > +++ b/include/channel_curl.h > @@ -30,6 +30,7 @@ typedef enum { > > typedef struct { > char *url; > + char *auth; > char *json_string; > json_object *json_reply; > char *cafile; > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 0dec551..a94243d 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -454,6 +454,15 @@ channel_op_res_t channel_set_options(channel_t *this, } } + if (channel_data->auth) { + if (curl_easy_setopt(channel_curl->handle, CURLOPT_USERPWD, + channel_data->auth) != CURLE_OK) { + ERROR("Basic Auth credentials could not be set."); + result = CHANNEL_EINIT; + goto cleanup; + } + } + cleanup: return result; } diff --git a/include/channel_curl.h b/include/channel_curl.h index 2133744..3af470a 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -30,6 +30,7 @@ typedef enum { typedef struct { char *url; + char *auth; char *json_string; json_object *json_reply; char *cafile;
Implement Basic Auth credentials support in channel_curl like commit 1243723 has done for the downloader only, in preparation to make the downloader use channel_curl. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/channel_curl.c | 9 +++++++++ include/channel_curl.h | 1 + 2 files changed, 10 insertions(+)