search for: curl_open

Displaying 18 results from an estimated 18 matches for "curl_open".

2020 Jan 08
1
[nbdkit PATCH] curl: use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T when available
...s/curl/curl.c @@ -70,6 +70,10 @@ static long protocols = CURLPROTO_ALL; /* Use '-D curl.verbose=1' to set. */ int curl_debug_verbose = 0; +#if CURL_AT_LEAST_VERSION(7, 55, 0) +#define HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T +#endif + static void curl_load (void) { @@ -290,6 +294,9 @@ curl_open (int readonly) struct curl_handle *h; CURLcode r; double d; +#ifdef HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T + curl_off_t o; +#endif h = calloc (1, sizeof *h); if (h == NULL) { @@ -377,6 +384,21 @@ curl_open (int readonly) goto err; } +#ifdef HAVE_CURLINFO_CONTENT_LENGTH_...
2020 Jan 07
3
[PATCH] Fix lossy conversion of Content-Length
...an Ambro?ewicz <adrian.ambrozewicz at linux.intel.com> --- plugins/curl/curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c index 031bd32..fe1330e 100644 --- a/plugins/curl/curl.c +++ b/plugins/curl/curl.c @@ -389,7 +389,7 @@ curl_open (int readonly) goto err; } - h->exportsize = (size_t) d; + h->exportsize = (int64_t) d; nbdkit_debug ("content length: %" PRIi64, h->exportsize); if (strncasecmp (url, "http://", strlen ("http://")) == 0 || -- 2.17.1
2020 Jan 09
2
Re: [PATCH] Fix lossy conversion of Content-Length
...t;  plugins/curl/curl.c | 2 +- > >  1 file changed, 1 insertion(+), 1 deletion(-) > > > >diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c > >index 031bd32..fe1330e 100644 > >--- a/plugins/curl/curl.c > >+++ b/plugins/curl/curl.c > >@@ -389,7 +389,7 @@ curl_open (int readonly) > >      goto err; > >    } > > > >-  h->exportsize = (size_t) d; > >+  h->exportsize = (int64_t) d; > > Why is a cast needed at all? > This is C, an implicit conversion > works just as well. Present since the initial commit, but not...
2020 Jan 09
2
Re: [PATCH] Fix lossy conversion of Content-Length
...ged, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c > >>> index 031bd32..fe1330e 100644 > >>> --- a/plugins/curl/curl.c > >>> +++ b/plugins/curl/curl.c > >>> @@ -389,7 +389,7 @@ curl_open (int readonly) > >>> goto err; > >>> } > >>> > >>> - h->exportsize = (size_t) d; > >>> + h->exportsize = (int64_t) d; > >> > >> Why is a cast needed at all? > >> This is C, an implicit conversio...
2020 Jan 17
1
[PATCH nbdkit] Add cainfo and capath options to curl plugin
...to directory with CA certificates.\n" \ "cookie=<COOKIE> Set HTTP/HTTPS cookies.\n" \ "password=<PASSWORD> The password for the user account.\n" \ "protocols=PROTO,PROTO,.. Limit protocols allowed.\n" \ @@ -369,6 +381,10 @@ curl_open (int readonly) curl_easy_setopt (h->c, CURLOPT_PROXYPASSWORD, proxy_password); if (cookie) curl_easy_setopt (h->c, CURLOPT_COOKIE, cookie); + if (cainfo) + curl_easy_setopt (h->c, CURLOPT_CAINFO, cainfo); + if (capath) + curl_easy_setopt (h->c, CURLOPT_CAPATH, capat...
2020 Jan 08
0
Re: [PATCH] Fix lossy conversion of Content-Length
...x.intel.com> > --- >  plugins/curl/curl.c | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c > index 031bd32..fe1330e 100644 > --- a/plugins/curl/curl.c > +++ b/plugins/curl/curl.c > @@ -389,7 +389,7 @@ curl_open (int readonly) >      goto err; >    } > > -  h->exportsize = (size_t) d; > +  h->exportsize = (int64_t) d; Why is a cast needed at all? This is C, an implicit conversion works just as well. >    nbdkit_debug ("content length: %" PRIi64, h->exportsize);...
2020 Jan 09
0
Re: [PATCH] Fix lossy conversion of Content-Length
...+- >>>  1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c >>> index 031bd32..fe1330e 100644 >>> --- a/plugins/curl/curl.c >>> +++ b/plugins/curl/curl.c >>> @@ -389,7 +389,7 @@ curl_open (int readonly) >>>      goto err; >>>    } >>> >>> -  h->exportsize = (size_t) d; >>> +  h->exportsize = (int64_t) d; >> >> Why is a cast needed at all? >> This is C, an implicit conversion >> works just as well. > &gt...
2020 Jan 10
0
[PATCH v2] Fix lossy conversion of Content-Length
...drian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> --- plugins/curl/curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c index 031bd32..633840a 100644 --- a/plugins/curl/curl.c +++ b/plugins/curl/curl.c @@ -389,7 +389,7 @@ curl_open (int readonly) goto err; } - h->exportsize = (size_t) d; + h->exportsize = d; nbdkit_debug ("content length: %" PRIi64, h->exportsize); if (strncasecmp (url, "http://", strlen ("http://")) == 0 || -- 2.17.1
2019 Sep 23
0
Re: [PATCH nbdkit v2] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...p. > +++ b/plugins/curl/curl.c > @@ -62,7 +62,7 @@ static const char *proxy_user = NULL; > static char *proxy_password = NULL; > static char *cookie = NULL; > static bool sslverify = true; > -static long timeout = 0; > +static uint32_t timeout = 0; > @@ -334,7 +336,7 @@ curl_open (int readonly) > curl_easy_setopt (h->c, CURLOPT_REDIR_PROTOCOLS, protocols); > } > if (timeout > 0) > - curl_easy_setopt (h->c, CURLOPT_TIMEOUT, timeout); > + curl_easy_setopt (h->c, CURLOPT_TIMEOUT, (long) timeout); I might have left a comment here (th...
2020 Jul 20
1
Re: [PATCH nbdkit v2] curl: Implement header and cookie scripts.
...header_script_renew = 0; > +char *password = NULL; All of these variables are already guaranteed zero-initialized without being explicit, > +long protocols = CURLPROTO_ALL; although consistency with this initialization (which is not necessarily 0) makes sense. > @@ -450,7 +490,11 @@ curl_open (int readonly) > > /* Get the file size and also whether the remote HTTP server > * supports byte ranges. > + * > + * We must run the scripts if necessary and set headers in the > + * handle. > */ > + if (do_scripts (h) == -1) goto err; Okay, code ma...
2019 Sep 23
2
[PATCH nbdkit v2] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...meout) != 1 || timeout < 0) { + if (nbdkit_parse_uint32_t ("timeout", value, &timeout) == -1) + return -1; + if (timeout < 0) { nbdkit_error ("'timeout' must be 0 or a positive timeout in seconds"); return -1; } @@ -334,7 +336,7 @@ curl_open (int readonly) curl_easy_setopt (h->c, CURLOPT_REDIR_PROTOCOLS, protocols); } if (timeout > 0) - curl_easy_setopt (h->c, CURLOPT_TIMEOUT, timeout); + curl_easy_setopt (h->c, CURLOPT_TIMEOUT, (long) timeout); if (!sslverify) { curl_easy_setopt (h->c, CURLOPT_S...
2020 Jul 15
2
[PATCH nbdkit v2] curl: Implement header and cookie scripts.
Evolution of this patch series: https://www.redhat.com/archives/libguestfs/2020-July/thread.html#00073 Instead of auth-script, this implements header-script and cookie-script. It can be used for similar purposes but the implementation is somewhat saner. Rich.
2020 May 19
1
[PATCH nbdkit] common/include: Add locale-safe ascii_strcasecmp and ascii_strncasecmp.
...lugins/curl/curl.c index f4afc826..b3059ed4 100644 --- a/plugins/curl/curl.c +++ b/plugins/curl/curl.c @@ -58,6 +58,7 @@ #include "cleanup.h" #include "ascii-ctype.h" +#include "ascii-string.h" static const char *url = NULL; /* required */ @@ -477,8 +478,8 @@ curl_open (int readonly) #endif nbdkit_debug ("content length: %" PRIi64, h->exportsize); - if (strncasecmp (url, "http://", strlen ("http://")) == 0 || - strncasecmp (url, "https://", strlen ("https://")) == 0) { + if (ascii_strncasecmp (url,...
2020 Jul 14
0
[PATCH nbdkit RFC 2/2] curl: Implement authorization scripts.
...; - char *write_buf; - uint32_t write_count; - const char *read_buf; - uint32_t read_count; -}; - /* Translate CURLcode to nbdkit_error. */ #define display_curl_error(h, r, fs, ...) \ do { \ @@ -450,7 +456,12 @@ curl_open (int readonly) /* Get the file size and also whether the remote HTTP server * supports byte ranges. + * + * We must run the auth-script if necessary and set headers in the + * handle. */ + if (auth_script && do_auth_script (h) == -1) + goto err; h->accept_range...
2020 Jul 14
3
[PATCH nbdkit RFC 0/2] curl: Implement authorization scripts.
This is an RFC only, at the very least it lacks tests. This implements a rather complex new feature in nbdkit-curl-plugin allowing you to specify an external shell script that can be used to fetch an authorization token for services which requires a token or cookie for access, especially if that token must be renewed periodically. The motivation can be seen in the changes to the docs in patch 2.
2020 Jul 15
0
[PATCH nbdkit v2] curl: Implement header and cookie scripts.
...; - char *write_buf; - uint32_t write_count; - const char *read_buf; - uint32_t read_count; -}; - /* Translate CURLcode to nbdkit_error. */ #define display_curl_error(h, r, fs, ...) \ do { \ @@ -450,7 +490,11 @@ curl_open (int readonly) /* Get the file size and also whether the remote HTTP server * supports byte ranges. + * + * We must run the scripts if necessary and set headers in the + * handle. */ + if (do_scripts (h) == -1) goto err; h->accept_range = false; curl_easy_setopt (h->...
2018 Dec 04
3
patch to support custom HTTP headers in download.file() and url()
...d Curl_close(Rconnection con) { RCurlconn ctxt = (RCurlconn)(con->private); + curl_slist_free_all(ctxt->headers); curl_multi_remove_handle(ctxt->mh, ctxt->hnd); curl_easy_cleanup(ctxt->hnd); curl_multi_cleanup(ctxt->mh); @@ -830,6 +850,9 @@ static Rboolean Curl_open(Rconnection con) curl_easy_setopt(ctxt->hnd, CURLOPT_TCP_KEEPALIVE, 1L); #endif + if (ctxt->headers) { + curl_easy_setopt(ctxt->hnd, CURLOPT_HTTPHEADER, ctxt->headers); + } curl_easy_setopt(ctxt->hnd, CURLOPT_WRITEFUNCTION, rcvData); curl_easy_setopt(ctxt->h...
2019 Sep 23
2
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
On Mon, Sep 23, 2019 at 12:05:11PM -0500, Eric Blake wrote: > > + int nbdkit_parse_long (const char *what, const char *str, long *r); > > + int nbdkit_parse_unsigned_long (const char *what, > > + const char *str, unsigned long *r); > > Do we really want to encourage the use of parse_long and > parse_unsigned_long? Those differ between