blob: 9fae793e018279e91f9a861d7dfa06daec85f7bf [file] [log] [blame]
Daniel Stenbergeea22872004-03-16 07:56:51 +00001 _ _ ____ _
2 ___| | | | _ \| |
3 / __| | | | |_) | |
4 | (__| |_| | _ <| |___
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +00005 \___|\___/|_| \_\_____|
6
7FAQ
8
Daniel Stenbergc3318b42000-08-17 14:06:42 +00009 1. Philosophy
10 1.1 What is cURL?
11 1.2 What is libcurl?
Daniel Stenbergc3688002004-10-04 12:54:58 +000012 1.3 What is curl not?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000013 1.4 When will you make curl do XXXX ?
Daniel Stenbergc3688002004-10-04 12:54:58 +000014 1.5 Who makes curl?
15 1.6 What do you get for making curl?
Daniel Stenbergc528dc52001-08-07 11:17:37 +000016 1.7 What about CURL from curl.com?
Antoine Pietrib341b762022-01-27 02:12:50 +010017 1.8 I have a problem, who do I mail?
Daniel Stenberg9a44fa82005-11-02 09:34:53 +000018 1.9 Where do I buy commercial support for curl?
19 1.10 How many are using curl?
Daniel Stenberga28464a2021-10-31 16:34:44 +010020 1.11 Why do you not update ca-bundle.crt
Antoine Pietrib341b762022-01-27 02:12:50 +010021 1.12 I have a problem, who can I chat with?
Daniel Stenberg59842d42010-08-18 16:54:11 +020022 1.13 curl's ECCN number?
Daniel Stenberga5f96b42010-10-06 20:03:13 +020023 1.14 How do I submit my patch?
Daniel Stenbergf81d3562015-05-26 19:13:09 +020024 1.15 How do I port libcurl to my OS?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000025
Daniel Stenbergc3318b42000-08-17 14:06:42 +000026 2. Install Related Problems
Daniel Stenberg490879e2020-11-05 13:06:00 +010027 2.1 configure fails when using static libraries
Daniel Stenbergc3318b42000-08-17 14:06:42 +000028 2.2 Does curl work/build with other SSL libraries?
Daniel Stenberg1afc8a72023-09-29 09:36:59 +020029 2.3 How do I upgrade curl.exe in Windows?
Dan Fandrich5c9fff92009-01-30 18:28:29 +000030 2.4 Does curl support SOCKS (RFC 1928) ?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000031
Daniel Stenbergc3318b42000-08-17 14:06:42 +000032 3. Usage Problems
33 3.1 curl: (1) SSL is disabled, https: not supported
34 3.2 How do I tell curl to resume a transfer?
Daniel Stenberga28464a2021-10-31 16:34:44 +010035 3.3 Why does my posting using -F not work?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000036 3.4 How do I tell curl to run custom FTP commands?
Dan Fandrichb3740f02011-06-02 18:41:57 -070037 3.5 How can I disable the Accept: */* header?
Daniel Stenberg48bc73c2002-05-21 13:53:32 +000038 3.6 Does curl support ASP, XML, XHTML or HTML version Y?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000039 3.7 Can I use curl to delete/rename a file through FTP?
40 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenberg98871d12002-05-22 22:14:03 +000041 3.9 How do I use curl in my favorite programming language?
Daniel Stenberg147a6732001-03-08 09:25:09 +000042 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenberg88d14e92001-05-29 14:02:20 +000043 3.11 How do I POST with a different Content-Type?
dbrowndan84086b32019-05-23 15:05:29 -070044 3.12 Why do FTP-specific features over HTTP proxy fail?
45 3.13 Why do my single/double quotes fail?
Kushal Das94ac2ca2022-04-21 17:05:36 +020046 3.14 Does curl support JavaScript or PAC (automated proxy config)?
Daniel Stenbergf3e5d4a2003-12-22 17:24:21 +000047 3.15 Can I do recursive fetches with curl?
Daniel Stenbergedd16d92004-08-12 11:39:00 +000048 3.16 What certificates do I need when I use SSL?
Kushal Das94ac2ca2022-04-21 17:05:36 +020049 3.17 How do I list the root directory of an FTP server?
Daniel Stenberge9eb5232005-04-05 14:36:37 +000050 3.18 Can I use curl to send a POST/PUT and not wait for a response?
Daniel Stenberg64f12a32010-09-07 19:05:07 +020051 3.19 How do I get HTTP from a host using a specific IP address?
Daniel Stenberg3f7b7de2011-03-07 22:27:26 +010052 3.20 How to SFTP from my user's home directory?
Daniel Stenberg0d0f8082011-03-08 11:15:59 +010053 3.21 Protocol xxx not supported or disabled in libcurl
Daniel Stenberg0ed4a092013-01-21 14:33:12 +010054 3.22 curl -X gives me HTTP problems
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000055
Daniel Stenbergc3318b42000-08-17 14:06:42 +000056 4. Running Problems
Daniel Stenberge26ee092001-01-15 10:26:37 +000057 4.2 Why do I get problems when I use & or % in the URL?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000058 4.3 How can I use {, }, [ or ] to specify multiple URLs?
Daniel Stenberg816ac2a2024-07-01 10:37:43 +020059 4.4 Why do I get downloaded data even though the webpage does not exist?
Daniel Stenberg3a4182d2022-03-29 13:58:11 +020060 4.5 Why do I get return code XXX from an HTTP server?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000061 4.5.1 "400 Bad Request"
62 4.5.2 "401 Unauthorized"
63 4.5.3 "403 Forbidden"
64 4.5.4 "404 Not Found"
65 4.5.5 "405 Method Not Allowed"
Daniel Stenbergd60029d2001-12-19 23:25:04 +000066 4.5.6 "301 Moved Permanently"
Daniel Stenbergc3318b42000-08-17 14:06:42 +000067 4.6 Can you tell me what error code 142 means?
Daniel Stenberg816ac2a2024-07-01 10:37:43 +020068 4.7 How do I keep usernames and passwords secret in curl command lines?
Daniel Stenberge30b2062021-12-09 12:03:35 +010069 4.8 I found a bug
Daniel Gustafsson76523102022-05-20 13:40:12 +020070 4.9 curl cannot authenticate to a server that requires NTLM?
Daniel Stenberge30b2062021-12-09 12:03:35 +010071 4.10 My HTTP request using HEAD, PUT or DELETE does not work
dbrowndan84086b32019-05-23 15:05:29 -070072 4.11 Why do my HTTP range requests return the full document?
Daniel Stenberg16077112002-11-20 19:17:43 +000073 4.12 Why do I get "certificate verify failed" ?
Daniel Stenberg1dc0ce92005-06-13 18:33:40 +000074 4.13 Why is curl -R on Windows one hour off?
Daniel Stenberge30b2062021-12-09 12:03:35 +010075 4.14 Redirects work in browser but not with curl
Daniel Stenberga28464a2021-10-31 16:34:44 +010076 4.15 FTPS does not work
Daniel Stenberge30b2062021-12-09 12:03:35 +010077 4.16 My HTTP POST or PUT requests are slow
Daniel Stenberg2afb88e2009-02-23 21:21:00 +000078 4.17 Non-functional connect timeouts on Windows
Daniel Stenbergb8012ea2009-11-07 21:52:41 +000079 4.18 file:// URLs containing drive letters (Windows, NetWare)
Daniel Stenberga28464a2021-10-31 16:34:44 +010080 4.19 Why does not curl return an error when the network cable is unplugged?
Daniel Stenberge30b2062021-12-09 12:03:35 +010081 4.20 curl does not return error for HTTP non-200 responses
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000082
Daniel Stenbergc3318b42000-08-17 14:06:42 +000083 5. libcurl Issues
Daniel Stenberg7d09e512001-01-11 12:52:07 +000084 5.1 Is libcurl thread-safe?
Daniel Stenberga40b55d2000-11-22 07:27:26 +000085 5.2 How can I receive all data into a large memory chunk?
Daniel Stenberg2c100372000-12-19 07:30:51 +000086 5.3 How do I fetch multiple files with libcurl?
Viktor Szakatsf81f3512024-08-03 01:09:57 +020087 5.4 Does libcurl do Winsock initialization on Win32 systems?
88 5.5 Does CURLOPT_WRITEDATA and CURLOPT_READDATA work on Win32 ?
Daniel Stenberg4c485992001-04-22 15:45:27 +000089 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberge30b2062021-12-09 12:03:35 +010090 5.7 Link errors when building libcurl on Windows
Daniel Stenberg9754b202010-08-11 09:15:43 +020091 5.8 libcurl.so.X: open failed: No such file or directory
Daniel Stenberg816ac2a2024-07-01 10:37:43 +020092 5.9 How does libcurl resolve hostnames?
Daniel Stenberge9eb5232005-04-05 14:36:37 +000093 5.10 How do I prevent libcurl from writing the response to stdout?
Daniel Stenberg6e8e0412005-04-05 14:38:38 +000094 5.11 How do I make libcurl not receive the whole HTTP response?
Daniel Stenbergb5d50e92005-04-11 13:39:55 +000095 5.12 Can I make libcurl fake or hide my real IP address?
Daniel Stenberg24602ed2007-12-10 10:28:56 +000096 5.13 How do I stop an ongoing transfer?
Daniel Stenberg22059852008-09-24 07:39:42 +000097 5.14 Using C++ non-static functions for callbacks?
Yang Tsea07bc792010-02-14 19:40:18 +000098 5.15 How do I get an FTP directory listing?
Daniel Stenberge30b2062021-12-09 12:03:35 +010099 5.16 I want a different time-out
Daniel Stenbergdbf93a82013-01-03 10:15:02 +0100100 5.17 Can I write a server with libcurl?
Daniel Stenberg1495f422014-05-08 09:30:35 +0200101 5.18 Does libcurl use threads?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000102
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000103 6. License Issues
104 6.1 I have a GPL program, can I use the libcurl library?
105 6.2 I have a closed-source program, can I use the libcurl library?
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000106 6.3 I have a BSD licensed program, can I use the libcurl library?
107 6.4 I have a program that uses LGPL libraries, can I use libcurl?
108 6.5 Can I modify curl/libcurl for my program and keep the changes secret?
109 6.6 Can you please change the curl/libcurl license to XXXX?
Dan Fandrich5c9fff92009-01-30 18:28:29 +0000110 6.7 What are my obligations when using libcurl in my commercial apps?
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000111
Daniel Stenberg9ac76292004-08-18 11:18:36 +0000112 7. PHP/CURL Issues
113 7.1 What is PHP/CURL?
Daniel Stenberge38a7882011-03-17 11:30:29 +0100114 7.2 Who wrote PHP/CURL?
Daniel Stenberg9ac76292004-08-18 11:18:36 +0000115 7.3 Can I perform multiple requests using the same handle?
Daniel Stenberg6d496952017-05-12 19:58:06 +0200116 7.4 Does PHP/CURL have dependencies?
Daniel Stenberg9ac76292004-08-18 11:18:36 +0000117
Daniel Stenberg352b07f2021-09-13 17:21:38 +0200118 8. Development
119 8.1 Why does curl use C89?
120 8.2 Will curl be rewritten?
121
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000122==============================================================================
123
1241. Philosophy
125
126 1.1 What is cURL?
127
Daniel Stenbergc3688002004-10-04 12:54:58 +0000128 cURL is the name of the project. The name is a play on 'Client for URLs',
129 originally with URL spelled in uppercase to make it obvious it deals with
Daniel Stenberge28628f2021-12-08 10:12:19 +0100130 URLs. The fact it can also be read as 'see URL' also helped, it works as
Dan Fandrichec2ad572005-04-13 19:31:00 +0000131 an abbreviation for "Client URL Request Library" or why not the recursive
Daniel Stenberg490879e2020-11-05 13:06:00 +0100132 version: "curl URL Request Library".
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000133
Daniel Stenbergc3688002004-10-04 12:54:58 +0000134 The cURL project produces two products:
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000135
Daniel Stenbergc3688002004-10-04 12:54:58 +0000136 libcurl
137
Daniel Stenberge30b2062021-12-09 12:03:35 +0100138 A client-side URL transfer library, supporting DICT, FILE, FTP, FTPS,
139 GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S,
Daniel Stenberg6698e6c2022-09-09 15:11:13 +0200140 RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS
141 and WSS.
Daniel Stenbergac20f522010-08-18 19:43:06 +0200142
Daniel Stenberg7ac16812009-01-14 22:52:18 +0000143 libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading,
Michael Osipov37f0e8a2014-08-02 13:51:18 +0100144 Kerberos, SPNEGO, HTTP form based upload, proxies, cookies, user+password
Daniel Stenberge30b2062021-12-09 12:03:35 +0100145 authentication, file transfer resume, http proxy tunneling and more.
Daniel Stenbergc3688002004-10-04 12:54:58 +0000146
147 libcurl is highly portable, it builds and works identically on numerous
Michael Osipov37f0e8a2014-08-02 13:51:18 +0100148 platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HP-UX,
Daniel Stenberg90dd1fc2022-01-16 23:35:00 +0100149 IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, macOS,
150 Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS, Symbian, OSF, Android,
151 Minix, IBM TPF and more...
Daniel Stenbergc3688002004-10-04 12:54:58 +0000152
153 libcurl is free, thread-safe, IPv6 compatible, feature rich, well
154 supported and fast.
Gisle Vanem51a87fa2004-11-24 15:14:42 +0000155
Daniel Stenbergc3688002004-10-04 12:54:58 +0000156 curl
157
Daniel Stenberg7aa79dc2021-09-15 14:33:05 +0200158 A command line tool for getting or sending data using URL syntax.
Daniel Stenbergc3688002004-10-04 12:54:58 +0000159
Daniel Stenbergac20f522010-08-18 19:43:06 +0200160 Since curl uses libcurl, curl supports the same wide range of common
161 Internet protocols that libcurl does.
Daniel Stenbergc3688002004-10-04 12:54:58 +0000162
Daniel Stenberg17932a82014-09-19 10:01:45 +0200163 We pronounce curl with an initial k sound. It rhymes with words like girl
164 and earl. This is a short WAV file to help you:
165
Viktor Szakats13ef6232017-08-08 19:22:34 +0000166 https://media.merriam-webster.com/soundc11/c/curl0001.wav
Daniel Stenberg887e7282001-01-03 09:13:07 +0000167
Daniel Stenbergf83be112005-05-18 10:12:08 +0000168 There are numerous sub-projects and related projects that also use the word
169 curl in the project names in various combinations, but you should take
Daniel Stenberg073ef0b2003-05-09 07:07:13 +0000170 notice that this FAQ is directed at the command-line tool named curl (and
Daniel Stenbergeea22872004-03-16 07:56:51 +0000171 libcurl the library), and may therefore not be valid for other curl-related
Daniel Stenbergf83be112005-05-18 10:12:08 +0000172 projects. (There is however a small section for the PHP/CURL in this FAQ.)
Daniel Stenberg073ef0b2003-05-09 07:07:13 +0000173
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000174 1.2 What is libcurl?
175
Daniel Stenberg5ad23d52021-10-20 09:24:18 +0200176 libcurl is a reliable and portable library for doing Internet data transfers
177 using one or more of its supported Internet protocols.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000178
Daniel Stenberge30b2062021-12-09 12:03:35 +0100179 You can use libcurl freely in your application, be it open source,
Daniel Stenbergeea22872004-03-16 07:56:51 +0000180 commercial or closed-source.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000181
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000182 libcurl is most probably the most portable, most powerful and most often
183 used C-based multi-platform file transfer library on this planet - be it
184 open source or commercial.
185
Daniel Stenbergc3688002004-10-04 12:54:58 +0000186 1.3 What is curl not?
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000187
Daniel Stenberge30b2062021-12-09 12:03:35 +0100188 curl is not a wget clone. That is a common misconception. Never, during
Daniel Stenbergeea22872004-03-16 07:56:51 +0000189 curl's development, have we intended curl to replace wget or compete on its
Daniel Stenberg490879e2020-11-05 13:06:00 +0100190 market. curl is targeted at single-shot file transfers.
Daniel Stenbergeea22872004-03-16 07:56:51 +0000191
Daniel Stenberg490879e2020-11-05 13:06:00 +0100192 curl is not a website mirroring program. If you want to use curl to mirror
193 something: fine, go ahead and write a script that wraps around curl or use
194 libcurl to make it reality.
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000195
Daniel Stenberg490879e2020-11-05 13:06:00 +0100196 curl is not an FTP site mirroring program. Sure, get and send FTP with curl
Daniel Stenberg4c485992001-04-22 15:45:27 +0000197 but if you want systematic and sequential behavior you should write a
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000198 script (or write a new program that interfaces libcurl) and do it.
199
Daniel Stenberg490879e2020-11-05 13:06:00 +0100200 curl is not a PHP tool, even though it works perfectly well when used from
Daniel Stenbergc3688002004-10-04 12:54:58 +0000201 or with PHP (when using the PHP/CURL module).
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000202
Daniel Stenberg490879e2020-11-05 13:06:00 +0100203 curl is not a program for a single operating system. curl exists, compiles,
Daniel Stenberg890b34d2007-02-11 09:55:17 +0000204 builds and runs under a wide range of operating systems, including all
Daniel Stenberg90dd1fc2022-01-16 23:35:00 +0100205 modern Unixes (and a bunch of older ones too), Windows, Amiga, OS/2, macOS,
206 QNX etc.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000207
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000208 1.4 When will you make curl do XXXX ?
209
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000210 We love suggestions of what to change in order to make curl and libcurl
211 better. We do however believe in a few rules when it comes to the future of
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000212 curl:
213
Daniel Stenberg490879e2020-11-05 13:06:00 +0100214 curl -- the command line tool -- is to remain a non-graphical command line
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200215 tool. If you want GUIs or fancy scripting capabilities, you should look for
216 another tool that uses libcurl.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000217
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200218 We do not add things to curl that other small and available tools already do
Daniel Stenberg92efb3d2021-11-01 13:43:11 +0100219 well at the side. curl's output can be piped into another program or
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600220 redirected to another file for the next program to interpret.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000221
Viktor Szakats7e35eb72018-02-23 23:29:01 +0000222 We focus on protocol related issues and improvements. If you want to do more
Daniel Stenberg92efb3d2021-11-01 13:43:11 +0100223 magic with the supported protocols than curl currently does, chances are
224 good we will agree. If you want to add more protocols, we may agree.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000225
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600226 If you want someone else to do all the work while you wait for us to
Daniel Stenberg92efb3d2021-11-01 13:43:11 +0100227 implement it for you, that is not a friendly attitude. We spend a
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200228 considerable time already on maintaining and developing curl. In order to
229 get more out of us, you should consider trading in some of your time and
Kushal Das94ac2ca2022-04-21 17:05:36 +0200230 effort in return. Simply go to the GitHub repository which resides at
Viktor Szakats20dcd192016-02-03 18:34:16 +0100231 https://github.com/curl/curl, fork the project, and create pull requests
paulehoffman53d1e422016-01-24 14:27:08 -0800232 with your proposed changes.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000233
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600234 If you write the code, chances are better that it will get into curl faster.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000235
Daniel Stenbergc3688002004-10-04 12:54:58 +0000236 1.5 Who makes curl?
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000237
Daniel Stenbergf83be112005-05-18 10:12:08 +0000238 curl and libcurl are not made by any single individual. Daniel Stenberg is
239 project leader and main developer, but other persons' submissions are
Daniel Stenbergd16c7572002-08-08 11:54:11 +0000240 important and crucial. Anyone can contribute and post their changes and
241 improvements and have them inserted in the main sources (of course on the
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600242 condition that developers agree that the fixes are good).
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000243
Daniel Stenbergdb2d52a2007-12-10 11:33:46 +0000244 The full list of all contributors is found in the docs/THANKS file.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000245
246 curl is developed by a community, with Daniel at the wheel.
247
Daniel Stenbergc3688002004-10-04 12:54:58 +0000248 1.6 What do you get for making curl?
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000249
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200250 Project cURL is entirely free and open. We do this voluntarily, mostly in
Daniel Stenberge30b2062021-12-09 12:03:35 +0100251 our spare time. Companies may pay individual developers to work on curl.
252 This is not controlled by nor supervised in any way by the curl project.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000253
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200254 We get help from companies. Haxx provides website, bandwidth, mailing lists
255 etc, GitHub hosts the primary git repository and other services like the bug
256 tracker at https://github.com/curl/curl. Also again, some companies have
257 sponsored certain parts of the development in the past and I hope some will
258 continue to do so in the future.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000259
Daniel Stenbergf83be112005-05-18 10:12:08 +0000260 If you want to support our project, consider a donation or a banner-program
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600261 or even better: by helping us with coding, documenting or testing etc.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000262
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100263 See also: https://curl.se/sponsors.html
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200264
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000265 1.7 What about CURL from curl.com?
266
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600267 During the summer of 2001, curl.com was busy advertising their client-side
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000268 programming language for the web, named CURL.
269
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000270 We are in no way associated with curl.com or their CURL programming
Daniel Stenbergeea22872004-03-16 07:56:51 +0000271 language.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000272
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000273 Our project name curl has been in effective use since 1998. We were not the
Daniel Stenberg4045cd52001-08-07 21:21:24 +0000274 first computer related project to use the name "curl" and do not claim any
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200275 rights to the name.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000276
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000277 We recognize that we will be living in parallel with curl.com and wish them
278 every success.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000279
Antoine Pietrib341b762022-01-27 02:12:50 +0100280 1.8 I have a problem, who do I mail?
Daniel Stenberg8eaa7fe2002-04-27 18:12:26 +0000281
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +0000282 Please do not mail any single individual unless you really need to. Keep
283 curl-related questions on a suitable mailing list. All available mailing
284 lists are listed in the MANUAL document and online at
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100285 https://curl.se/mail/
Daniel Stenberg8eaa7fe2002-04-27 18:12:26 +0000286
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +0000287 Keeping curl-related questions and discussions on mailing lists allows
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600288 others to join in and help, to share their ideas, to contribute their
289 suggestions and to spread their wisdom. Keeping discussions on public mailing
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +0000290 lists also allows for others to learn from this (both current and future
291 users thanks to the web based archives of the mailing lists), thus saving us
292 from having to repeat ourselves even more. Thanks for respecting this.
Daniel Stenberg8eaa7fe2002-04-27 18:12:26 +0000293
Daniel Stenberg0b8f57b2005-08-07 14:36:55 +0000294 If you have found or simply suspect a security problem in curl or libcurl,
Daniel Stenbergab2f27c2021-09-09 14:46:38 +0200295 submit all the details at https://hackerone.one/curl. On there we keep the
296 issue private while we investigate, confirm it, work and validate a fix and
297 agree on a time schedule for publication etc. That way we produce a fix in a
298 timely manner before the flaw is announced to the world, reducing the impact
Antoine Pietrib341b762022-01-27 02:12:50 +0100299 the problem risks having on existing users.
Daniel Stenbergab2f27c2021-09-09 14:46:38 +0200300
301 Security issues can also be taking to the curl security team by emailing
302 security at curl.se (closed list of receivers, mails are not disclosed).
Daniel Stenberg0b8f57b2005-08-07 14:36:55 +0000303
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000304 1.9 Where do I buy commercial support for curl?
305
306 curl is fully open source. It means you can hire any skilled engineer to fix
307 your curl-related problems.
308
H3RSKO3d221402020-08-16 16:36:10 -0400309 We list available alternatives on the curl website:
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100310 https://curl.se/support.html
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000311
312 1.10 How many are using curl?
313
314 It is impossible to tell.
315
Daniel Stenberga28464a2021-10-31 16:34:44 +0100316 We do not know how many users that knowingly have installed and use curl.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000317
Daniel Stenberga28464a2021-10-31 16:34:44 +0100318 We do not know how many users that use curl without knowing that they are in
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000319 fact using it.
320
Daniel Stenberga28464a2021-10-31 16:34:44 +0100321 We do not know how many users that downloaded or installed curl and then
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000322 never use it.
323
Daniel Gustafssonafbf7d22020-11-05 09:36:24 +0100324 In 2020, we estimate that curl runs in roughly ten billion installations
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200325 world wide.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000326
Daniel Stenberga28464a2021-10-31 16:34:44 +0100327 1.11 Why do you not update ca-bundle.crt
Daniel Stenberg15bf1682008-02-07 15:43:36 +0000328
Daniel Stenberga28464a2021-10-31 16:34:44 +0100329 In the cURL project we have decided not to attempt to keep this file updated
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200330 (or even present) since deciding what to add to a ca cert bundle is an
Daniel Stenberga28464a2021-10-31 16:34:44 +0100331 undertaking we have not been ready to accept, and the one we can get from
Kushal Das94ac2ca2022-04-21 17:05:36 +0200332 Mozilla is perfectly fine so there is no need to duplicate that work.
Daniel Stenberg15bf1682008-02-07 15:43:36 +0000333
334 Today, with many services performed over HTTPS, every operating system
335 should come with a default ca cert bundle that can be deemed somewhat
336 trustworthy and that collection (if reasonably updated) should be deemed to
Daniel Stenberg074bd2a2008-02-18 11:39:11 +0000337 be a lot better than a private curl version.
Daniel Stenberg15bf1682008-02-07 15:43:36 +0000338
Daniel Stenberg074bd2a2008-02-18 11:39:11 +0000339 If you want the most recent collection of ca certs that Mozilla Firefox
340 uses, we recommend that you extract the collection yourself from Mozilla
341 Firefox (by running 'make ca-bundle), or by using our online service setup
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100342 for this purpose: https://curl.se/docs/caextract.html
Daniel Stenberg15bf1682008-02-07 15:43:36 +0000343
Antoine Pietrib341b762022-01-27 02:12:50 +0100344 1.12 I have a problem who, can I chat with?
Daniel Stenberg8740d142009-06-09 09:02:39 +0000345
Kushal Das94ac2ca2022-04-21 17:05:36 +0200346 There is a bunch of friendly people hanging out in the #curl channel on the
Daniel Stenberga28464a2021-10-31 16:34:44 +0100347 IRC network libera.chat. If you are polite and nice, chances are good that
Daniel Stenbergb03b82a2021-05-24 00:21:00 +0200348 you can get -- or provide -- help instantly.
Daniel Stenberg8740d142009-06-09 09:02:39 +0000349
Daniel Stenberg59842d42010-08-18 16:54:11 +0200350 1.13 curl's ECCN number?
351
352 The US government restricts exports of software that contains or uses
353 cryptography. When doing so, the Export Control Classification Number (ECCN)
354 is used to identify the level of export control etc.
355
Daniel Stenbergb8235962016-01-04 18:59:29 +0100356 Apache Software Foundation gives a good explanation of ECCNs at
357 https://www.apache.org/dev/crypto.html
Daniel Stenberg59842d42010-08-18 16:54:11 +0200358
359 We believe curl's number might be ECCN 5D002, another possibility is
Daniel Stenbergb8235962016-01-04 18:59:29 +0100360 5D992. It seems necessary to write them (the authority that administers ECCN
361 numbers), asking to confirm.
Daniel Stenberg59842d42010-08-18 16:54:11 +0200362
Daniel Stenbergb8235962016-01-04 18:59:29 +0100363 Comprehensible explanations of the meaning of such numbers and how to obtain
364 them (resp.) are here
Daniel Stenberg59842d42010-08-18 16:54:11 +0200365
Viktor Szakats13ef6232017-08-08 19:22:34 +0000366 https://www.bis.doc.gov/licensing/exportingbasics.htm
367 https://www.bis.doc.gov/licensing/do_i_needaneccn.html
Daniel Stenberg59842d42010-08-18 16:54:11 +0200368
369 An incomprehensible description of the two numbers above is here
Viktor Szakatsf0783612018-09-22 07:58:05 +0000370 https://www.bis.doc.gov/index.php/documents/new-encryption/1653-ccl5-pt2-3
Daniel Stenberg59842d42010-08-18 16:54:11 +0200371
Daniel Stenberga5f96b42010-10-06 20:03:13 +0200372 1.14 How do I submit my patch?
373
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200374 We strongly encourage you to submit changes and improvements directly as
Daniel Stenberga28464a2021-10-31 16:34:44 +0100375 "pull requests" on GitHub: https://github.com/curl/curl/pulls
Daniel Stenberga5f96b42010-10-06 20:03:13 +0200376
Daniel Stenberga28464a2021-10-31 16:34:44 +0100377 If you for any reason cannot or will not deal with GitHub, send your patch to
378 the curl-library mailing list. We are many subscribers there and there are
Daniel Stenbergd63b3902020-09-07 17:08:07 +0200379 lots of people who can review patches, comment on them and "receive" them
380 properly.
Daniel Stenberga5f96b42010-10-06 20:03:13 +0200381
Daniel Stenberg490879e2020-11-05 13:06:00 +0100382 Lots of more details are found in the CONTRIBUTE.md and INTERNALS.md
383 documents.
Daniel Stenberga5f96b42010-10-06 20:03:13 +0200384
Daniel Stenbergf81d3562015-05-26 19:13:09 +0200385 1.15 How do I port libcurl to my OS?
386
387 Here's a rough step-by-step:
388
389 1. copy a suitable lib/config-*.h file as a start to lib/config-[youros].h
390
391 2. edit lib/config-[youros].h to match your OS and setup
392
393 3. edit lib/curl_setup.h to include config-[youros].h when your OS is
394 detected by the preprocessor, in the style others already exist
395
396 4. compile lib/*.c and make them into a library
397
Daniel Stenberg8eaa7fe2002-04-27 18:12:26 +0000398
Daniel Stenbergc3318b42000-08-17 14:06:42 +00003992. Install Related Problems
400
Daniel Stenberg490879e2020-11-05 13:06:00 +0100401 2.1 configure fails when using static libraries
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000402
Daniel Stenberg490879e2020-11-05 13:06:00 +0100403 You may find that configure fails to properly detect the entire dependency
404 chain of libraries when you provide static versions of the libraries that
405 configure checks for.
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000406
Daniel Stenberg490879e2020-11-05 13:06:00 +0100407 The reason why static libraries is much harder to deal with is that for them
Daniel Stenberga28464a2021-10-31 16:34:44 +0100408 we do not get any help but the script itself must know or check what more
Daniel Stenberg490879e2020-11-05 13:06:00 +0100409 libraries that are needed (with shared libraries, that dependency "chain" is
RainRat10879372024-04-10 00:36:10 -0700410 handled automatically). This is an error-prone process and one that also
Daniel Stenberg490879e2020-11-05 13:06:00 +0100411 tends to vary over time depending on the release versions of the involved
412 components and may also differ between operating systems.
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000413
Daniel Stenberg92efb3d2021-11-01 13:43:11 +0100414 For that reason, configure does few attempts to actually figure this out and
415 you are instead encouraged to set LIBS and LDFLAGS accordingly when you
416 invoke configure, and point out the needed libraries and set the necessary
417 flags yourself.
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000418
Daniel Stenberg490879e2020-11-05 13:06:00 +0100419 2.2 Does curl work with other SSL libraries?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000420
Daniel Stenberg490879e2020-11-05 13:06:00 +0100421 curl has been written to use a generic SSL function layer internally, and
Daniel Stenberg045c7342013-01-23 13:17:36 +0100422 that SSL functionality can then be provided by one out of many different SSL
423 backends.
424
425 curl can be built to use one of the following SSL alternatives: OpenSSL,
Viktor Szakats63430342024-07-12 13:55:26 +0200426 LibreSSL, BoringSSL, AWS-LC, GnuTLS, wolfSSL, mbedTLS, Secure Transport
Viktor Szakatsf81f3512024-08-03 01:09:57 +0200427 (native iOS/macOS), Schannel (native Windows), BearSSL or Rustls. They all
Daniel Stenberg78d62322023-08-07 13:02:32 +0200428 have their pros and cons, and we try to maintain a comparison of them here:
429 https://curl.se/docs/ssl-compared.html
Daniel Stenberge9640b62000-08-02 07:17:56 +0000430
Daniel Stenberg1afc8a72023-09-29 09:36:59 +0200431 2.3 How do I upgrade curl.exe in Windows?
432
433 The curl tool that is shipped as an integrated component of Windows 10 and
434 Windows 11 is managed by Microsoft. If you were to delete the file or
435 replace it with a newer version downloaded from https://curl.se/windows,
436 then Windows Update will cease to work on your system.
437
438 There is no way to independently force an upgrade of the curl.exe that is
439 part of Windows other than through the regular Windows update process. There
440 is also nothing the curl project itself can do about this, since this is
441 managed and controlled entirely by Microsoft as owners of the operating
442 system.
443
444 You can always download and install the latest version of curl for Windows
445 from https://curl.se/windows into a separate location.
446
Dan Fandrich5c9fff92009-01-30 18:28:29 +0000447 2.4 Does curl support SOCKS (RFC 1928) ?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000448
Daniel Stenberg844cbc72007-07-29 22:17:39 +0000449 Yes, SOCKS 4 and 5 are supported.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000450
Daniel Stenbergc3318b42000-08-17 14:06:42 +00004513. Usage problems
Daniel Stenberge9640b62000-08-02 07:17:56 +0000452
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000453 3.1 curl: (1) SSL is disabled, https: not supported
Daniel Stenberge9640b62000-08-02 07:17:56 +0000454
Daniel Stenberg21498a12023-09-29 10:17:03 +0200455 If you get this output when trying to get anything from an HTTPS server, it
456 means that the instance of curl/libcurl that you are using was built without
457 support for this protocol.
Daniel Stenberg0d0f8082011-03-08 11:15:59 +0100458
Daniel Stenberga28464a2021-10-31 16:34:44 +0100459 This could have happened if the configure script that was run at build time
460 could not find all libs and include files curl requires for SSL to work. If
Daniel Stenberg0d0f8082011-03-08 11:15:59 +0100461 the configure script fails to find them, curl is simply built without SSL
462 support.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000463
Daniel Stenberg21498a12023-09-29 10:17:03 +0200464 To get HTTPS support into a curl that was previously built but that reports
465 that HTTPS is not supported, you should dig through the document and logs
466 and check out why the configure script does not find the SSL libs and/or
467 include files.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000468
Daniel Stenberga28464a2021-10-31 16:34:44 +0100469 Also, check out the other paragraph in this FAQ labeled "configure does not
Daniel Stenberge9640b62000-08-02 07:17:56 +0000470 find OpenSSL even when it is installed".
471
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000472 3.2 How do I tell curl to resume a transfer?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000473
Daniel Stenberg490879e2020-11-05 13:06:00 +0100474 curl supports resumed transfers both ways on both FTP and HTTP.
Daniel Stenberg887e7282001-01-03 09:13:07 +0000475 Try the -C option.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000476
Daniel Stenberga28464a2021-10-31 16:34:44 +0100477 3.3 Why does my posting using -F not work?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000478
Daniel Stenberga28464a2021-10-31 16:34:44 +0100479 You cannot arbitrarily use -F or -d, the choice between -F or -d depends on
Daniel Stenberg490879e2020-11-05 13:06:00 +0100480 the HTTP operation you need curl to do and what the web server that will
481 receive your post expects.
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600482
Daniel Stenberga28464a2021-10-31 16:34:44 +0100483 If the form you are trying to submit uses the type 'multipart/form-data',
Daniel Stenberg490879e2020-11-05 13:06:00 +0100484 then and only then you must use the -F type. In all the most common cases,
485 you should use -d which then causes a posting with the type
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600486 'application/x-www-form-urlencoded'.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000487
Daniel Stenberg4c485992001-04-22 15:45:27 +0000488 This is described in some detail in the MANUAL and TheArtOfHttpScripting
Daniel Stenberga28464a2021-10-31 16:34:44 +0100489 documents, and if you do not understand it the first time, read it again
Daniel Stenberg4c485992001-04-22 15:45:27 +0000490 before you post questions about this to the mailing list. Also, try reading
491 through the mailing list archives for old postings and questions regarding
492 this.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000493
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000494 3.4 How do I tell curl to run custom FTP commands?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000495
496 You can tell curl to perform optional commands both before and/or after a
497 file transfer. Study the -Q/--quote option.
498
Daniel Stenberga28464a2021-10-31 16:34:44 +0100499 Since curl is used for file transfers, you do not normally use curl to
Daniel Stenberg68e2c9a2012-11-25 19:44:49 +0100500 perform FTP commands without transferring anything. Therefore you must
501 always specify a URL to transfer to/from even when doing custom FTP
502 commands, or use -I which implies the "no body" option sent to libcurl.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000503
Dan Fandrichb3740f02011-06-02 18:41:57 -0700504 3.5 How can I disable the Accept: */* header?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000505
506 You can change all internally generated headers by adding a replacement with
507 the -H/--header option. By adding a header with empty contents you safely
Dan Fandrichb3740f02011-06-02 18:41:57 -0700508 disable that one. Use -H "Accept:" to disable that specific header.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000509
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000510 3.6 Does curl support ASP, XML, XHTML or HTML version Y?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000511
Daniel Stenberga28464a2021-10-31 16:34:44 +0100512 To curl, all contents are alike. It does not matter how the page was
Daniel Stenberg07f97802013-02-08 09:58:23 +0100513 generated. It may be ASP, PHP, Perl, shell-script, SSI or plain HTML
Kushal Das94ac2ca2022-04-21 17:05:36 +0200514 files. There is no difference to curl and it does not even know what kind of
Daniel Stenberg07f97802013-02-08 09:58:23 +0100515 language that generated the page.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000516
Kushal Das94ac2ca2022-04-21 17:05:36 +0200517 See also item 3.14 regarding JavaScript.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000518
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000519 3.7 Can I use curl to delete/rename a file through FTP?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000520
Daniel Stenberg4c485992001-04-22 15:45:27 +0000521 Yes. You specify custom FTP commands with -Q/--quote.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000522
523 One example would be to delete a file after you have downloaded it:
524
Daniel Stenberg21498a12023-09-29 10:17:03 +0200525 curl -O ftp://example.com/coolfile -Q '-DELE coolfile'
Daniel Stenberge9640b62000-08-02 07:17:56 +0000526
Daniel Stenberg33b9daa2007-06-26 21:53:46 +0000527 or rename a file after upload:
528
Daniel Stenberg21498a12023-09-29 10:17:03 +0200529 curl -T infile ftp://example.com/dir/ -Q "-RNFR infile" -Q "-RNTO newname"
Daniel Stenberg33b9daa2007-06-26 21:53:46 +0000530
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000531 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000532
Daniel Stenberg490879e2020-11-05 13:06:00 +0100533 curl does not follow so-called redirects by default. The Location: header
Daniel Stenberga28464a2021-10-31 16:34:44 +0100534 that informs the client about this is only interpreted if you are using the
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000535 -L/--location option. As in:
Daniel Stenberge9640b62000-08-02 07:17:56 +0000536
Daniel Stenberg21498a12023-09-29 10:17:03 +0200537 curl -L http://example.com
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000538
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000539 Not all redirects are HTTP ones, see 4.14
540
Daniel Stenberg98871d12002-05-22 22:14:03 +0000541 3.9 How do I use curl in my favorite programming language?
Daniel Stenberg368e3522001-01-29 10:16:21 +0000542
dbrowndan84086b32019-05-23 15:05:29 -0700543 Many programming languages have interfaces/bindings that allow you to use
544 curl without having to use the command line tool. If you are fluent in such
545 a language, you may prefer to use one of these interfaces instead.
Daniel Stenberg4c485992001-04-22 15:45:27 +0000546
Daniel Stenberg4c485992001-04-22 15:45:27 +0000547 Find out more about which languages that support curl directly, and how to
H3RSKO3d221402020-08-16 16:36:10 -0400548 install and use them, in the libcurl section of the curl website:
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100549 https://curl.se/libcurl/
Daniel Stenberg368e3522001-01-29 10:16:21 +0000550
Daniel Stenberg832e8272011-06-13 19:02:38 +0200551 All the various bindings to libcurl are made by other projects and people,
552 outside of the cURL project. The cURL project itself only produces libcurl
Daniel Stenberga28464a2021-10-31 16:34:44 +0100553 with its plain C API. If you do not find anywhere else to ask you can ask
Daniel Stenberg832e8272011-06-13 19:02:38 +0200554 about bindings on the curl-library list too, but be prepared that people on
555 that list may not know anything about bindings.
556
Daniel Stenberge30b2062021-12-09 12:03:35 +0100557 In December 2021, there were interfaces available for the following
Daniel Stenberg1640bb62019-02-28 09:09:51 +0100558 languages: Ada95, Basic, C, C++, Ch, Cocoa, D, Delphi, Dylan, Eiffel,
559 Euphoria, Falcon, Ferite, Gambas, glib/GTK+, Go, Guile, Harbour, Haskell,
560 Java, Julia, Lisp, Lua, Mono, .NET, node.js, Object-Pascal, OCaml, Pascal,
561 Perl, PHP, PostgreSQL, Python, R, Rexx, Ring, RPG, Ruby, Rust, Scheme,
562 Scilab, S-Lang, Smalltalk, SP-Forth, SPL, Tcl, Visual Basic, Visual FoxPro,
563 Q, wxwidgets, XBLite and Xoho. By the time you read this, additional ones
Daniel Stenberge30b2062021-12-09 12:03:35 +0100564 may have appeared.
Daniel Stenberg368e3522001-01-29 10:16:21 +0000565
Daniel Stenberg147a6732001-03-08 09:25:09 +0000566 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000567
Daniel Stenberg490879e2020-11-05 13:06:00 +0100568 curl adheres to the HTTP spec, which basically means you can play with *any*
Viktor Szakatsf81f3512024-08-03 01:09:57 +0200569 protocol that is built on top of HTTP. Protocols such as SOAP, WebDAV and
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000570 XML-RPC are all such ones. You can use -X to set custom requests and -H to
571 set custom headers (or replace internally generated ones).
572
Daniel Stenberga28464a2021-10-31 16:34:44 +0100573 Using libcurl is of course just as good and you would just use the proper
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +0000574 library options to do the same.
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000575
Daniel Stenberg88d14e92001-05-29 14:02:20 +0000576 3.11 How do I POST with a different Content-Type?
577
578 You can always replace the internally generated headers with -H/--header.
579 To make a simple HTTP POST with text/xml as content-type, do something like:
580
581 curl -d "datatopost" -H "Content-Type: text/xml" [URL]
582
dbrowndan84086b32019-05-23 15:05:29 -0700583 3.12 Why do FTP-specific features over HTTP proxy fail?
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000584
Daniel Stenberg3a4182d2022-03-29 13:58:11 +0200585 Because when you use an HTTP proxy, the protocol spoken on the network will
586 be HTTP, even if you specify an FTP URL. This effectively means that you
Daniel Stenberga28464a2021-10-31 16:34:44 +0100587 normally cannot use FTP-specific features such as FTP upload and FTP quote
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000588 etc.
589
590 There is one exception to this rule, and that is if you can "tunnel through"
Daniel Stenberg271f96f2001-11-20 08:03:01 +0000591 the given HTTP proxy. Proxy tunneling is enabled with a special option (-p)
Daniel Stenberg97a8c982001-12-21 08:10:34 +0000592 and is generally not available as proxy admins usually disable tunneling to
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600593 ports other than 443 (which is used for HTTPS access through proxies).
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000594
dbrowndan84086b32019-05-23 15:05:29 -0700595 3.13 Why do my single/double quotes fail?
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000596
597 To specify a command line option that includes spaces, you might need to
598 put the entire option within quotes. Like in:
599
Viktor Szakats1bc69df2023-09-29 15:42:39 +0000600 curl -d " with spaces " example.com
Daniel Stenbergeea22872004-03-16 07:56:51 +0000601
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000602 or perhaps
603
Viktor Szakats1bc69df2023-09-29 15:42:39 +0000604 curl -d ' with spaces ' example.com
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000605
606 Exactly what kind of quotes and how to do this is entirely up to the shell
Viktor Szakatsf81f3512024-08-03 01:09:57 +0200607 or command line interpreter that you are using. For most Unix shells, you
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000608 can more or less pick either single (') or double (") quotes. For
Jay Satiroa61eac62022-05-09 02:22:39 -0400609 Windows/DOS command prompts you must use double (") quotes, and if the
610 option string contains inner double quotes you can escape them with a
611 backslash.
612
613 For Windows powershell the arguments are not always passed on as expected
614 because curl is not a powershell script. You may or may not be able to use
615 single quotes. To escape inner double quotes seems to require a
616 backslash-backtick escape sequence and the outer quotes as double quotes.
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000617
Daniel Stenberg98871d12002-05-22 22:14:03 +0000618 Please study the documentation for your particular environment. Examples in
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600619 the curl docs will use a mix of both of these as shown above. You must
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000620 adjust them to work in your environment.
621
Daniel Stenberg61f62842002-03-11 08:39:00 +0000622 Remember that curl works and runs on more operating systems than most single
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000623 individuals have ever tried.
624
Kushal Das94ac2ca2022-04-21 17:05:36 +0200625 3.14 Does curl support JavaScript or PAC (automated proxy config)?
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000626
Daniel Stenberg816ac2a2024-07-01 10:37:43 +0200627 Many webpages do magic stuff using embedded JavaScript. curl and libcurl
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000628 have no built-in support for that, so it will be treated just like any other
629 contents.
630
Jan-Piet Mens09c80742022-01-30 12:57:24 +0100631 .pac files are a Netscape invention and are sometimes used by organizations
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000632 to allow them to differentiate which proxies to use. The .pac contents is
Kushal Das94ac2ca2022-04-21 17:05:36 +0200633 just a JavaScript program that gets invoked by the browser and that returns
634 the name of the proxy to connect to. Since curl does not support JavaScript,
Daniel Stenberga28464a2021-10-31 16:34:44 +0100635 it cannot support .pac proxy configuration either.
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000636
Kushal Das94ac2ca2022-04-21 17:05:36 +0200637 Some workarounds usually suggested to overcome this JavaScript dependency:
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000638
Kushal Das94ac2ca2022-04-21 17:05:36 +0200639 Depending on the JavaScript complexity, write up a script that translates it
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200640 to another language and execute that.
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000641
Kushal Das94ac2ca2022-04-21 17:05:36 +0200642 Read the JavaScript code and rewrite the same logic in another language.
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000643
Kushal Das94ac2ca2022-04-21 17:05:36 +0200644 Implement a JavaScript interpreter, people have successfully used the
645 Mozilla JavaScript engine in the past.
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000646
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200647 Ask your admins to stop this, for a static proxy setup or similar.
Daniel Stenberg48bc73c2002-05-21 13:53:32 +0000648
Daniel Stenbergf3e5d4a2003-12-22 17:24:21 +0000649 3.15 Can I do recursive fetches with curl?
650
651 No. curl itself has no code that performs recursive operations, such as
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000652 those performed by wget and similar tools.
Daniel Stenbergf3e5d4a2003-12-22 17:24:21 +0000653
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600654 There exists wrapper scripts with that functionality (for example the
Daniel Stenbergf3e5d4a2003-12-22 17:24:21 +0000655 curlmirror perl script), and you can write programs based on libcurl to do
656 it, but the command line tool curl itself cannot.
Daniel Stenberg6b1a1a62002-03-11 08:29:26 +0000657
Daniel Stenbergedd16d92004-08-12 11:39:00 +0000658 3.16 What certificates do I need when I use SSL?
Daniel Stenberg43563562004-08-12 11:02:01 +0000659
660 There are three different kinds of "certificates" to keep track of when we
661 talk about using SSL-based protocols (HTTPS or FTPS) using curl or libcurl.
662
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200663 CLIENT CERTIFICATE
Daniel Stenberg43563562004-08-12 11:02:01 +0000664
Daniel Stenberg6d496952017-05-12 19:58:06 +0200665 The server you communicate with may require that you can provide this in
Daniel Stenberge30b2062021-12-09 12:03:35 +0100666 order to prove that you actually are who you claim to be. If the server
Daniel Stenberga28464a2021-10-31 16:34:44 +0100667 does not require this, you do not need a client certificate.
Daniel Stenberg64f12a32010-09-07 19:05:07 +0200668
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200669 A client certificate is always used together with a private key, and the
670 private key has a pass phrase that protects it.
Daniel Stenberg43563562004-08-12 11:02:01 +0000671
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200672 SERVER CERTIFICATE
Daniel Stenberg43563562004-08-12 11:02:01 +0000673
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200674 The server you communicate with has a server certificate. You can and should
675 verify this certificate to make sure that you are truly talking to the real
676 server and not a server impersonating it.
677
678 CERTIFICATE AUTHORITY CERTIFICATE ("CA cert")
679
680 You often have several CA certs in a CA cert bundle that can be used to
681 verify a server certificate that was signed by one of the authorities in the
682 bundle. curl does not come with a CA cert bundle but most curl installs
683 provide one. You can also override the default.
684
685 The server certificate verification process is made by using a Certificate
686 Authority certificate ("CA cert") that was used to sign the server
687 certificate. Server certificate verification is enabled by default in curl
688 and libcurl and is often the reason for problems as explained in FAQ entry
689 4.12 and the SSLCERTS document
Daniel Stenberg4d2f8002020-11-04 14:02:01 +0100690 (https://curl.se/docs/sslcerts.html). Server certificates that are
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200691 "self-signed" or otherwise signed by a CA that you do not have a CA cert
692 for, cannot be verified. If the verification during a connect fails, you are
693 refused access. You then need to explicitly disable the verification to
694 connect to the server.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000695
Kushal Das94ac2ca2022-04-21 17:05:36 +0200696 3.17 How do I list the root directory of an FTP server?
Daniel Stenberg951fdeb2004-12-21 09:37:55 +0000697
698 There are two ways. The way defined in the RFC is to use an encoded slash
Kushal Das94ac2ca2022-04-21 17:05:36 +0200699 in the first path part. List the "/tmp" directory like this:
Daniel Stenberg951fdeb2004-12-21 09:37:55 +0000700
Daniel Stenberg21498a12023-09-29 10:17:03 +0200701 curl ftp://ftp.example.com/%2ftmp/
Daniel Stenberg951fdeb2004-12-21 09:37:55 +0000702
703 or the not-quite-kosher-but-more-readable way, by simply starting the path
704 section of the URL with a slash:
705
Daniel Stenberg21498a12023-09-29 10:17:03 +0200706 curl ftp://ftp.example.com//tmp/
Daniel Stenberg951fdeb2004-12-21 09:37:55 +0000707
Daniel Stenberge9eb5232005-04-05 14:36:37 +0000708 3.18 Can I use curl to send a POST/PUT and not wait for a response?
Yang Tsea07bc792010-02-14 19:40:18 +0000709
Daniel Stenberge9eb5232005-04-05 14:36:37 +0000710 No.
711
Daniel Stenberge30b2062021-12-09 12:03:35 +0100712 You can easily write your own program using libcurl to do such stunts.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +0000713
Daniel Stenberg64f12a32010-09-07 19:05:07 +0200714 3.19 How do I get HTTP from a host using a specific IP address?
715
Daniel Stenberga28464a2021-10-31 16:34:44 +0100716 For example, you may be trying out a website installation that is not yet in
Daniel Stenberg64f12a32010-09-07 19:05:07 +0200717 the DNS. Or you have a site using multiple IP addresses for a given host
718 name and you want to address a specific one out of the set.
719
720 Set a custom Host: header that identifies the server name you want to reach
721 but use the target IP address in the URL:
722
723 curl --header "Host: www.example.com" http://127.0.0.1/
724
Daniel Stenberg816ac2a2024-07-01 10:37:43 +0200725 You can also opt to add faked hostname entries to curl with the --resolve
Daniel Stenberg50d88bf2011-12-07 23:08:15 +0100726 option. That has the added benefit that things like redirects will also work
727 properly. The above operation would instead be done as:
728
729 curl --resolve www.example.com:80:127.0.0.1 http://www.example.com/
730
Daniel Stenberg3f7b7de2011-03-07 22:27:26 +0100731 3.20 How to SFTP from my user's home directory?
732
733 Contrary to how FTP works, SFTP and SCP URLs specify the exact directory to
Daniel Stenberga28464a2021-10-31 16:34:44 +0100734 work with. It means that if you do not specify that you want the user's home
Daniel Stenberg3f7b7de2011-03-07 22:27:26 +0100735 directory, you get the actual root directory.
736
737 To specify a file in your user's home directory, you need to use the correct
Daniel Stenberg1640bb62019-02-28 09:09:51 +0100738 URL syntax which for SFTP might look similar to:
Daniel Stenberg3f7b7de2011-03-07 22:27:26 +0100739
740 curl -O -u user:password sftp://example.com/~/file.txt
741
742 and for SCP it is just a different protocol prefix:
743
744 curl -O -u user:password scp://example.com/~/file.txt
745
Daniel Stenberg0d0f8082011-03-08 11:15:59 +0100746 3.21 Protocol xxx not supported or disabled in libcurl
747
748 When passing on a URL to curl to use, it may respond that the particular
749 protocol is not supported or disabled. The particular way this error message
Daniel Stenberga28464a2021-10-31 16:34:44 +0100750 is phrased is because curl does not make a distinction internally of whether
Dan Fandrich31c6e7a2013-04-15 22:26:18 +0200751 a particular protocol is not supported (i.e. never got any code added that
Daniel Stenberg0d0f8082011-03-08 11:15:59 +0100752 knows how to speak that protocol) or if it was explicitly disabled. curl can
753 be built to only support a given set of protocols, and the rest would then
754 be disabled or not supported.
755
756 Note that this error will also occur if you pass a wrongly spelled protocol
757 part as in "htpt://example.com" or as in the less evident case if you prefix
758 the protocol part with a space as in " http://example.com/".
759
Daniel Stenberg0ed4a092013-01-21 14:33:12 +0100760 3.22 curl -X gives me HTTP problems
761
762 In normal circumstances, -X should hardly ever be used.
763
764 By default you use curl without explicitly saying which request method to
Daniel Stenberg3a4182d2022-03-29 13:58:11 +0200765 use when the URL identifies an HTTP transfer. If you just pass in a URL like
Daniel Stenberg0ed4a092013-01-21 14:33:12 +0100766 "curl http://example.com" it will use GET. If you use -d or -F curl will use
767 POST, -I will cause a HEAD and -T will make it a PUT.
768
Daniel Stenberga28464a2021-10-31 16:34:44 +0100769 If for whatever reason you are not happy with these default choices that curl
Daniel Stenberg0ed4a092013-01-21 14:33:12 +0100770 does for you, you can override those request methods by specifying -X
771 [WHATEVER]. This way you can for example send a DELETE by doing "curl -X
772 DELETE [URL]".
773
Daniel Stenberg816ac2a2024-07-01 10:37:43 +0200774 It is thus pointless to do "curl -XGET [URL]" as GET would be used anyway.
775 In the same vein it is pointless to do "curl -X POST -d data [URL]". You can
776 make a fun and somewhat rare request that sends a request-body in a GET
777 request with something like "curl -X GET -d data [URL]"
Daniel Stenberg0ed4a092013-01-21 14:33:12 +0100778
Daniel Stenberga28464a2021-10-31 16:34:44 +0100779 Note that -X does not actually change curl's behavior as it only modifies the
Daniel Stenberg7b534842015-02-02 15:38:29 +0100780 actual string sent in the request, but that may of course trigger a
781 different set of events.
Daniel Stenberg0ed4a092013-01-21 14:33:12 +0100782
783 Accordingly, by using -XPOST on a command line that for example would follow
784 a 303 redirect, you will effectively prevent curl from behaving
785 correctly. Be aware.
786
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000787
Daniel Stenbergc3318b42000-08-17 14:06:42 +00007884. Running Problems
789
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000790 4.2 Why do I get problems when I use & or % in the URL?
Daniel Stenberg29470102000-06-02 13:32:01 +0000791
Kushal Das94ac2ca2022-04-21 17:05:36 +0200792 In general Unix shells, the & symbol is treated specially and when used, it
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000793 runs the specified command in the background. To safely send the & as a part
Daniel Stenberg4c485992001-04-22 15:45:27 +0000794 of a URL, you should quote the entire URL by using single (') or double (")
Dan Fandrich5c9fff92009-01-30 18:28:29 +0000795 quotes around it. Similar problems can also occur on some shells with other
Daniel Stenberge30b2062021-12-09 12:03:35 +0100796 characters, including ?*!$~(){}<>\|;`. When in doubt, quote the URL.
Daniel Stenberg29470102000-06-02 13:32:01 +0000797
Daniel Stenberg07d46882009-02-13 09:12:52 +0000798 An example that would invoke a remote CGI that uses &-symbols could be:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000799
Daniel Stenberg21498a12023-09-29 10:17:03 +0200800 curl 'http://www.example.com/cgi-bin/query?text=yes&q=curl'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000801
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200802 In Windows, the standard DOS shell treats the percent sign specially and you
803 need to use TWO percent signs for each single one you want to use in the
804 URL.
Daniel Stenberge26ee092001-01-15 10:26:37 +0000805
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200806 If you want a literal percent sign to be part of the data you pass in a POST
807 using -d/--data you must encode it as '%25' (which then also needs the
808 percent sign doubled on Windows machines).
Daniel Stenberg1b77c182001-01-29 10:24:51 +0000809
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000810 4.3 How can I use {, }, [ or ] to specify multiple URLs?
Daniel Stenberg29470102000-06-02 13:32:01 +0000811
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600812 Because those letters have a special meaning to the shell, to be used in
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000813 a URL specified to curl you must quote them.
Daniel Stenberg29470102000-06-02 13:32:01 +0000814
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600815 An example that downloads two URLs (sequentially) would be:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000816
Daniel Stenbergedcd5df2000-06-06 14:13:36 +0000817 curl '{curl,www}.haxx.se'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000818
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600819 To be able to use those characters as actual parts of the URL (without using
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +0000820 them for the curl URL "globbing" system), use the -g/--globoff option:
Daniel Stenberge26ee092001-01-15 10:26:37 +0000821
Viktor Szakats1bc69df2023-09-29 15:42:39 +0000822 curl -g 'www.example.com/weirdname[].html'
Daniel Stenberge26ee092001-01-15 10:26:37 +0000823
Daniel Stenberg816ac2a2024-07-01 10:37:43 +0200824 4.4 Why do I get downloaded data even though the webpage does not exist?
Daniel Stenberg29470102000-06-02 13:32:01 +0000825
Daniel Stenberga28464a2021-10-31 16:34:44 +0100826 curl asks remote servers for the page you specify. If the page does not exist
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000827 at the server, the HTTP protocol defines how the server should respond and
Daniel Stenberga28464a2021-10-31 16:34:44 +0100828 that means that headers and a "page" will be returned. That is simply how
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000829 HTTP works.
Daniel Stenberg29470102000-06-02 13:32:01 +0000830
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000831 By using the --fail option you can tell curl explicitly to not get any data
Daniel Stenberga28464a2021-10-31 16:34:44 +0100832 if the HTTP return code does not say success.
Daniel Stenberg8f037322000-06-06 14:09:01 +0000833
Daniel Stenberg3a4182d2022-03-29 13:58:11 +0200834 4.5 Why do I get return code XXX from an HTTP server?
Daniel Stenberg29470102000-06-02 13:32:01 +0000835
Daniel Stenberg22c92a62023-06-25 10:50:17 +0200836 RFC 2616 clearly explains the return codes. This is a short transcript. Go
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000837 read the RFC for exact details:
Daniel Stenberg29470102000-06-02 13:32:01 +0000838
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000839 4.5.1 "400 Bad Request"
Daniel Stenberg29470102000-06-02 13:32:01 +0000840
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000841 The request could not be understood by the server due to malformed
842 syntax. The client SHOULD NOT repeat the request without modifications.
843
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000844 4.5.2 "401 Unauthorized"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000845
846 The request requires user authentication.
847
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000848 4.5.3 "403 Forbidden"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000849
Viktor Szakatsff9d7f42018-10-08 19:37:40 +0000850 The server understood the request, but is refusing to fulfill it.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000851 Authorization will not help and the request SHOULD NOT be repeated.
852
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000853 4.5.4 "404 Not Found"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000854
855 The server has not found anything matching the Request-URI. No indication
Antoine Pietrib341b762022-01-27 02:12:50 +0100856 is given as to whether the condition is temporary or permanent.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000857
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000858 4.5.5 "405 Method Not Allowed"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000859
860 The method specified in the Request-Line is not allowed for the resource
861 identified by the Request-URI. The response MUST include an Allow header
862 containing a list of valid methods for the requested resource.
863
Daniel Stenbergd60029d2001-12-19 23:25:04 +0000864 4.5.6 "301 Moved Permanently"
Daniel Stenbergeea22872004-03-16 07:56:51 +0000865
Daniel Stenberg98871d12002-05-22 22:14:03 +0000866 If you get this return code and an HTML output similar to this:
Daniel Stenbergd60029d2001-12-19 23:25:04 +0000867
868 <H1>Moved Permanently</H1> The document has moved <A
869 HREF="http://same_url_now_with_a_trailing_slash/">here</A>.
870
dbrowndan84086b32019-05-23 15:05:29 -0700871 it might be because you requested a directory URL but without the trailing
Daniel Stenbergd60029d2001-12-19 23:25:04 +0000872 slash. Try the same operation again _with_ the trailing URL, or use the
873 -L/--location option to follow the redirection.
874
Daniel Stenberg811edcd2004-08-10 08:41:41 +0000875 4.6 Can you tell me what error code 142 means?
Daniel Stenberg29470102000-06-02 13:32:01 +0000876
Daniel Stenberg8b5f0ab2004-12-21 21:35:00 +0000877 All curl error codes are described at the end of the man page, in the
878 section called "EXIT CODES".
879
880 Error codes that are larger than the highest documented error code means
Daniel Stenberg13bf9642001-08-23 11:11:13 +0000881 that curl has exited due to a crash. This is a serious error, and we
Daniel Stenberg25fe47f2001-11-14 20:13:38 +0000882 appreciate a detailed bug report from you that describes how we could go
Daniel Stenberge30b2062021-12-09 12:03:35 +0100883 ahead and repeat this.
Daniel Stenberg29470102000-06-02 13:32:01 +0000884
Daniel Stenberg816ac2a2024-07-01 10:37:43 +0200885 4.7 How do I keep usernames and passwords secret in curl command lines?
Daniel Stenberg29470102000-06-02 13:32:01 +0000886
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000887 This problem has two sides:
Daniel Stenberg29470102000-06-02 13:32:01 +0000888
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000889 The first part is to avoid having clear-text passwords in the command line
Daniel Stenberga28464a2021-10-31 16:34:44 +0100890 so that they do not appear in 'ps' outputs and similar. That is easily
Daniel Stenbergeea22872004-03-16 07:56:51 +0000891 avoided by using the "-K" option to tell curl to read parameters from a file
892 or stdin to which you can pass the secret info. curl itself will also
893 attempt to "hide" the given password by blanking out the option - this
Daniel Stenberga28464a2021-10-31 16:34:44 +0100894 does not work on all platforms.
Daniel Stenberg29470102000-06-02 13:32:01 +0000895
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000896 To keep the passwords in your account secret from the rest of the world is
897 not a task that curl addresses. You could of course encrypt them somehow to
898 at least hide them from being read by human eyes, but that is not what
899 anyone would call security.
Daniel Stenberg29470102000-06-02 13:32:01 +0000900
Daniel Stenbergeea22872004-03-16 07:56:51 +0000901 Also note that regular HTTP (using Basic authentication) and FTP passwords
dbrowndan84086b32019-05-23 15:05:29 -0700902 are sent as cleartext across the network. All it takes for anyone to fetch
Daniel Stenberg92efb3d2021-11-01 13:43:11 +0100903 them is to listen on the network. Eavesdropping is easy. Use more secure
Daniel Stenbergeea22872004-03-16 07:56:51 +0000904 authentication methods (like Digest, Negotiate or even NTLM) or consider the
905 SSL-based alternatives HTTPS and FTPS.
Daniel Stenberg887e7282001-01-03 09:13:07 +0000906
Daniel Stenberge30b2062021-12-09 12:03:35 +0100907 4.8 I found a bug
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000908
Daniel Stenberg4c485992001-04-22 15:45:27 +0000909 It is not a bug if the behavior is documented. Read the docs first.
Daniel Stenberge30b2062021-12-09 12:03:35 +0100910 Especially check out the KNOWN_BUGS file, it may be a documented bug.
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000911
Daniel Stenberga28464a2021-10-31 16:34:44 +0100912 If it is a problem with a binary you have downloaded or a package for your
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000913 particular platform, try contacting the person who built the package/archive
914 you have.
915
Daniel Stenberg8eaa7fe2002-04-27 18:12:26 +0000916 If there is a bug, read the BUGS document first. Then report it as described
917 in there.
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000918
Daniel Gustafsson76523102022-05-20 13:40:12 +0200919 4.9 curl cannot authenticate to a server that requires NTLM?
Daniel Stenberg2c100372000-12-19 07:30:51 +0000920
Daniel Stenberg7c8bae02023-07-29 23:44:28 +0200921 NTLM support requires OpenSSL, GnuTLS, mbedTLS, Secure Transport, or
Bill Nagel497e7c92016-07-07 08:40:45 -0700922 Microsoft Windows libraries at build-time to provide this functionality.
Daniel Stenberg3a552b12003-06-26 11:35:48 +0000923
Daniel Stenberge30b2062021-12-09 12:03:35 +0100924 4.10 My HTTP request using HEAD, PUT or DELETE does not work
Daniel Stenbergbc743752002-05-15 21:40:29 +0000925
926 Many web servers allow or demand that the administrator configures the
927 server properly for these requests to work on the web server.
928
929 Some servers seem to support HEAD only on certain kinds of URLs.
930
931 To fully grasp this, try the documentation for the particular server
Daniel Stenberga28464a2021-10-31 16:34:44 +0100932 software you are trying to interact with. This is not anything curl can do
Daniel Stenbergbc743752002-05-15 21:40:29 +0000933 anything about.
934
dbrowndan84086b32019-05-23 15:05:29 -0700935 4.11 Why do my HTTP range requests return the full document?
Daniel Stenberg522b85a2002-11-12 20:00:02 +0000936
937 Because the range may not be supported by the server, or the server may
938 choose to ignore it and return the full document anyway.
Daniel Stenbergbc743752002-05-15 21:40:29 +0000939
Daniel Stenberg16077112002-11-20 19:17:43 +0000940 4.12 Why do I get "certificate verify failed" ?
941
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100942 When you invoke curl and get an error 60 error back it means that curl
Daniel Stenberga28464a2021-10-31 16:34:44 +0100943 could not verify that the server's certificate was good. curl verifies the
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100944 certificate using the CA cert bundle and verifying for which names the
Dan Fandrich2a264d42020-12-12 09:59:10 -0800945 certificate has been granted.
Daniel Stenberg16077112002-11-20 19:17:43 +0000946
Dan Fandrich2a264d42020-12-12 09:59:10 -0800947 To completely disable the certificate verification, use -k. This does
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100948 however enable man-in-the-middle attacks and makes the transfer INSECURE.
Antoine Pietrib341b762022-01-27 02:12:50 +0100949 We strongly advise against doing this for more than experiments.
Daniel Stenberg16077112002-11-20 19:17:43 +0000950
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100951 If you get this failure with a CA cert bundle installed and used, the
Bruno Baguette0d380a82021-11-26 08:23:34 +0100952 server's certificate might not be signed by one of the CA's in your CA
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100953 store. It might for example be self-signed. You then correct this problem by
954 obtaining a valid CA cert for the server. Or again, decrease the security by
955 disabling this check.
Daniel Stenberg16077112002-11-20 19:17:43 +0000956
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100957 At times, you find that the verification works in your favorite browser but
958 fails in curl. When this happens, the reason is usually that the server
959 sends an incomplete cert chain. The server is mandated to send all
Daniel Stenberga28464a2021-10-31 16:34:44 +0100960 "intermediate certificates" but does not. This typically works with browsers
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100961 anyway since they A) cache such certs and B) supports AIA which downloads
962 such missing certificates on demand. This is a server misconfiguration. A
963 good way to figure out if this is the case it to use the SSL Labs server
964 test and check the certificate chain: https://www.ssllabs.com/ssltest/
Daniel Stenberg16077112002-11-20 19:17:43 +0000965
Daniel Stenberg3864ad32020-11-06 09:16:06 +0100966 Details are also in the SSLCERTS.md document, found online here:
967 https://curl.se/docs/sslcerts.html
Daniel Stenberg16077112002-11-20 19:17:43 +0000968
Daniel Stenberg1dc0ce92005-06-13 18:33:40 +0000969 4.13 Why is curl -R on Windows one hour off?
970
Jay Satiroee3c83f2016-11-11 02:48:52 -0500971 Since curl 7.53.0 this issue should be fixed as long as curl was built with
972 any modern compiler that allows for a 64-bit curl_off_t type. For older
973 compilers or prior curl versions it may set a time that appears one hour off.
974 This happens due to a flaw in how Windows stores and uses file modification
975 times and it is not easily worked around. For more details read this:
Viktor Szakats62a71af2018-03-12 18:17:05 +0000976 https://www.codeproject.com/Articles/1144/Beating-the-Daylight-Savings-Time-bug-and-getting
Daniel Stenberg1dc0ce92005-06-13 18:33:40 +0000977
Daniel Stenberge30b2062021-12-09 12:03:35 +0100978 4.14 Redirects work in browser but not with curl
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000979
railsnewbie257cd6b99e2017-01-11 23:48:22 -0600980 curl supports HTTP redirects well (see item 3.8). Browsers generally support
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200981 at least two other ways to perform redirects that curl does not:
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000982
Daniel Stenberg3a4182d2022-03-29 13:58:11 +0200983 Meta tags. You can write an HTML tag that will cause the browser to redirect
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200984 to another given URL after a certain time.
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000985
Kushal Das94ac2ca2022-04-21 17:05:36 +0200986 JavaScript. You can write a JavaScript program embedded in an HTML page that
Daniel Stenberg1a911f72013-08-24 17:13:46 +0200987 redirects the browser to another given URL.
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000988
989 There is no way to make curl follow these redirects. You must either
dbrowndan84086b32019-05-23 15:05:29 -0700990 manually figure out what the page is set to do, or write a script that parses
991 the results and fetches the new URL.
Daniel Stenberg09cb9c72005-08-26 13:22:39 +0000992
Daniel Stenberga28464a2021-10-31 16:34:44 +0100993 4.15 FTPS does not work
Daniel Stenberg844cbc72007-07-29 22:17:39 +0000994
995 curl supports FTPS (sometimes known as FTP-SSL) both implicit and explicit
996 mode.
997
998 When a URL is used that starts with FTPS://, curl assumes implicit SSL on
999 the control connection and will therefore immediately connect and try to
1000 speak SSL. FTPS:// connections default to port 990.
1001
Daniel Stenbergfa1a8e02024-11-28 21:24:11 +07001002 To use explicit FTPS, you use an FTP:// URL and the --ssl-reqd option (or one
Daniel Stenberg1640bb62019-02-28 09:09:51 +01001003 of its related flavors). This is the most common method, and the one
Daniel Stenberg22c92a62023-06-25 10:50:17 +02001004 mandated by RFC 4217. This kind of connection will then of course use the
Daniel Stenberg844cbc72007-07-29 22:17:39 +00001005 standard FTP port 21 by default.
1006
Daniel Stenberge30b2062021-12-09 12:03:35 +01001007 4.16 My HTTP POST or PUT requests are slow
Daniel Stenberg95df5d02008-09-24 07:50:46 +00001008
Dan Fandrichee521a12023-03-10 13:15:43 -08001009 libcurl makes all POST and PUT requests (except for requests with a small
1010 request body) use the "Expect: 100-continue" header. This header allows the
1011 server to deny the operation early so that libcurl can bail out before having
1012 to send any data. This is useful in authentication cases and others.
Daniel Stenberg95df5d02008-09-24 07:50:46 +00001013
Daniel Stenberga28464a2021-10-31 16:34:44 +01001014 However, many servers do not implement the Expect: stuff properly and if the
1015 server does not respond (positively) within 1 second libcurl will continue
Daniel Stenberg95df5d02008-09-24 07:50:46 +00001016 and send off the data anyway.
1017
1018 You can disable libcurl's use of the Expect: header the same way you disable
1019 any header, using -H / CURLOPT_HTTPHEADER, or by forcing it to use HTTP 1.0.
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001020
Daniel Stenberg2afb88e2009-02-23 21:21:00 +00001021 4.17 Non-functional connect timeouts
1022
1023 In most Windows setups having a timeout longer than 21 seconds make no
1024 difference, as it will only send 3 TCP SYN packets and no more. The second
1025 packet sent three seconds after the first and the third six seconds after
Daniel Stenberge30b2062021-12-09 12:03:35 +01001026 the second. No more than three packets are sent, no matter how long the
Daniel Stenberg2afb88e2009-02-23 21:21:00 +00001027 timeout is set.
1028
1029 See option TcpMaxConnectRetransmissions on this page:
Viktor Szakats45f21e02015-06-16 00:47:26 +02001030 https://support.microsoft.com/en-us/kb/175523/en-us
Daniel Stenberg2afb88e2009-02-23 21:21:00 +00001031
1032 Also, even on non-Windows systems there may run a firewall or anti-virus
1033 software or similar that accepts the connection but does not actually do
1034 anything else. This will make (lib)curl to consider the connection connected
Daniel Stenberga28464a2021-10-31 16:34:44 +01001035 and thus the connect timeout will not trigger.
Daniel Stenberg2afb88e2009-02-23 21:21:00 +00001036
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001037 4.18 file:// URLs containing drive letters (Windows, NetWare)
1038
Daniel Stenberg0f199632016-10-18 13:59:54 +02001039 When using curl to try to download a local file, one might use a URL
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001040 in this format:
1041
1042 file://D:/blah.txt
1043
Daniel Stenberga28464a2021-10-31 16:34:44 +01001044 you will find that even if D:\blah.txt does exist, curl returns a 'file
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001045 not found' error.
1046
Viktor Szakats45f21e02015-06-16 00:47:26 +02001047 According to RFC 1738 (https://www.ietf.org/rfc/rfc1738.txt),
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001048 file:// URLs must contain a host component, but it is ignored by
1049 most implementations. In the above example, 'D:' is treated as the
Daniel Stenberg0f199632016-10-18 13:59:54 +02001050 host component, and is taken away. Thus, curl tries to open '/blah.txt'.
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001051 If your system is installed to drive C:, that will resolve to 'C:\blah.txt',
Daniel Stenberga28464a2021-10-31 16:34:44 +01001052 and if that does not exist you will get the not found error.
Daniel Stenbergb8012ea2009-11-07 21:52:41 +00001053
1054 To fix this problem, use file:// URLs with *three* leading slashes:
1055
1056 file:///D:/blah.txt
1057
1058 Alternatively, if it makes more sense, specify 'localhost' as the host
1059 component:
1060
1061 file://localhost/D:/blah.txt
1062
Daniel Stenberg0f199632016-10-18 13:59:54 +02001063 In either case, curl should now be looking for the correct file.
Daniel Stenberg2afb88e2009-02-23 21:21:00 +00001064
Daniel Stenberga28464a2021-10-31 16:34:44 +01001065 4.19 Why does not curl return an error when the network cable is unplugged?
Dan Fandrich7d166b02010-07-21 15:15:07 -07001066
Dan Fandrich31c6e7a2013-04-15 22:26:18 +02001067 Unplugging a cable is not an error situation. The TCP/IP protocol stack
Dan Fandrich7d166b02010-07-21 15:15:07 -07001068 was designed to be fault tolerant, so even though there may be a physical
Daniel Stenberga28464a2021-10-31 16:34:44 +01001069 break somewhere the connection should not be affected, just possibly
Daniel Stenberge30b2062021-12-09 12:03:35 +01001070 delayed. Eventually, the physical break will be fixed or the data will be
Dan Fandrich31c6e7a2013-04-15 22:26:18 +02001071 re-routed around the physical problem through another path.
Dan Fandrich7d166b02010-07-21 15:15:07 -07001072
1073 In such cases, the TCP/IP stack is responsible for detecting when the
1074 network connection is irrevocably lost. Since with some protocols it is
Daniel Stenberg14f92f22016-01-25 11:11:29 +01001075 perfectly legal for the client to wait indefinitely for data, the stack may
Dan Fandrich7d166b02010-07-21 15:15:07 -07001076 never report a problem, and even when it does, it can take up to 20 minutes
Daniel Stenberge30b2062021-12-09 12:03:35 +01001077 for it to detect an issue. The curl option --keepalive-time enables
Dan Fandrich7d166b02010-07-21 15:15:07 -07001078 keep-alive support in the TCP/IP stack which makes it periodically probe the
1079 connection to make sure it is still available to send data. That should
1080 reliably detect any TCP/IP network failure.
1081
Daniel Stenberge30b2062021-12-09 12:03:35 +01001082 TCP keep alive will not detect the network going down before the TCP/IP
Dan Fandrich7d166b02010-07-21 15:15:07 -07001083 connection is established (e.g. during a DNS lookup) or using protocols that
Daniel Stenberge30b2062021-12-09 12:03:35 +01001084 do not use TCP. To handle those situations, curl offers a number of timeouts
Dan Fandrich7d166b02010-07-21 15:15:07 -07001085 on its own. --speed-limit/--speed-time will abort if the data transfer rate
1086 falls too low, and --connect-timeout and --max-time can be used to put an
1087 overall timeout on the connection phase or the entire transfer.
1088
Dan Fandrich31c6e7a2013-04-15 22:26:18 +02001089 A libcurl-using application running in a known physical environment (e.g.
1090 an embedded device with only a single network connection) may want to act
Daniel Stenberge30b2062021-12-09 12:03:35 +01001091 immediately if its lone network connection goes down. That can be achieved
Dan Fandrich31c6e7a2013-04-15 22:26:18 +02001092 by having the application monitor the network connection on its own using an
Daniel Stenberg1640bb62019-02-28 09:09:51 +01001093 OS-specific mechanism, then signaling libcurl to abort (see also item 5.13).
Daniel Stenberg889de6b2014-08-28 11:39:39 +02001094
Daniel Stenberge30b2062021-12-09 12:03:35 +01001095 4.20 curl does not return error for HTTP non-200 responses
Daniel Stenberg889de6b2014-08-28 11:39:39 +02001096
1097 Correct. Unless you use -f (--fail).
1098
Daniel Stenberga28464a2021-10-31 16:34:44 +01001099 When doing HTTP transfers, curl will perform exactly what you are asking it
Daniel Stenberg889de6b2014-08-28 11:39:39 +02001100 to do and if successful it will not return an error. You can use curl to
1101 test your web server's "file not found" page (that gets 404 back), you can
Daniel Stenberg816ac2a2024-07-01 10:37:43 +02001102 use it to check your authentication protected webpages (that gets a 401
Daniel Stenberg889de6b2014-08-28 11:39:39 +02001103 back) and so on.
1104
1105 The specific HTTP response code does not constitute a problem or error for
1106 curl. It simply sends and delivers HTTP as you asked and if that worked,
1107 everything is fine and dandy. The response code is generally providing more
Daniel Stenberga28464a2021-10-31 16:34:44 +01001108 higher level error information that curl does not care about. The error was
Daniel Stenberg889de6b2014-08-28 11:39:39 +02001109 not in the HTTP transfer.
1110
1111 If you want your command line to treat error codes in the 400 and up range
1112 as errors and thus return a non-zero value and possibly show an error
1113 message, curl has a dedicated option for that: -f (CURLOPT_FAILONERROR in
1114 libcurl speak).
1115
Daniel Stenbergaccbbd72014-08-28 11:42:00 +02001116 You can also use the -w option and the variable %{response_code} to extract
railsnewbie257cd6b99e2017-01-11 23:48:22 -06001117 the exact response code that was returned in the response.
Daniel Stenbergaccbbd72014-08-28 11:42:00 +02001118
Daniel Stenbergc3318b42000-08-17 14:06:42 +000011195. libcurl Issues
Daniel Stenberg29470102000-06-02 13:32:01 +00001120
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001121 5.1 Is libcurl thread-safe?
Daniel Stenberg29470102000-06-02 13:32:01 +00001122
Daniel Stenberg7d09e512001-01-11 12:52:07 +00001123 Yes.
1124
Dan Fandrichec2ad572005-04-13 19:31:00 +00001125 We have written the libcurl code specifically adjusted for multi-threaded
Daniel Stenberg7d09e512001-01-11 12:52:07 +00001126 programs. libcurl will use thread-safe functions instead of non-safe ones if
Daniel Stenberge30b2062021-12-09 12:03:35 +01001127 your system has such. Note that you must never share the same handle in
Dan Fandrich31c6e7a2013-04-15 22:26:18 +02001128 multiple threads.
1129
Jay Satirobefa21f2016-05-05 14:34:27 -04001130 There may be some exceptions to thread safety depending on how libcurl was
1131 built. Please review the guidelines for thread safety to learn more:
Daniel Stenberg4d2f8002020-11-04 14:02:01 +01001132 https://curl.se/libcurl/c/threadsafe.html
Daniel Stenberg7f70dbc2007-02-12 22:32:37 +00001133
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001134 5.2 How can I receive all data into a large memory chunk?
1135
Daniel Stenberga84af982001-05-15 13:09:27 +00001136 [ See also the examples/getinmemory.c source ]
1137
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001138 You are in full control of the callback function that gets called every time
1139 there is data received from the remote server. You can make that callback do
Daniel Stenberg4c485992001-04-22 15:45:27 +00001140 whatever you want. You do not have to write the received data to a file.
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001141
1142 One solution to this problem could be to have a pointer to a struct that you
1143 pass to the callback function. You set the pointer using the
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001144 CURLOPT_WRITEDATA option. Then that pointer will be passed to the callback
1145 instead of a FILE * to a file:
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001146
1147 /* imaginary struct */
1148 struct MemoryStruct {
1149 char *memory;
1150 size_t size;
1151 };
1152
1153 /* imaginary callback function */
1154 size_t
1155 WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
1156 {
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001157 size_t realsize = size * nmemb;
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001158 struct MemoryStruct *mem = (struct MemoryStruct *)data;
Daniel Stenbergeea22872004-03-16 07:56:51 +00001159
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001160 mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
1161 if (mem->memory) {
1162 memcpy(&(mem->memory[mem->size]), ptr, realsize);
1163 mem->size += realsize;
1164 mem->memory[mem->size] = 0;
1165 }
1166 return realsize;
1167 }
1168
Daniel Stenberg2c100372000-12-19 07:30:51 +00001169 5.3 How do I fetch multiple files with libcurl?
Daniel Stenbergec5ac822000-12-14 08:37:09 +00001170
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +00001171 libcurl has excellent support for transferring multiple files. You should
1172 just repeatedly set new URLs with curl_easy_setopt() and then transfer it
1173 with curl_easy_perform(). The handle you get from curl_easy_init() is not
Daniel Stenberga28464a2021-10-31 16:34:44 +01001174 only reusable, but you are even encouraged to reuse it if you can, as that
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +00001175 will enable libcurl to use persistent connections.
Daniel Stenberga40b55d2000-11-22 07:27:26 +00001176
Viktor Szakatsf81f3512024-08-03 01:09:57 +02001177 5.4 Does libcurl do Winsock initialization on Win32 systems?
Daniel Stenberg910fc852000-12-30 11:48:51 +00001178
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +00001179 Yes, if told to in the curl_global_init() call.
Daniel Stenberg910fc852000-12-30 11:48:51 +00001180
Viktor Szakatsf81f3512024-08-03 01:09:57 +02001181 5.5 Does CURLOPT_WRITEDATA and CURLOPT_READDATA work on Win32 ?
Daniel Stenberg41084e52001-01-22 08:42:00 +00001182
1183 Yes, but you cannot open a FILE * and pass the pointer to a DLL and have
Daniel Stenberg7e3cd822003-12-08 13:59:35 +00001184 that DLL use the FILE * (as the DLL and the client application cannot access
1185 each others' variable memory areas). If you set CURLOPT_WRITEDATA you must
1186 also use CURLOPT_WRITEFUNCTION as well to set a function that writes the
1187 file, even if that simply writes the data to the specified FILE *.
1188 Similarly, if you use CURLOPT_READDATA you must also specify
1189 CURLOPT_READFUNCTION.
Daniel Stenberg41084e52001-01-22 08:42:00 +00001190
Daniel Stenberg4c485992001-04-22 15:45:27 +00001191 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +00001192
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +00001193 curl and libcurl have excellent support for persistent connections when
Daniel Stenberg816ac2a2024-07-01 10:37:43 +02001194 transferring several files from the same server. curl will attempt to reuse
Daniel Stenbergdb5c9cd2003-02-25 08:52:32 +00001195 connections for all URLs specified on the same command line/config file, and
1196 libcurl will reuse connections for all transfers that are made using the
1197 same libcurl handle.
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +00001198
Daniel Stenberg6d496952017-05-12 19:58:06 +02001199 When you use the easy interface the connection cache is kept within the easy
1200 handle. If you instead use the multi interface, the connection cache will be
1201 kept within the multi handle and will be shared among all the easy handles
railsnewbie257cd6b99e2017-01-11 23:48:22 -06001202 that are used within the same multi handle.
Daniel Stenbergc9a82f32011-06-21 08:44:42 +02001203
Daniel Stenberge30b2062021-12-09 12:03:35 +01001204 5.7 Link errors when building libcurl on Windows
Daniel Stenbergdd82d692002-10-08 07:16:17 +00001205
1206 You need to make sure that your project, and all the libraries (both static
1207 and dynamic) that it links against, are compiled/linked against the same run
1208 time library.
1209
1210 This is determined by the /MD, /ML, /MT (and their corresponding /M?d)
1211 options to the command line compiler. /MD (linking against MSVCRT dll) seems
1212 to be the most commonly used option.
1213
Gisle Vanem51a87fa2004-11-24 15:14:42 +00001214 When building an application that uses the static libcurl library, you must
1215 add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for
Daniel Stenberga28464a2021-10-31 16:34:44 +01001216 dynamic import symbols. If you are using Visual Studio, you need to instead
Daniel Stenberg6ce76e62010-09-08 23:23:19 +02001217 add CURL_STATICLIB in the "Preprocessor Definitions" section.
1218
Antoine Pietrib341b762022-01-27 02:12:50 +01001219 If you get a linker error like "unknown symbol __imp__curl_easy_init ..." you
Daniel Stenberge30b2062021-12-09 12:03:35 +01001220 have linked against the wrong (static) library. If you want to use the
Daniel Stenberga28464a2021-10-31 16:34:44 +01001221 libcurl.dll and import lib, you do not need any extra CFLAGS, but use one of
Daniel Stenberg6ce76e62010-09-08 23:23:19 +02001222 the import libraries below. These are the libraries produced by the various
1223 lib/Makefile.* files:
Gisle Vanem51a87fa2004-11-24 15:14:42 +00001224
Daniel Stenberg77110862011-03-14 13:31:05 +01001225 Target: static lib. import lib for libcurl*.dll.
1226 -----------------------------------------------------------
Viktor Szakats7313ffe2022-09-29 21:29:04 +00001227 MinGW: libcurl.a libcurldll.a
Daniel Stenberg77110862011-03-14 13:31:05 +01001228 MSVC (release): libcurl.lib libcurl_imp.lib
1229 MSVC (debug): libcurld.lib libcurld_imp.lib
1230 Borland: libcurl.lib libcurl_imp.lib
Gisle Vanem51a87fa2004-11-24 15:14:42 +00001231
Daniel Stenberg9754b202010-08-11 09:15:43 +02001232 5.8 libcurl.so.X: open failed: No such file or directory
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001233
1234 This is an error message you might get when you try to run a program linked
Daniel Stenberg3a4182d2022-03-29 13:58:11 +02001235 with a shared version of libcurl and your runtime linker (ld.so) could not
Daniel Stenberg9754b202010-08-11 09:15:43 +02001236 find the shared library named libcurl.so.X. (Where X is the number of the
1237 current libcurl ABI, typically 3 or 4).
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001238
Daniel Stenberg9754b202010-08-11 09:15:43 +02001239 You need to make sure that ld.so finds libcurl.so.X. You can do that
Daniel Stenberge30b2062021-12-09 12:03:35 +01001240 multiple ways, and it differs somewhat between different operating systems.
1241 They are usually:
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001242
1243 * Add an option to the linker command line that specify the hard-coded path
Daniel Stenberg3a4182d2022-03-29 13:58:11 +02001244 the runtime linker should check for the lib (usually -R)
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001245
1246 * Set an environment variable (LD_LIBRARY_PATH for example) where ld.so
1247 should check for libs
1248
Daniel Stenberga28464a2021-10-31 16:34:44 +01001249 * Adjust the system's config to check for libs in the directory where you have
Kushal Das94ac2ca2022-04-21 17:05:36 +02001250 put the library (like Linux's /etc/ld.so.conf)
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001251
1252 'man ld.so' and 'man ld' will tell you more details
1253
Daniel Stenberg816ac2a2024-07-01 10:37:43 +02001254 5.9 How does libcurl resolve hostnames?
Daniel Stenberg1d323362004-08-12 14:09:10 +00001255
Daniel Stenberge30b2062021-12-09 12:03:35 +01001256 libcurl supports a large number of name resolve functions. One of them is
1257 picked at build-time and will be used unconditionally. Thus, if you want to
1258 change name resolver function you must rebuild libcurl and tell it to use a
1259 different function.
Daniel Stenberg1d323362004-08-12 14:09:10 +00001260
Daniel Stenberg816ac2a2024-07-01 10:37:43 +02001261 - The non-IPv6 resolver that can use one of four different hostname resolve
railsnewbie257cd6b99e2017-01-11 23:48:22 -06001262 calls (depending on what your system supports):
Daniel Stenberg1d323362004-08-12 14:09:10 +00001263
Daniel Stenberg77110862011-03-14 13:31:05 +01001264 A - gethostbyname()
1265 B - gethostbyname_r() with 3 arguments
1266 C - gethostbyname_r() with 5 arguments
1267 D - gethostbyname_r() with 6 arguments
Daniel Stenberg1d323362004-08-12 14:09:10 +00001268
Steve Holme151ae592014-12-27 11:09:01 +00001269 - The IPv6-resolver that uses getaddrinfo()
Daniel Stenberg1d323362004-08-12 14:09:10 +00001270
1271 - The c-ares based name resolver that uses the c-ares library for resolves.
Daniel Stenbergfa811932011-04-14 23:12:27 +02001272 Using this offers asynchronous name resolves.
Daniel Stenberg1d323362004-08-12 14:09:10 +00001273
Daniel Stenberg18a9ee62010-06-30 15:52:58 +02001274 - The threaded resolver (default option on Windows). It uses:
Daniel Stenberg1d323362004-08-12 14:09:10 +00001275
Steve Holme151ae592014-12-27 11:09:01 +00001276 A - gethostbyname() on plain IPv4 hosts
1277 B - getaddrinfo() on IPv6 enabled hosts
Daniel Stenbergdd82d692002-10-08 07:16:17 +00001278
Daniel Stenberge9eb5232005-04-05 14:36:37 +00001279 Also note that libcurl never resolves or reverse-lookups addresses given as
1280 pure numbers, such as 127.0.0.1 or ::1.
1281
1282 5.10 How do I prevent libcurl from writing the response to stdout?
1283
1284 libcurl provides a default built-in write function that writes received data
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001285 to stdout. Set the CURLOPT_WRITEFUNCTION to receive the data, or possibly
1286 set CURLOPT_WRITEDATA to a different FILE * handle.
Daniel Stenberge9eb5232005-04-05 14:36:37 +00001287
Daniel Stenberg6e8e0412005-04-05 14:38:38 +00001288 5.11 How do I make libcurl not receive the whole HTTP response?
1289
1290 You make the write callback (or progress callback) return an error and
1291 libcurl will then abort the transfer.
1292
Daniel Stenbergb5d50e92005-04-11 13:39:55 +00001293 5.12 Can I make libcurl fake or hide my real IP address?
1294
Daniel Stenberg1a911f72013-08-24 17:13:46 +02001295 No. libcurl operates on a higher level. Besides, faking IP address would
railsnewbie257cd6b99e2017-01-11 23:48:22 -06001296 imply sending IP packets with a made-up source address, and then you normally
Daniel Stenberg1a911f72013-08-24 17:13:46 +02001297 get a problem with receiving the packet sent back as they would then not be
Daniel Stenberge30b2062021-12-09 12:03:35 +01001298 routed to you.
Daniel Stenbergb5d50e92005-04-11 13:39:55 +00001299
1300 If you use a proxy to access remote sites, the sites will not see your local
1301 IP address but instead the address of the proxy.
1302
1303 Also note that on many networks NATs or other IP-munging techniques are used
1304 that makes you see and use a different IP address locally than what the
Daniel Stenberg1a911f72013-08-24 17:13:46 +02001305 remote server will see you coming from. You may also consider using
Viktor Szakats45f21e02015-06-16 00:47:26 +02001306 https://www.torproject.org/ .
Daniel Stenbergb5d50e92005-04-11 13:39:55 +00001307
Daniel Stenberg24602ed2007-12-10 10:28:56 +00001308 5.13 How do I stop an ongoing transfer?
1309
Daniel Stenberg4b837a72011-01-24 22:18:43 +01001310 With the easy interface you make sure to return the correct error code from
1311 one of the callbacks, but none of them are instant. There is no function you
1312 can call from another thread or similar that will stop it immediately.
Dan Fandrichb3740f02011-06-02 18:41:57 -07001313 Instead, you need to make sure that one of the callbacks you use returns an
Daniel Stenberge30b2062021-12-09 12:03:35 +01001314 appropriate value that will stop the transfer. Suitable callbacks that you
Dan Fandrichb3740f02011-06-02 18:41:57 -07001315 can do this with include the progress callback, the read callback and the
1316 write callback.
Daniel Stenberg24602ed2007-12-10 10:28:56 +00001317
Daniel Stenberga28464a2021-10-31 16:34:44 +01001318 If you are using the multi interface, you can also stop a transfer by
Dan Fandrichb3740f02011-06-02 18:41:57 -07001319 removing the particular easy handle from the multi stack at any moment you
Daniel Stenberg9ca812f2013-02-04 22:46:51 +01001320 think the transfer is done or when you wish to abort the transfer.
Daniel Stenberge9eb5232005-04-05 14:36:37 +00001321
Daniel Stenberg22059852008-09-24 07:39:42 +00001322 5.14 Using C++ non-static functions for callbacks?
1323
Daniel Stenberga28464a2021-10-31 16:34:44 +01001324 libcurl is a C library, it does not know anything about C++ member functions.
Daniel Stenberg22059852008-09-24 07:39:42 +00001325
railsnewbie257cd6b99e2017-01-11 23:48:22 -06001326 You can overcome this "limitation" with relative ease using a static
Daniel Stenberg22059852008-09-24 07:39:42 +00001327 member function that is passed a pointer to the class:
1328
1329 // f is the pointer to your object.
Stephen Brokenshire2a1d5382016-10-01 16:36:50 +01001330 static size_t YourClass::func(void *buffer, size_t sz, size_t n, void *f)
Daniel Stenberg22059852008-09-24 07:39:42 +00001331 {
1332 // Call non-static member function.
1333 static_cast<YourClass*>(f)->nonStaticFunction();
1334 }
1335
1336 // This is how you pass pointer to the static function:
Stephen Brokenshire2a1d5382016-10-01 16:36:50 +01001337 curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, YourClass::func);
Daniel Stenberg22059852008-09-24 07:39:42 +00001338 curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, this);
1339
Yang Tsea07bc792010-02-14 19:40:18 +00001340 5.15 How do I get an FTP directory listing?
Daniel Stenberg8740d142009-06-09 09:02:39 +00001341
1342 If you end the FTP URL you request with a slash, libcurl will provide you
1343 with a directory listing of that given directory. You can also set
1344 CURLOPT_CUSTOMREQUEST to alter what exact listing command libcurl would use
1345 to list the files.
1346
Jay Satirof9eed592016-07-09 03:05:55 -04001347 The follow-up question tends to be how is a program supposed to parse the
Kushal Das94ac2ca2022-04-21 17:05:36 +02001348 directory listing. How does it know what's a file and what's a directory and
1349 what's a symlink etc. If the FTP server supports the MLSD command then it
1350 will return data in a machine-readable format that can be parsed for type.
Daniel Stenberg22c92a62023-06-25 10:50:17 +02001351 The types are specified by RFC 3659 section 7.5.1. If MLSD is not supported
Kushal Das94ac2ca2022-04-21 17:05:36 +02001352 then you have to work with what you are given. The LIST output format is
1353 entirely at the server's own liking and the NLST output does not reveal any
1354 types and in many cases does not even include all the directory entries.
Viktor Szakatsf81f3512024-08-03 01:09:57 +02001355 Also, both LIST and NLST tend to hide Unix-style hidden files (those that
Kushal Das94ac2ca2022-04-21 17:05:36 +02001356 start with a dot) by default so you need to do "LIST -a" or similar to see
1357 them.
Daniel Stenberg8740d142009-06-09 09:02:39 +00001358
Jay Satirof9eed592016-07-09 03:05:55 -04001359 Example - List only directories.
1360 ftp.funet.fi supports MLSD and ftp.kernel.org does not:
1361
1362 curl -s ftp.funet.fi/pub/ -X MLSD | \
1363 perl -lne 'print if s/(?:^|;)type=dir;[^ ]+ (.+)$/$1/'
1364
1365 curl -s ftp.kernel.org/pub/linux/kernel/ | \
1366 perl -lne 'print if s/^d[-rwx]{9}(?: +[^ ]+){7} (.+)$/$1/'
1367
1368 If you need to parse LIST output in libcurl one such existing
Viktor Szakatsd49881c2016-02-03 05:09:25 +01001369 list parser is available at https://cr.yp.to/ftpparse.html Versions of
Dan Fandrich7d166b02010-07-21 15:15:07 -07001370 libcurl since 7.21.0 also provide the ability to specify a wildcard to
1371 download multiple files from one FTP directory.
Daniel Stenberg8740d142009-06-09 09:02:39 +00001372
Daniel Stenberge30b2062021-12-09 12:03:35 +01001373 5.16 I want a different time-out
Daniel Stenberge8ab9a02012-09-28 15:50:18 +02001374
Daniel Stenberge30b2062021-12-09 12:03:35 +01001375 Sometimes users realize that CURLOPT_TIMEOUT and CURLOPT_CONNECTIMEOUT are
1376 not sufficiently advanced or flexible to cover all the various use cases and
1377 scenarios applications end up with.
Daniel Stenberge8ab9a02012-09-28 15:50:18 +02001378
1379 libcurl offers many more ways to time-out operations. A common alternative
1380 is to use the CURLOPT_LOW_SPEED_LIMIT and CURLOPT_LOW_SPEED_TIME options to
1381 specify the lowest possible speed to accept before to consider the transfer
1382 timed out.
1383
1384 The most flexible way is by writing your own time-out logic and using
Daniel Stenberg7f555dc2017-10-09 16:13:27 +02001385 CURLOPT_XFERINFOFUNCTION (perhaps in combination with other callbacks) and
Daniel Stenberge8ab9a02012-09-28 15:50:18 +02001386 use that to figure out exactly when the right condition is met when the
1387 transfer should get stopped.
1388
Daniel Stenbergdbf93a82013-01-03 10:15:02 +01001389 5.17 Can I write a server with libcurl?
1390
1391 No. libcurl offers no functions or building blocks to build any kind of
Daniel Stenberg3a4182d2022-03-29 13:58:11 +02001392 Internet protocol server. libcurl is only a client-side library. For server
Daniel Stenbergdbf93a82013-01-03 10:15:02 +01001393 libraries, you need to continue your search elsewhere but there exist many
Daniel Stenberge30b2062021-12-09 12:03:35 +01001394 good open source ones out there for most protocols you could want a server
1395 for. There are also really good stand-alone servers that have been tested
Kushal Das94ac2ca2022-04-21 17:05:36 +02001396 and proven for many years. There is no need for you to reinvent them.
Daniel Stenbergdbf93a82013-01-03 10:15:02 +01001397
Daniel Stenberg1495f422014-05-08 09:30:35 +02001398 5.18 Does libcurl use threads?
1399
1400 Put simply: no, libcurl will execute in the same thread you call it in. All
1401 callbacks will be called in the same thread as the one you call libcurl in.
1402
1403 If you want to avoid your thread to be blocked by the libcurl call, you make
Daniel Stenberge30b2062021-12-09 12:03:35 +01001404 sure you use the non-blocking multi API which will do transfers
1405 asynchronously - still in the same single thread.
Daniel Stenberg1495f422014-05-08 09:30:35 +02001406
1407 libcurl will potentially internally use threads for name resolving, if it
Daniel Stenberga28464a2021-10-31 16:34:44 +01001408 was built to work like that, but in those cases it will create the child
Daniel Stenberg1495f422014-05-08 09:30:35 +02001409 threads by itself and they will only be used and then killed internally by
1410 libcurl and never exposed to the outside.
Daniel Stenberg8740d142009-06-09 09:02:39 +00001411
Daniel Stenbergc3318b42000-08-17 14:06:42 +000014126. License Issues
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001413
Daniel Stenberg92efb3d2021-11-01 13:43:11 +01001414 curl and libcurl are released under a MIT/X derivative license. The license
1415 is liberal and should not impose a problem for your project. This section is
1416 just a brief summary for the cases we get the most questions. (Parts of this
1417 section was much enhanced by Bjorn Reese.)
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001418
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001419 We are not lawyers and this is not legal advice. You should probably consult
Dan Fandrichc28443c2010-12-08 10:16:25 -08001420 one if you want true and accurate legal insights without our prejudice. Note
1421 especially that this section concerns the libcurl license only; compiling in
1422 features of libcurl that depend on other libraries (e.g. OpenSSL) may affect
1423 the licensing obligations of your application.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001424
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001425 6.1 I have a GPL program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001426
Daniel Stenberge30b2062021-12-09 12:03:35 +01001427 Yes
Daniel Stenberg7d1ef962000-08-14 06:31:59 +00001428
Daniel Stenberge30b2062021-12-09 12:03:35 +01001429 Since libcurl may be distributed under the MIT/X derivative license, it can
1430 be used together with GPL in any software.
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001431
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001432 6.2 I have a closed-source program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001433
Daniel Stenberge30b2062021-12-09 12:03:35 +01001434 Yes
Daniel Stenberg0d181b52001-01-04 12:43:53 +00001435
Daniel Stenbergc59baa02001-02-12 10:05:09 +00001436 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001437
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001438 6.3 I have a BSD licensed program, can I use the libcurl library?
Daniel Stenberg31b8eea2000-08-23 07:27:00 +00001439
Daniel Stenberge30b2062021-12-09 12:03:35 +01001440 Yes
Daniel Stenberg0d181b52001-01-04 12:43:53 +00001441
Daniel Stenbergc59baa02001-02-12 10:05:09 +00001442 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +00001443
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001444 6.4 I have a program that uses LGPL libraries, can I use libcurl?
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001445
Daniel Stenberge30b2062021-12-09 12:03:35 +01001446 Yes
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001447
Daniel Stenberga28464a2021-10-31 16:34:44 +01001448 The LGPL license does not clash with other licenses.
Daniel Stenbergc3318b42000-08-17 14:06:42 +00001449
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001450 6.5 Can I modify curl/libcurl for my program and keep the changes secret?
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001451
Daniel Stenberge30b2062021-12-09 12:03:35 +01001452 Yes
Daniel Stenberg0d181b52001-01-04 12:43:53 +00001453
Daniel Stenberge30b2062021-12-09 12:03:35 +01001454 The MIT/X derivative license practically allows you to do almost anything
1455 with the sources, on the condition that the copyright texts in the sources
1456 are left intact.
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001457
Daniel Stenberg811edcd2004-08-10 08:41:41 +00001458 6.6 Can you please change the curl/libcurl license to XXXX?
Daniel Stenbergc3c77392000-07-31 22:42:34 +00001459
Daniel Stenbergc59baa02001-02-12 10:05:09 +00001460 No.
1461
Daniel Stenberg11d718b2001-03-13 11:47:30 +00001462 We have carefully picked this license after years of development and
1463 discussions and a large amount of people have contributed with source code
1464 knowing that this is the license we use. This license puts the restrictions
1465 we want on curl/libcurl and it does not spread to other programs or
Daniel Stenberg3a552b12003-06-26 11:35:48 +00001466 libraries that use it. It should be possible for everyone to use libcurl or
1467 curl in their projects, no matter what license they already have in use.
Daniel Stenberg9ac76292004-08-18 11:18:36 +00001468
Dan Fandrich5c9fff92009-01-30 18:28:29 +00001469 6.7 What are my obligations when using libcurl in my commercial apps?
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001470
1471 Next to none. All you need to adhere to is the MIT-style license (stated in
1472 the COPYING file) which basically says you have to include the copyright
1473 notice in "all copies" and that you may not use the copyright holder's name
1474 when promoting your software.
1475
1476 You do not have to release any of your source code.
1477
1478 You do not have to reveal or make public any changes to the libcurl source
1479 code.
1480
Daniel Stenberg819dfdd2011-01-29 23:52:40 +01001481 You do not have to broadcast to the world that you are using libcurl within
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001482 your app.
1483
Daniel Stenberg819dfdd2011-01-29 23:52:40 +01001484 All we ask is that you disclose "the copyright notice and this permission
1485 notice" somewhere. Most probably like in the documentation or in the section
1486 where other third party dependencies already are mentioned and acknowledged.
1487
Daniel Stenberg4d2f8002020-11-04 14:02:01 +01001488 As can be seen here: https://curl.se/docs/companies.html and elsewhere,
Daniel Stenberg819dfdd2011-01-29 23:52:40 +01001489 more and more companies are discovering the power of libcurl and take
1490 advantage of it even in commercial environments.
Daniel Stenberg9a44fa82005-11-02 09:34:53 +00001491
1492
Daniel Stenberg9ac76292004-08-18 11:18:36 +000014937. PHP/CURL Issues
1494
1495 7.1 What is PHP/CURL?
1496
1497 The module for PHP that makes it possible for PHP programs to access curl-
Daniel Stenbergb6c876b2005-07-30 23:37:05 +00001498 functions from within PHP.
1499
1500 In the cURL project we call this module PHP/CURL to differentiate it from
1501 curl the command line tool and libcurl the library. The PHP team however
1502 does not refer to it like this (for unknown reasons). They call it plain
Daniel Stenberg844cbc72007-07-29 22:17:39 +00001503 CURL (often using all caps) or sometimes ext/curl, but both cause much
1504 confusion to users which in turn gives us a higher question load.
Daniel Stenberg9ac76292004-08-18 11:18:36 +00001505
Daniel Stenberge38a7882011-03-17 11:30:29 +01001506 7.2 Who wrote PHP/CURL?
Daniel Stenberg9ac76292004-08-18 11:18:36 +00001507
MaxGiting05cd55f2015-11-18 23:00:24 -05001508 PHP/CURL was initially written by Sterling Hughes.
Daniel Stenberg9ac76292004-08-18 11:18:36 +00001509
1510 7.3 Can I perform multiple requests using the same handle?
1511
Daniel Stenbergee400f92004-08-19 06:31:29 +00001512 Yes - at least in PHP version 4.3.8 and later (this has been known to not
1513 work in earlier versions, but the exact version when it started to work is
1514 unknown to me).
Daniel Stenberg9ac76292004-08-18 11:18:36 +00001515
Daniel Stenbergee400f92004-08-19 06:31:29 +00001516 After a transfer, you just set new options in the handle and make another
Daniel Stenberg5b060a42023-08-22 17:40:39 +02001517 transfer. This will make libcurl reuse the same connection if it can.
MaxGiting05cd55f2015-11-18 23:00:24 -05001518
1519 7.4 Does PHP/CURL have dependencies?
1520
1521 PHP/CURL is a module that comes with the regular PHP package. It depends on
1522 and uses libcurl, so you need to have libcurl installed properly before
1523 PHP/CURL can be used.
Daniel Stenberg352b07f2021-09-13 17:21:38 +02001524
15258. Development
1526
1527 8.1 Why does curl use C89?
1528
Kushal Das94ac2ca2022-04-21 17:05:36 +02001529 As with everything in curl, there is a history and we keep using what we have
Daniel Stenberg352b07f2021-09-13 17:21:38 +02001530 used before until someone brings up the subject and argues for and works on
1531 changing it.
1532
1533 We started out using C89 in the 1990s because that was the only way to write
1534 a truly portable C program and have it run as widely as possible. C89 was for
1535 a long time even necessary to make things work on otherwise considered modern
Daniel Stenberga28464a2021-10-31 16:34:44 +01001536 platforms such as Windows. Today, we do not really know how many users that
Daniel Stenberg352b07f2021-09-13 17:21:38 +02001537 still require the use of a C89 compiler.
1538
1539 We will continue to use C89 for as long as nobody brings up a strong enough
Daniel Stenberga28464a2021-10-31 16:34:44 +01001540 reason for us to change our minds. The core developers of the project do not
Daniel Stenberg352b07f2021-09-13 17:21:38 +02001541 feel restricted by this and we are not convinced that going C99 will offer us
1542 enough of a benefit to warrant the risk of cutting off a share of users.
1543
1544 8.2 Will curl be rewritten?
1545
1546 In one go: no. Little by little over time? Maybe.
1547
1548 Over the years, new languages and clever operating environments come and go.
1549 Every now and then the urge apparently arises to request that we rewrite curl
1550 in another language.
1551
1552 Some the most important properties in curl are maintaining the API and ABI
1553 for libcurl and keeping the behavior for the command line tool. As long as we
1554 can do that, everything else is up for discussion. To maintain the ABI, we
1555 probably have to maintain a certain amount of code in C, and to remain rock
1556 stable, we will never risk anything by rewriting a lot of things in one go.
1557 That said, we can certainly offer more and more optional backends written in
1558 other languages, as long as those backends can be plugged in at build-time.
Daniel Stenberg3a4182d2022-03-29 13:58:11 +02001559 Backends can be written in any language, but should probably provide APIs
Daniel Stenberg352b07f2021-09-13 17:21:38 +02001560 usable from C to ease integration and transition.