Lines Matching full:curl

4 Networking client functionality as provided by $(HTTP curl.haxx.se/libcurl,
26 You may need to link to the $(B curl) library, e.g. by adding $(D "libs": ["curl"])
99 import std.net.curl, std.stdio;
125 import std.net.curl, std.stdio;
144 Source: $(PHOBOSSRC std/net/curl.d)
150 Credits: The functionally is based on $(HTTP curl.haxx.se/libcurl, libcurl).
159 module std.net.curl;
161 public import etc.c.curl : CurlOption;
163 import etc.c.curl : CURLcode;
381 * import std.net.curl;
407 // Is true if the Conn type is a valid Curl Connection type.
424 * import std.net.curl;
480 * import std.net.curl;
557 * import std.net.curl;
627 * import std.net.curl;
728 * import std.net.curl;
787 * import std.net.curl;
856 * import std.net.curl;
900 * import std.net.curl;
941 * import std.net.curl;
1029 import etc.c.curl : CurlSeek, CurlSeekPos; in _basicHTTP()
1079 // As of curl 7.18.0, libcurl will not pass in _basicHTTP()
1289 * import std.net.curl, std.stdio;
1400 * import std.net.curl, std.stdio;
1488 curl protocols.
1637 * import std.net.curl, std.stdio;
1650 * import std.net.curl, std.stdio;
1764 * import std.net.curl, std.stdio;
1777 * import std.net.curl, std.stdio;
1866 Mixin template for all supported curl protocols. This is the commom
1874 import etc.c.curl : CurlReadFunc, RawCurlProxy = CurlProxy; in Protocol()
1888 The curl handle used by this connection. in Protocol()
1890 @property ref Curl handle() return in Protocol()
1892 return p.curl; in Protocol()
1900 return p.curl.stopped; in Protocol()
1906 p.curl.shutdown(); in Protocol()
1914 p.curl.set(CurlOption.verbose, on ? 1L : 0L); in Protocol()
1922 p.curl.set(CurlOption.low_speed_limit, 1); in Protocol()
1923 p.curl.set(CurlOption.low_speed_time, d.total!"seconds"); in Protocol()
1931 p.curl.set(CurlOption.timeout_ms, d.total!"msecs"); in Protocol()
1937 p.curl.set(CurlOption.connecttimeout_ms, d.total!"msecs"); in Protocol()
1943 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy) in Protocol()
1947 p.curl.set(CurlOption.proxy, host); in Protocol()
1951 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYPORT, _proxy_port) in Protocol()
1955 p.curl.set(CurlOption.proxyport, cast(long) port); in Protocol()
1962 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) in Protocol()
1966 p.curl.set(CurlOption.proxytype, cast(long) type); in Protocol()
1972 p.curl.set(CurlOption.dns_cache_timeout, d.total!"msecs"); in Protocol()
1988 p.curl.set(CurlOption.intrface, i); in Protocol()
2012 p.curl.set(CurlOption.localport, cast(long) port); in Protocol()
2023 p.curl.set(CurlOption.noproxy, hosts); in Protocol()
2035 p.curl.set(CurlOption.localportrange, cast(long) range); in Protocol()
2039 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTCPNODELAY, nodelay) in Protocol()
2043 p.curl.set(CurlOption.tcp_nodelay, cast(long) (on ? 1 : 0) ); in Protocol()
2047 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLVERIFYPEER, verifypeer) in Protocol()
2051 p.curl.set(CurlOption.ssl_verifypeer, on ? 1 : 0); in Protocol()
2055 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLVERIFYHOST, verifypeer) in Protocol()
2059 p.curl.set(CurlOption.ssl_verifyhost, on ? 2 : 0); in Protocol()
2083 p.curl.set(CurlOption.userpwd, format("%s:%s", username, password)); in Protocol()
2118 p.curl.set(CurlOption.proxyuserpwd, in Protocol()
2140 * import std.net.curl; in Protocol()
2157 p.curl.clear(CurlOption.postfields); // cannot specify data when using callback in Protocol()
2158 p.curl.onSend = callback; in Protocol()
2174 * import std.net.curl, std.stdio; in Protocol()
2186 p.curl.onReceive = callback; in Protocol()
2204 * import std.net.curl, std.stdio; in Protocol()
2218 p.curl.onProgress = callback; in Protocol()
2329 * import std.net.curl, std.stdio;
2344 * import std.net.curl, std.stdio;
2367 * import std.net.curl, std.stdio;
2392 import etc.c.curl : CurlAuth, CurlInfo, curl_slist, CURLVERSION_NOW, curl_off_t;
2394 /// Authentication method equal to $(REF CurlAuth, etc,c,curl)
2404 Curl.curl.slist_free_all(headersOut); in ~this()
2405 if (curl.handle !is null) // work around RefCounted/emplace bug in ~this()
2406 curl.shutdown(); in ~this()
2408 Curl curl; member
2473 curl.onReceiveHeader = dg; in onReceiveHeader()
2478 import etc.c.curl : CurlTimeCond;
2480 /// Parse status line, as received from / generated by cURL.
2506 // The HTTP2 protocol is binary; cURL generates this fake text header.
2511 /** Time condition enumeration as an alias of $(REF CurlTimeCond, etc,c,curl)
2546 newlist = Curl.curl.slist_append(newlist, cur.data); in dup()
2550 copy.p.curl.set(CurlOption.httpheader, copy.p.headersOut); in dup()
2551 copy.p.curl = p.curl.dup(); in dup()
2559 p.curl.initialize(); in initialize()
2588 p.curl.set(CurlOption.nobody, 1L);
2593 p.curl.set(CurlOption.httpget, 1L);
2597 p.curl.set(CurlOption.post, 1L);
2601 p.curl.set(CurlOption.upload, 1L);
2605 p.curl.set(CurlOption.customrequest, "DELETE");
2609 p.curl.set(CurlOption.customrequest, "OPTIONS");
2613 p.curl.set(CurlOption.customrequest, "TRACE");
2617 p.curl.set(CurlOption.customrequest, "CONNECT");
2621 p.curl.set(CurlOption.customrequest, "PATCH");
2626 scope (exit) p.curl.clear(opt);
2627 return p.curl.perform(throwOnError);
2637 p.curl.set(CurlOption.url, url); in url()
2643 p.curl.set(CurlOption.cainfo, caFile); in caInfo()
2650 static import etc.c.curl; in version()
2688 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy) in version()
2693 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYPORT, _proxy_port) in version()
2698 alias CurlProxy = etc.c.curl.CurlProxy; in version()
2701 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) in version()
2744 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTCPNODELAY, nodelay) in version()
2790 * import std.net.curl; in version()
2820 * import std.net.curl, std.stdio; in version()
2844 * import std.net.curl, std.stdio; in version()
2864 Curl.curl.slist_free_all(p.headersOut); in clearRequestHeaders()
2866 p.curl.clear(CurlOption.httpheader); in clearRequestHeaders()
2876 * import std.net.curl;
2891 p.headersOut = Curl.curl.slist_append(p.headersOut, in addRequestHeader()
2893 p.curl.set(CurlOption.httpheader, p.headersOut); in addRequestHeader()
2898 * It has the form "Phobos-std.net.curl/$(I PHOBOS_VERSION) (libcurl/$(I CURL_VERSION))"
2905 // http://curl.haxx.se/docs/versions.html in defaultUserAgent()
2906 enum fmt = "Phobos-std.net.curl/%d.%03d (libcurl/%d.%d.%d)"; in defaultUserAgent()
2914 auto curlVer = Curl.curl.version_info(CURLVERSION_NOW).version_num; in defaultUserAgent()
2930 p.curl.set(CurlOption.useragent, userAgent); in setUserAgent()
2934 * Get various timings defined in $(REF CurlInfo, etc, c, curl).
2935 * The value is usable only if the return value is equal to `etc.c.curl.CurlError.ok`.
2938 * timing = one of the timings defined in $(REF CurlInfo, etc, c, curl).
2940 * `etc.c.curl.CurlInfo.namelookup_time`,
2941 * `etc.c.curl.CurlInfo.connect_time`,
2942 * `etc.c.curl.CurlInfo.pretransfer_time`,
2943 * `etc.c.curl.CurlInfo.starttransfer_time`,
2944 * `etc.c.curl.CurlInfo.redirect_time`,
2945 * `etc.c.curl.CurlInfo.appconnect_time`,
2946 * `etc.c.curl.CurlInfo.total_time`.
2951 * should be used only if the return value is `etc.c.curl.CurlInfo.ok`.
2955 * import std.net.curl;
2956 * import etc.c.curl : CurlError, CurlInfo;
2970 return p.curl.getTiming(timing, val); in getTiming()
3005 p.curl.set(CurlOption.cookie, cookie); in setCookie()
3011 p.curl.set(CurlOption.cookiefile, path); in setCookieJar()
3013 p.curl.set(CurlOption.cookiejar, path); in setCookieJar()
3019 p.curl.set(CurlOption.cookielist, "FLUSH"); in flushCookieJar()
3025 p.curl.set(CurlOption.cookielist, "SESS"); in clearSessionCookies()
3031 p.curl.set(CurlOption.cookielist, "ALL"); in clearAllCookies()
3045 p.curl.set(CurlOption.timecondition, cond);
3046 p.curl.set(CurlOption.timevalue, timestamp.toUnixTime());
3057 * import std.net.curl, std.stdio;
3076 * import std.net.curl, std.stdio;
3098 * import std.net.curl;
3109 p.curl.clear(CurlOption.readfunction); in setPostData()
3111 p.curl.set(CurlOption.postfields, cast(void*) data.ptr); in setPostData()
3112 p.curl.set(CurlOption.postfieldsize, data.length); in setPostData()
3148 * import std.net.curl, std.stdio;
3206 p.curl.set(lenOpt, to!curl_off_t(len)); in contentLength()
3215 p.curl.set(CurlOption.httpauth, cast(long) authMethod); in authenticationMethod()
3227 p.curl.set(CurlOption.followlocation, 0); in maxRedirects()
3231 p.curl.set(CurlOption.followlocation, 1); in maxRedirects()
3232 p.curl.set(CurlOption.maxredirs, maxRedirs); in maxRedirects()
3288 import etc.c.curl;
3336 import etc.c.curl : CurlError, CurlInfo, curl_off_t, curl_slist;
3343 Curl.curl.slist_free_all(commands); in ~this()
3344 if (curl.handle !is null) // work around RefCounted/emplace bug in ~this()
3345 curl.shutdown(); in ~this()
3348 Curl curl; member
3379 copy.p.curl = p.curl.dup(); in dup()
3384 newlist = Curl.curl.slist_append(newlist, cur.data); in dup()
3388 copy.p.curl.set(CurlOption.postquote, copy.p.commands); in dup()
3395 p.curl.initialize(); in initialize()
3412 return p.curl.perform(throwOnError);
3423 p.curl.set(CurlOption.url, url); in url()
3430 static import etc.c.curl; in version()
3468 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy) in version()
3473 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYPORT, _proxy_port) in version()
3478 alias CurlProxy = etc.c.curl.CurlProxy; in version()
3481 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) in version()
3524 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTCPNODELAY, nodelay) in version()
3604 Curl.curl.slist_free_all(p.commands); in clearCommands()
3606 p.curl.clear(CurlOption.postquote); in clearCommands()
3616 * import std.net.curl;
3626 p.commands = Curl.curl.slist_append(p.commands, in addCommand()
3628 p.curl.set(CurlOption.postquote, p.commands); in addCommand()
3649 p.curl.set(CurlOption.infilesize_large, to!curl_off_t(len)); in contentLength()
3653 * Get various timings defined in $(REF CurlInfo, etc, c, curl).
3654 * The value is usable only if the return value is equal to `etc.c.curl.CurlError.ok`.
3657 * timing = one of the timings defined in $(REF CurlInfo, etc, c, curl).
3659 * `etc.c.curl.CurlInfo.namelookup_time`,
3660 * `etc.c.curl.CurlInfo.connect_time`,
3661 * `etc.c.curl.CurlInfo.pretransfer_time`,
3662 * `etc.c.curl.CurlInfo.starttransfer_time`,
3663 * `etc.c.curl.CurlInfo.redirect_time`,
3664 * `etc.c.curl.CurlInfo.appconnect_time`,
3665 * `etc.c.curl.CurlInfo.total_time`.
3670 * should be used only if the return value is `etc.c.curl.CurlInfo.ok`.
3674 * import std.net.curl;
3675 * import etc.c.curl : CurlError, CurlInfo;
3691 return p.curl.getTiming(timing, val); in getTiming()
3723 * import std.net.curl;
3740 import etc.c.curl : CurlUseSSL, curl_slist;
3746 if (curl.handle !is null) // work around RefCounted/emplace bug in ~this()
3747 curl.shutdown(); in ~this()
3749 Curl curl; member
3759 curl.onSend = delegate size_t(void[] data) in message()
3797 copy.p.curl = p.curl.dup();
3802 newlist = Curl.curl.slist_append(newlist, cur.data);
3806 copy.p.curl.set(CurlOption.postquote, copy.p.commands);
3819 return p.curl.perform(throwOnError);
3833 p.curl.set(CurlOption.use_ssl, CurlUseSSL.all); in url()
3840 p.curl.set(CurlOption.url, url); in url()
3845 p.curl.initialize(); in initialize()
3846 p.curl.set(CurlOption.upload, 1L); in initialize()
3856 static import etc.c.curl; in version()
3894 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy) in version()
3899 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYPORT, _proxy_port) in version()
3904 alias CurlProxy = etc.c.curl.CurlProxy; in version()
3907 * See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY, _proxy_type) in version()
3950 See: $(HTTP curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTCPNODELAY, nodelay) in version()
4029 p.curl.set(CurlOption.mail_from, sender); in mailFrom()
4043 Curl.curl.slist_append(recipients_list, in mailTo()
4046 p.curl.set(CurlOption.mail_rcpt, recipients_list); in mailTo()
4061 import std.net.curl;
4074 Exception thrown on errors in std.net.curl functions.
4096 Exception thrown on timeout errors in std.net.curl functions.
4144 /// Equal to $(REF CURLcode, etc,c,curl)
4152 import etc.c.curl : CurlGlobal;
4155 import etc.c.curl : curl_version_info, curl_version_info_data,
4156 CURL, CURLcode, CURLINFO, CURLoption, CURLversion, curl_slist;
4162 CURL* function() easy_init;
4163 CURLcode function(CURL *curl, CURLoption option,...) easy_setopt;
4164 CURLcode function(CURL *curl) easy_perform;
4165 CURLcode function(CURL *curl, CURLINFO info,...) easy_getinfo;
4166 CURL* function(CURL *curl) easy_duphandle;
4168 CURLcode function(CURL *handle, int bitmask) easy_pause;
4169 void function(CURL *curl) easy_cleanup;
4208 // try to load curl from the executable to allow static linking in loadAPI()
4228 static immutable names = ["libcurl.dll", "curl.dll"]; in loadAPI()
4239 … enforce!CurlException(handle !is null, "Failed to load curl, tried %(%s, %).".format(names)); in loadAPI()
4287 when passing Curl to other functions. Otherwise always allocate on
4290 struct Curl
4292 import etc.c.curl : CURL, CurlError, CurlPause, CurlSeek, CurlSeekPos,
4301 private static auto ref curl() @property { return CurlAPI.instance; } in curl() function
4304 private CURL* handle;
4319 Initialize the instance by creating a working curl handle.
4324 enforce!CurlException(!handle, "Curl instance already initialized"); in initialize()
4325 handle = curl.easy_init(); in initialize()
4326 enforce!CurlException(handle, "Curl instance couldn't be initialized"); in initialize()
4345 Curl dup() in dup()
4348 Curl copy; in dup()
4349 copy.handle = curl.easy_duphandle(handle); in dup()
4372 // Enable for curl version > 7.21.7 in dup()
4411 auto msgZ = curl.easy_strerror(code); in errorString()
4419 auto def = "Curl instance called after being cleaned up";
4425 Stop and invalidate this curl instance.
4432 curl.easy_cleanup(this.handle); in shutdown()
4442 _check(curl.easy_pause(this.handle, in pause()
4448 Set a string curl option.
4450 option = A $(REF CurlOption, etc,c,curl) as found in the curl documentation
4457 _check(curl.easy_setopt(this.handle, option, value.tempCString().buffPtr)); in set()
4461 Set a long curl option.
4463 option = A $(REF CurlOption, etc,c,curl) as found in the curl documentation
4469 _check(curl.easy_setopt(this.handle, option, value)); in set()
4473 Set a void* curl option.
4475 option = A $(REF CurlOption, etc,c,curl) as found in the curl documentation
4481 _check(curl.easy_setopt(this.handle, option, value)); in set()
4487 option = A $(REF CurlOption, etc,c,curl) as found in the curl documentation
4492 _check(curl.easy_setopt(this.handle, option, null)); in clear()
4499 option = A $(REF CurlOption, etc,c,curl) as found in the curl documentation
4504 auto rval = curl.easy_setopt(this.handle, option, null); in clearIfSupported()
4510 perform the curl request by doing the HTTP,FTP etc. as it has
4519 CurlCode code = curl.easy_perform(this.handle);
4529 `etc.c.curl.CurlError.ok`.
4534 code = curl.easy_getinfo(handle, timing, &val); in getTiming()
4554 * import std.net.curl, std.stdio;
4555 * Curl curl;
4556 * curl.initialize();
4557 * curl.set(CurlOption.url, "http://dlang.org");
4558 …* curl.onReceive = (ubyte[] data) { writeln("Got data", to!(const(char)[])(data)); return data.len…
4559 * curl.perform();
4566 throwOnStopped("Receive callback called on cleaned up Curl instance"); in onReceive()
4570 set(CurlOption.writefunction, cast(void*) &Curl._receiveCallback); in onReceive()
4585 * import std.net.curl, std.stdio;
4586 * Curl curl;
4587 * curl.initialize();
4588 * curl.set(CurlOption.url, "http://dlang.org");
4589 * curl.onReceiveHeader = (in char[] header) { writeln(header); };
4590 * curl.perform();
4598 "cleaned up Curl instance"); in onReceiveHeader()
4603 cast(void*) &Curl._receiveHeaderCallback); in onReceiveHeader()
4615 * The special value `Curl.abortRequest` can be returned in
4617 * The special value `Curl.pauseRequest` can be returned in order to
4622 * import std.net.curl;
4623 * Curl curl;
4624 * curl.initialize();
4625 * curl.set(CurlOption.url, "http://dlang.org");
4628 * curl.onSend = (void[] data)
4637 * curl.perform();
4644 throwOnStopped("Send callback called on cleaned up Curl instance"); in onSend()
4648 set(CurlOption.readfunction, cast(void*) &Curl._sendCallback); in onSend()
4652 * The event handler that gets called when the curl backend needs to seek
4657 * $(REF CurlSeekPos, etc,c,curl)
4661 * $(REF CurlSeek, etc,c,curl)
4665 * import std.net.curl;
4666 * Curl curl;
4667 * curl.initialize();
4668 * curl.set(CurlOption.url, "http://dlang.org");
4669 * curl.onSeek = (long p, CurlSeekPos sp)
4673 * curl.perform();
4680 throwOnStopped("Seek callback called on cleaned up Curl instance"); in onSeek()
4684 set(CurlOption.seekfunction, cast(void*) &Curl._seekCallback); in onSeek()
4694 * $(REF CurlSockType, etc,c,curl)
4698 * and make curl close the socket
4702 * import std.net.curl;
4703 * Curl curl;
4704 * curl.initialize();
4705 * curl.set(CurlOption.url, "http://dlang.org");
4706 * curl.onSocketOption = delegate int(curl_socket_t s, CurlSockType t) { /+ do stuff +/ };
4707 * curl.perform();
4716 "cleaned up Curl instance"); in onSocketOption()
4721 cast(void*) &Curl._socketOptionCallback); in onSocketOption()
4738 * import std.net.curl, std.stdio;
4739 * Curl curl;
4740 * curl.initialize();
4741 * curl.set(CurlOption.url, "http://dlang.org");
4742 * curl.onProgress = delegate int(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow)
4748 * curl.perform();
4759 "up Curl instance"); in onProgress()
4764 set(CurlOption.progressfunction, cast(void*) &Curl._progressCallback); in onProgress()
4772 auto b = cast(Curl*) ptr; in _receiveCallback()
4784 auto b = cast(Curl*) ptr; in _receiveHeaderCallback()
4795 Curl* b = cast(Curl*) ptr; in _sendCallback()
4805 auto b = cast(Curl*) ptr; in _seekCallback()
4818 auto b = cast(Curl*) ptr; in _socketOptionCallback()
4831 auto b = cast(Curl*) ptr; in _progressCallback()
5182 connDup.p.curl.handle = null; // make sure handle is not freed in _async()
5192 import etc.c.curl : CURL, CurlError; in _async()
5222 auto connDup = cast(CURL*) receiveOnly!ulong(); in _async()
5224 client.p.curl.handle = connDup; in _async()
5279 new CurlException(client.p.curl.errorString(code))); in _async()