• Home
  • Raw
  • Download

Lines Matching +full:basic +full:- +full:ftp

1 ---
3 SPDX-License-Identifier: curl
4 Title: libcurl-tutorial
7 See-also:
8 - libcurl-easy (3)
9 - libcurl-errors (3)
10 - libcurl-multi (3)
11 - libcurl-url (3)
13 - All
14 ---
18 libcurl-tutorial - libcurl programming tutorial
22 This document attempts to describe the general principles and some basic
46 installed them. The 'curl-config'[3] tool can be used to get this information:
48 $ curl-config --cflags
57 command line. To figure out which flags to use, once again the 'curl-config'
60 $ curl-config --libs
66 varies from different libraries and builds is the support for SSL-based
68 properly at build-time, libcurl is built with SSL support. To figure out if an
69 installed libcurl has been built with SSL support enabled, use *curl-config*
73 $ curl-config --feature
86 area. See docs/libcurl/libcurl.m4 file - it includes docs on how to use it.
122 which only does anything on libcurls compiled and built SSL-enabled. On these
143 It is considered best-practice to determine libcurl features at runtime rather
144 than at build-time (if possible of course). By calling
192 One of the most basic properties to set in the handle is the URL. You set your
228 rare platform-dependent nitpicks. Did you spot it? On some platforms[2],
238 CURLOPT_WRITEFUNCTION(3) if you set CURLOPT_WRITEDATA(3) - or experience
272 # Multi-threading Issues
275 libcurl-thread(3) for more information.
281 does, or the remote server might return non-standard replies that confuse the
287 protocol data as well (especially when using FTP). If you are using HTTP,
302 Getting some in-depth knowledge about the protocols involved is never wrong,
309 uploading to a remote FTP site is similar to uploading data to an HTTP server
366 them URL encoded, as %XX where XX is a two-digit hexadecimal number.
386 There is a long time Unix "standard" way of storing FTP usernames and
394 non-FTP protocols such as HTTP. To make curl use this file, use the
401 A basic example of how such a .netrc file may look like:
425 method is called 'Basic', which is sending the name and password in clear-text
426 in the HTTP request, base64-encoded. This is insecure.
428 At the time of this writing, libcurl can be built to use: Basic, Digest, NTLM,
446 claims to support. This method does however add a round-trip since libcurl
482 Content-Type: header of the post? Well, binary posts prevent libcurl from being
490 headers = curl_slist_append(headers, "Content-Type: text/xml");
507 POST operations are required, they do not do multi-part formposts. Multi-part
510 called multi-part because they are built by a chain of parts, each part being
512 fact create and post a multi-part formpost with the regular libcurl POST
517 functions: using those, you can create and fill a multi-part form. Function
518 curl_mime_init(3) creates a multi-part body; you can then append new parts
519 to a multi-part body using curl_mime_addpart(3).
522 curl_mime_data(3), file using curl_mime_filedata(3) and user-defined data
526 curl_mime_headers(3) allows defining the part's headers. When a multi-part
541 curl_mime_name(part, "logotype-image");
555 curl_mime_subparts(3) implements nested multi-parts, this way of
585 CURLFORM_COPYNAME, "logotype-image",
597 Multipart formposts are chains of parts using MIME-style separators and
599 that describe the individual content-type, size etc. To enable your
608 headers = curl_slist_append(headers, "Content-Type: text/xml");
611 CURLFORM_COPYNAME, "logotype-image",
635 Four rules have to be respected in building the multi-part:
637 - The easy handle must be created before building the multi-part.
639 - The multi-part is always created by a call to curl_mime_init(handle).
641 - Each part is created by a call to curl_mime_addpart(multipart).
643 - When complete, the multi-part must be bound to the easy handle using
664 the headers to be automatically released upon destroyed the multi-part, thus
665 saving a clean-up call to curl_slist_free_all(3).
669 CURLFORM_PTRNAME, "logotype-image",
670 CURLFORM_FILECONTENT, "-",
676 curl_mime_name(part, "logotype-image");
677 curl_mime_data_cb(part, (curl_off_t) -1, fread, fseek, NULL, stdin);
680 curl_mime_name(3) always copies the field name. The special filename "-" is
682 source using fread(). The transfer is be chunk-encoded since the data size is
766 For historical and traditional reasons, libcurl has a built-in progress meter
773 For most applications however, the built-in progress meter is useless and what
798 The callbacks CANNOT be non-static class member functions
814 What "proxy" means according to Merriam-Webster: "a person authorized to act
819 access to employees through their proxies. Network clients or user-agents ask
835 use the HTTP protocol. For example, you cannot invoke your own custom FTP
836 commands or even proper FTP directory listings.
842 curl_easy_setopt(handle, CURLOPT_PROXY, "proxy-host.com:8080");
866 named 'ftp_proxy' is checked for FTP URLs. Again, the proxies are always HTTP
882 variables, set the proxy name to "" - an empty string - with
887 SSL is for secure point-to-point connections. This involves strong encryption
910 This is however not the only time proxy-tunneling might offer benefits to
914 machine, it suddenly also re-introduces the ability to do non-HTTP
915 operations over an HTTP proxy. You can in fact use things such as FTP
916 upload or FTP custom commands this way.
930 ## Proxy Auto-Config
944 - Depending on the JavaScript complexity, write up a script that translates it
947 - Read the JavaScript code and rewrite the same logic in another language.
949 - Implement a JavaScript interpreter; people have successfully used the
952 - Ask your admins to stop this, for a static proxy setup or similar.
956 Re-cycling the same easy handle several times when doing multiple requests is
966 re-connection time.
968 FTP connections that are kept alive save a lot of time, as the command-
969 response round-trips are skipped, and also you do not risk getting blocked
970 without permission to login again like on many FTP servers only allowing N
1009 When doing POST requests, libcurl sets this header to "100-continue" to ask
1018 reliable protocol that is widely deployed and has excellent proxy-support.
1021 programming you may need to change the traditional HTTP (or FTP or...)
1043 HTTP-like protocols pass a series of headers to the server when doing the
1050 headers = curl_slist_append(headers, "Hey-server-hey: how are you?");
1051 headers = curl_slist_append(headers, "X-silly-content: yes");
1066 headers = curl_slist_append(headers, "Accept: Agent-007");
1083 ## Enforcing chunked transfer-encoding
1085 By making sure a request uses the custom header "Transfer-Encoding: chunked"
1086 when doing a non-GET HTTP operation, libcurl switches over to "chunked"
1095 getting 1.1-requests and when dealing with stubborn old things like that, you
1100 ## FTP Custom Commands
1102 Not all protocols are HTTP-like, and thus the above may not help you when
1103 you want to make, for example, your FTP transfers to behave differently.
1105 Sending custom commands to an FTP server means that you need to send the
1106 commands exactly as the FTP server expects them (RFC 959 is a good guide
1107 here), and you can only use commands that work on the control-connection
1109 data-connection must be left to libcurl's own judgment. Also be aware that
1118 headers = curl_slist_append(headers, "DELE file-to-remove");
1123 curl_easy_perform(handle); /* transfer ftp data! */
1133 The custom FTP commands are issued to the server in the same order they are
1142 are in "HTTP-style", looking like they do in HTTP.
1144 The option to enable headers or to run custom FTP commands may be useful to
1148 ## FTP Custom CURLOPT_CUSTOMREQUEST
1150 If you do want to list the contents of an FTP directory using your own defined
1151 FTP command, CURLOPT_CUSTOMREQUEST(3) does just that. "NLST" is the default
1163 In real-world cases, servers send new cookies to replace existing ones to
1166 Cookies are sent from server to clients with the header Set-Cookie: and
1203 file. We call that the cookie-jar. When you set a filename with
1209 # FTP Peculiarities We Need
1211 FTP transfers use a second TCP/IP connection for the data transfer. This is
1218 best for all the people behind firewalls, NATs or IP-masquerading setups.
1221 work it tries PASV instead. (EPSV is an extension to the original FTP spec
1222 and does not exist nor work on all FTP servers.)
1231 with the CURLOPT_FTPPORT(3) option. If you set it to "-", libcurl uses your
1242 In addition to support HTTP multi-part form fields, the MIME API can be used
1248 multi-part, for example to include another email message or to offer several
1251 To build such a message, you prepare the nth-level multi-part and then include
1252 it as a source to the parent multi-part using function
1254 bound to its parent multi-part, a nth-level multi-part belongs to it and
1257 Email messages data is not supposed to be non-ascii and line length is
1263 use this function (this would over-encode it), but explicitly set the
1295 "Content-Disposition: inline");
1318 Some protocols provide "headers", meta-data separated from the normal
1335 "Headers" for FTP transfers equal all the FTP server responses. They are not
1336 actually true headers, but in this case we pretend they are! ;-)
1351 multi-threaded programs, but the truth is almost the reverse. The multi
1352 interface allows a single-threaded application to perform the same kinds of
1353 multiple, simultaneous transfers that multi-threaded programs can perform. It
1354 allows many of the benefits of multi-threaded transfers without the complexity
1359 designed for using with select(). See the libcurl-multi.3 man page for details
1391 what it wants to do. Take note that libcurl does also feature some time-out
1422 share a lot of the data that otherwise would be kept on a per-easy handle
1429 easy handles by using the share interface, see libcurl-share(3).
1439 Transfer-Encoding in cases where HTTP uploads are done with data of an unknown
1450 The curl-config tool is generated at build-time (on Unix-like systems) and