blob: 3c16e6684b80f4630a50aa02da051d6fa12e2fff [file] [log] [blame]
Daniel Stenberg97a8c982001-12-21 08:10:34 +00001Updated: December 21, 2001 (http://curl.haxx.se/docs/faq.shtml)
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +00002 _ _ ____ _
3 ___| | | | _ \| |
4 / __| | | | |_) | |
5 | (__| |_| | _ <| |___
6 \___|\___/|_| \_\_____|
7
8FAQ
9
Daniel Stenbergc3318b42000-08-17 14:06:42 +000010 1. Philosophy
11 1.1 What is cURL?
12 1.2 What is libcurl?
13 1.3 What is cURL not?
14 1.4 When will you make curl do XXXX ?
Daniel Stenberga0eb52b2001-03-23 15:28:13 +000015 1.5 Who makes cURL?
16 1.6 What do you get for making cURL?
Daniel Stenbergc528dc52001-08-07 11:17:37 +000017 1.7 What about CURL from curl.com?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000018
Daniel Stenbergc3318b42000-08-17 14:06:42 +000019 2. Install Related Problems
20 2.1 configure doesn't find OpenSSL even when it is installed
21 2.1.1. native linker doesn't find openssl
22 2.1.2. only the libssl lib is missing
23 2.2 Does curl work/build with other SSL libraries?
24 2.3 Where can I find a copy of LIBEAY32.DLL?
25 2.4 Does cURL support Socks (RFC 1928) ?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000026
Daniel Stenbergc3318b42000-08-17 14:06:42 +000027 3. Usage Problems
28 3.1 curl: (1) SSL is disabled, https: not supported
29 3.2 How do I tell curl to resume a transfer?
30 3.3 Why doesn't my posting using -F work?
31 3.4 How do I tell curl to run custom FTP commands?
32 3.5 How can I disable the Pragma: nocache header?
33 3.6 Does curl support javascript, ASP, XML, XHTML or HTML version Y?
34 3.7 Can I use curl to delete/rename a file through FTP?
35 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenbergdfdf4912001-12-21 09:20:04 +000036 3.9 How do I use curl in my favourite programming language?
Daniel Stenberg147a6732001-03-08 09:25:09 +000037 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenberg88d14e92001-05-29 14:02:20 +000038 3.11 How do I POST with a different Content-Type?
Daniel Stenberg6513dce2001-11-27 13:34:59 +000039 3.12 Why do FTP specific features over HTTP proxy fail?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000040
Daniel Stenbergc3318b42000-08-17 14:06:42 +000041 4. Running Problems
42 4.1 Problems connecting to SSL servers.
Daniel Stenberge26ee092001-01-15 10:26:37 +000043 4.2 Why do I get problems when I use & or % in the URL?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000044 4.3 How can I use {, }, [ or ] to specify multiple URLs?
45 4.4 Why do I get downloaded data even though the web page doesn't exist?
46 4.5 Why do I get return code XXX from a HTTP server?
47 4.5.1 "400 Bad Request"
48 4.5.2 "401 Unauthorized"
49 4.5.3 "403 Forbidden"
50 4.5.4 "404 Not Found"
51 4.5.5 "405 Method Not Allowed"
Daniel Stenbergd60029d2001-12-19 23:25:04 +000052 4.5.6 "301 Moved Permanently"
Daniel Stenbergc3318b42000-08-17 14:06:42 +000053 4.6 Can you tell me what error code 142 means?
Daniel Stenberg4c485992001-04-22 15:45:27 +000054 4.7 How do I keep user names and passwords secret in Curl command lines?
Daniel Stenberg09ba8562000-10-27 12:25:00 +000055 4.8 I found a bug!
Daniel Stenberg2c100372000-12-19 07:30:51 +000056 4.9 Curl can't authenticate to the server that requires NTLM?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000057
Daniel Stenbergc3318b42000-08-17 14:06:42 +000058 5. libcurl Issues
Daniel Stenberg7d09e512001-01-11 12:52:07 +000059 5.1 Is libcurl thread-safe?
Daniel Stenberga40b55d2000-11-22 07:27:26 +000060 5.2 How can I receive all data into a large memory chunk?
Daniel Stenberg2c100372000-12-19 07:30:51 +000061 5.3 How do I fetch multiple files with libcurl?
Daniel Stenberg910fc852000-12-30 11:48:51 +000062 5.4 Does libcurl do Winsock initing on win32 systems?
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +000063 5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ?
Daniel Stenberg4c485992001-04-22 15:45:27 +000064 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000065
Daniel Stenbergc3318b42000-08-17 14:06:42 +000066 6. License Issues
67 6.1 I have a GPL program, can I use the libcurl library?
68 6.2 I have a closed-source program, can I use the libcurl library?
Daniel Stenberg31b8eea2000-08-23 07:27:00 +000069 6.3 I have a BSD licensed program, can I use the libcurl library?
70 6.4 I have a program that uses LGPL libraries, can I use libcurl?
71 6.5 Can I modify curl/libcurl for my program and keep the changes secret?
72 6.6 Can you please change the curl/libcurl license to XXXX?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000073
74==============================================================================
75
761. Philosophy
77
78 1.1 What is cURL?
79
80 cURL (or simply just 'curl') is a command line tool for getting or sending
81 files using URL syntax. The name is a play on 'Client for URLs', originally
Daniel Stenberg09ba8562000-10-27 12:25:00 +000082 with URL spelled in uppercase to make it obvious it deals with URLs. The
83 fact it can also be pronounced 'see URL' also helped.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000084
Daniel Stenberg4c485992001-04-22 15:45:27 +000085 Curl supports a range of common Internet protocols, currently including
Daniel Stenbergd73d28a2001-08-23 11:12:07 +000086 HTTP, HTTPS, FTP, FTPS, GOPHER, LDAP, DICT, TELNET and FILE.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000087
Daniel Stenberg8e7b2612001-03-22 11:23:48 +000088 We spell it cURL or just curl. We pronounce it with an initial k sound:
89 [kurl].
Daniel Stenberg887e7282001-01-03 09:13:07 +000090
Daniel Stenbergc3318b42000-08-17 14:06:42 +000091 1.2 What is libcurl?
92
Daniel Stenbergbc5954f2001-03-23 08:16:24 +000093 libcurl is a reliable and portable library which provides you with an easy
Daniel Stenberg4c485992001-04-22 15:45:27 +000094 interface to a range of common Internet protocols.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000095
Daniel Stenbergbc5954f2001-03-23 08:16:24 +000096 You can use libcurl for free in your application even if it is commercial
97 or closed-source.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000098
99 1.3 What is cURL not?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000100
Daniel Stenberg7d24ce92001-11-01 09:12:35 +0000101 Curl is *not* a wget clone even though that is a very common misconception.
102 Never, during curl's development, have we intended curl to replace wget or
103 compete on its market. Curl is targeted at single-shot file transfers.
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000104
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000105 Curl is not a web site mirroring program. If you wanna use curl to mirror
106 something: fine, go ahead and write a script that wraps around curl to make
107 it reality (like curlmirror.pl does).
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000108
Daniel Stenberg4c485992001-04-22 15:45:27 +0000109 Curl is not an FTP site mirroring program. Sure, get and send FTP with curl
110 but if you want systematic and sequential behavior you should write a
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000111 script (or write a new program that interfaces libcurl) and do it.
112
113 Curl is not a PHP tool, even though it works perfectly well when used from
114 or with PHP.
115
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000116 Curl is not a single-OS program. Curl exists, compiles, builds and runs
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000117 under a wide range of operating systems, including all modern Unixes (and a
118 bunch of older ones too), Windows, Amiga, BeOS, OS/2, OS X, QNX etc.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000119
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000120 1.4 When will you make curl do XXXX ?
121
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000122 We love suggestions of what to change in order to make curl and libcurl
123 better. We do however believe in a few rules when it comes to the future of
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000124 curl:
125
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000126 * Curl is to remain a command line tool. If you want GUIs or fancy scripting
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000127 capabilities, you're free to write another tool that uses libcurl and that
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000128 offers this. There's no point in having a single tool that does every
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000129 imaginable thing. That's also one of the great advantages of having the
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000130 core of curl as a library.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000131
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000132 * We do not add things to curl that other small and available tools already
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000133 do very fine at the side. Curl's output is fine to pipe into another
134 program or redirect to another file for the next program to interpret.
135
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000136 * We focus on protocol related issues and improvements. If you wanna do more
Daniel Stenberg5f8e93d2000-10-25 07:41:58 +0000137 magic with the supported protocols than curl currently does, chances are
Daniel Stenberg7d24ce92001-11-01 09:12:35 +0000138 big we will agree. If you wanna add more protocols, we may very well
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000139 agree.
140
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000141 * If you want someone else to make all the work while you wait for us to
142 implement it for you, that is not a very friendly attitude. We spend a
143 considerable time already on maintaining and developing curl. In order to
144 get more out of us, you should consider trading in some of your time and
145 efforts in return.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000146
147 * If you write the code, chances are bigger that it will get into curl
148 faster.
149
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000150 1.5 Who makes cURL?
151
152 cURL and libcurl are not made by any single individual. Sure, Daniel
153 Stenberg writes the major parts, but various people's submissions are
154 important and crucial. Anyone can post their changes and improvements and
155 have them inserted in the main sources (of course on the condition that
156 developers agree on that the fixes are good).
157
Daniel Stenberg81f22462001-11-27 13:33:21 +0000158 The list of contributors in the docs/THANKS file is only a small part of all
159 the people that every day provide us with bug reports, suggestions, ideas
160 and source code.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000161
162 curl is developed by a community, with Daniel at the wheel.
163
164 1.6 What do you get for making cURL?
165
166 Project cURL is entirely free and open, without any commercial interests or
167 money involved. No person gets paid in any way for developing curl. We all
Daniel Stenberg4c485992001-04-22 15:45:27 +0000168 do this voluntarily on our spare time.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000169
170 We get some help from companies. Contactor Data hosts the curl web site and
171 the main mailing list, Haxx owns the curl web site's domain and
172 sourceforge.net hosts several project tools we take advantage from like the
173 bug tracker, mailing lists and more.
174
Daniel Stenbergd3706812001-11-27 13:37:29 +0000175 If you want to support our project with a donation or similar, one way of
Daniel Stenberg25fe47f2001-11-14 20:13:38 +0000176 doing that would be to buy "gift certificates" at useful online shopping
177 sites, such as amazon.com or thinkgeek.com. Another way would be to sponsor
178 us through a banner-program or by simply helping us coding, documenting,
179 testing etc.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000180
181 1.7 What about CURL from curl.com?
182
183 During the summer 2001, curl.com has been busy advertising their client-side
184 programming language for the web, named CURL.
185
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000186 We are in no way associated with curl.com or their CURL programming
187 language.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000188
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000189 Our project name curl has been in effective use since 1998. We were not the
Daniel Stenberg4045cd52001-08-07 21:21:24 +0000190 first computer related project to use the name "curl" and do not claim any
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000191 first-hand rights to the name.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000192
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000193 We recognize that we will be living in parallel with curl.com and wish them
194 every success.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000195
Daniel Stenbergc3318b42000-08-17 14:06:42 +00001962. Install Related Problems
197
198 2.1. configure doesn't find OpenSSL even when it is installed
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000199
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000200 This may be because of several reasons.
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000201
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000202 2.1.1. native linker doesn't find openssl
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000203
Daniel Stenbergbfb16902000-08-17 11:42:59 +0000204 Affected platforms:
205 Solaris (native cc compiler)
206 HPUX (native cc compiler)
207 SGI IRIX (native cc compiler)
Daniel Stenberg13962ad2000-09-28 10:26:44 +0000208 SCO UNIX (native cc compiler)
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000209
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000210 When configuring curl, I specify --with-ssl. OpenSSL is installed in
211 /usr/local/ssl Configure reports SSL in /usr/local/ssl, but fails to find
212 CRYPTO_lock in -lcrypto
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000213
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000214 Cause: The cc for this test places the -L/usr/local/ssl/lib AFTER
215 -lcrypto, so ld can't find the library. This is due to a bug in the GNU
216 autoconf tool.
217
218 Workaround: Specifying "LDFLAGS=-L/usr/local/ssl/lib" in front of
219 ./configure places the -L/usr/local/ssl/lib early enough in the command
220 line to make things work
221
Daniel Stenbergbfb16902000-08-17 11:42:59 +0000222 Solution submitted by: Bob Allison <allisonb@users.sourceforge.net>
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000223
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000224 2.1.2. only the libssl lib is missing
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000225
226 If all include files and the libcrypto lib is present, with only the
227 libssl being missing according to configure, this is mostly likely because
228 a few functions are left out from the libssl.
229
230 If the function names missing include RSA or RSAREF you can be certain
Daniel Stenberg4c485992001-04-22 15:45:27 +0000231 that this is because libssl requires the RSA and RSAREF libs to build.
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000232
233 See the INSTALL file section that explains how to add those libs to
234 configure. Make sure that you remove the config.cache file before you
235 rerun configure with the new flags.
236
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000237 2.2. Does curl work/build with other SSL libraries?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000238
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000239 Curl has been written to use OpenSSL, although there should not be much
Daniel Stenberg26d1aac2001-02-16 13:41:09 +0000240 problems using a different library. If anyone does "port" curl to use a
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000241 different SSL library, we are of course very interested in getting the
242 patch!
Daniel Stenberge9640b62000-08-02 07:17:56 +0000243
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000244 2.3. Where can I find a copy of LIBEAY32.DLL?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000245
246 That is an OpenSSL binary built for Windows.
247
248 Curl uses OpenSSL to do the SSL stuff. The LIBEAY32.DLL is what curl needs
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000249 on a windows machine to do https://. Check out the curl web site to find
Daniel Stenberg4c485992001-04-22 15:45:27 +0000250 accurate and up-to-date pointers to recent OpenSSL DLLs and other binary
Daniel Stenberge9640b62000-08-02 07:17:56 +0000251 packages.
252
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000253 2.4. Does cURL support Socks (RFC 1928) ?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000254
Daniel Stenberg4c485992001-04-22 15:45:27 +0000255 No. Nobody has wanted it that badly yet. We appreciate patches that bring
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000256 this functionality.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000257
258
Daniel Stenbergc3318b42000-08-17 14:06:42 +00002593. Usage problems
Daniel Stenberge9640b62000-08-02 07:17:56 +0000260
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000261 3.1. curl: (1) SSL is disabled, https: not supported
Daniel Stenberge9640b62000-08-02 07:17:56 +0000262
263 If you get this output when trying to get anything from a https:// server,
264 it means that the configure script couldn't find all libs and include files
265 it requires for SSL to work. If the configure script fails to find them,
266 curl is simply built without SSL support.
267
268 To get the https:// support into a curl that was previously built but that
269 reports that https:// is not supported, you should dig through the document
270 and logs and check out why the configure script doesn't find the SSL libs
271 and/or include files.
272
273 Also, check out the other paragraph in this FAQ labeled "configure doesn't
274 find OpenSSL even when it is installed".
275
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000276 3.2. How do I tell curl to resume a transfer?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000277
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000278 Curl supports resumed transfers both ways on both FTP and HTTP.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000279
Daniel Stenberg887e7282001-01-03 09:13:07 +0000280 Try the -C option.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000281
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000282 3.3. Why doesn't my posting using -F work?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000283
284 You can't simply use -F or -d at your choice. The web server that will
285 receive your post assumes one of the formats. If the form you're trying to
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000286 "fake" sets the type to 'multipart/form-data', then and only then you must
Daniel Stenberge9640b62000-08-02 07:17:56 +0000287 use the -F type. In all the most common cases, you should use -d which then
288 causes a posting with the type 'application/x-www-form-urlencoded'.
289
Daniel Stenberg4c485992001-04-22 15:45:27 +0000290 This is described in some detail in the MANUAL and TheArtOfHttpScripting
291 documents, and if you don't understand it the first time, read it again
292 before you post questions about this to the mailing list. Also, try reading
293 through the mailing list archives for old postings and questions regarding
294 this.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000295
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000296 3.4. How do I tell curl to run custom FTP commands?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000297
298 You can tell curl to perform optional commands both before and/or after a
299 file transfer. Study the -Q/--quote option.
300
301 Since curl is used for file transfers, you don't use curl to just perform
Daniel Stenberg4c485992001-04-22 15:45:27 +0000302 FTP commands without transferring anything. Therefore you must always specify
Daniel Stenberge9640b62000-08-02 07:17:56 +0000303 a URL to transfer to/from even when doing custom FTP commands.
304
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000305 3.5. How can I disable the Pragma: nocache header?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000306
307 You can change all internally generated headers by adding a replacement with
308 the -H/--header option. By adding a header with empty contents you safely
309 disable that one. Use -H "Pragma:" to disable that specific header.
310
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000311 3.6. Does curl support javascript, ASP, XML, XHTML or HTML version Y?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000312
313 To curl, all contents are alike. It doesn't matter how the page was
Daniel Stenberg4c485992001-04-22 15:45:27 +0000314 generated. It may be ASP, PHP, Perl, shell-script, SSI or plain
Daniel Stenberge9640b62000-08-02 07:17:56 +0000315 HTML-files. There's no difference to curl and it doesn't even know what kind
316 of language that generated the page.
317
318 Javascript is slightly different since that is code embedded in the HTML
319 that is sent for the client to interpret and curl has no javascript
320 interpreter.
321
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000322 3.7. Can I use curl to delete/rename a file through FTP?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000323
Daniel Stenberg4c485992001-04-22 15:45:27 +0000324 Yes. You specify custom FTP commands with -Q/--quote.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000325
326 One example would be to delete a file after you have downloaded it:
327
328 curl -O ftp://download.com/coolfile -Q '-DELE coolfile'
329
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000330 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000331
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000332 Curl does not follow so-called redirects by default. The Location: header
333 that informs the client about this is only interpreted if you're using the
334 -L/--location option. As in:
Daniel Stenberge9640b62000-08-02 07:17:56 +0000335
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000336 curl -L http://redirector.com
337
Daniel Stenbergdfdf4912001-12-21 09:20:04 +0000338 3.9 How do I use curl in my favourite programming language?
Daniel Stenberg368e3522001-01-29 10:16:21 +0000339
Daniel Stenbergdfdf4912001-12-21 09:20:04 +0000340 There exist many language interfaces/bindings for curl that integrates it
341 better with various languages. If you are fluid in a script language, you
342 may very well opt to use such an interface instead of using the command line
343 tool.
Daniel Stenberg4c485992001-04-22 15:45:27 +0000344
345 At the time of writing, there are bindings for the five language mentioned
346 above, but chances are there are even more by the time you read this. Or you
Daniel Stenbergcab90bf2001-05-30 08:01:35 +0000347 may be able you write your own wrapper for a not-yet supported language!
Daniel Stenberg4c485992001-04-22 15:45:27 +0000348
349 Find out more about which languages that support curl directly, and how to
350 install and use them, in the libcurl section of the curl web site:
351
352 http://curl.haxx.se/libcurl/
Daniel Stenberg368e3522001-01-29 10:16:21 +0000353
Daniel Stenbergdfdf4912001-12-21 09:20:04 +0000354 In December 2001, there are interfaces available for the following
355 languages: C/C++, Cocoa, Dylan, Java, Perl, PHP, Python, Rexx, Ruby, Scheme
356 and Tcl. By the time you read this, additional ones may have appeared!
Daniel Stenberg368e3522001-01-29 10:16:21 +0000357
Daniel Stenberg147a6732001-03-08 09:25:09 +0000358 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000359
360 Curl adheres to the HTTP spec, which basically means you can play with *any*
Daniel Stenberg4c485992001-04-22 15:45:27 +0000361 protocol that is built on top of HTTP. Protocols such as SOAP, WEBDAV and
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000362 XML-RPC are all such ones. You can use -X to set custom requests and -H to
363 set custom headers (or replace internally generated ones).
364
365 Using libcurl or PHP's curl modules is just as fine and you'd just use the
366 proper library options to do the same.
367
Daniel Stenberg88d14e92001-05-29 14:02:20 +0000368 3.11 How do I POST with a different Content-Type?
369
370 You can always replace the internally generated headers with -H/--header.
371 To make a simple HTTP POST with text/xml as content-type, do something like:
372
373 curl -d "datatopost" -H "Content-Type: text/xml" [URL]
374
Daniel Stenberg50e9f8f2001-10-23 10:12:28 +0000375 3.12 Why do FTP specific features over HTTP proxy fail?
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000376
377 Because when you use a HTTP proxy, the protocol spoken on the network will
378 be HTTP, even if you specify a FTP URL. This effectively means that you
379 normally can't use FTP specific features such as ftp upload and ftp quote
380 etc.
381
382 There is one exception to this rule, and that is if you can "tunnel through"
Daniel Stenberg271f96f2001-11-20 08:03:01 +0000383 the given HTTP proxy. Proxy tunneling is enabled with a special option (-p)
Daniel Stenberg97a8c982001-12-21 08:10:34 +0000384 and is generally not available as proxy admins usually disable tunneling to
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000385 other ports than 443 (which is used for HTTPS access through proxies).
386
Daniel Stenbergc3318b42000-08-17 14:06:42 +00003874. Running Problems
388
389 4.1. Problems connecting to SSL servers.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000390
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000391 It took a very long time before we could sort out why curl had problems to
392 connect to certain SSL servers when using SSLeay or OpenSSL v0.9+. The
393 error sometimes showed up similar to:
Daniel Stenberge9640b62000-08-02 07:17:56 +0000394
395 16570:error:1407D071:SSL routines:SSL2_READ:bad mac decode:s2_pkt.c:233:
396
397 It turned out to be because many older SSL servers don't deal with SSLv3
398 requests properly. To correct this problem, tell curl to select SSLv2 from
399 the command line (-2/--sslv2).
400
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000401 There has also been examples where the remote server didn't like the SSLv2
Daniel Stenberge9640b62000-08-02 07:17:56 +0000402 request and instead you had to force curl to use SSLv3 with -3/--sslv3.
403
Daniel Stenberge26ee092001-01-15 10:26:37 +0000404 4.2. Why do I get problems when I use & or % in the URL?
Daniel Stenberg29470102000-06-02 13:32:01 +0000405
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000406 In general unix shells, the & letter is treated special and when used, it
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000407 runs the specified command in the background. To safely send the & as a part
Daniel Stenberg4c485992001-04-22 15:45:27 +0000408 of a URL, you should quote the entire URL by using single (') or double (")
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000409 quotes around it.
Daniel Stenberg29470102000-06-02 13:32:01 +0000410
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000411 An example that would invoke a remote CGI that uses &-letters could be:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000412
Daniel Stenbergedcd5df2000-06-06 14:13:36 +0000413 curl 'http://www.altavista.com/cgi-bin/query?text=yes&q=curl'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000414
Daniel Stenberge26ee092001-01-15 10:26:37 +0000415 In win32, the standard DOS shell treats the %-letter specially and you may
416 need to quote the string properly when % is used in it.
417
Daniel Stenberg1b77c182001-01-29 10:24:51 +0000418 Also note that if you want the literal %-letter to be part of the data you
419 pass in a POST using -d/--data you must encode it as '%25'.
420
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000421 4.3. How can I use {, }, [ or ] to specify multiple URLs?
Daniel Stenberg29470102000-06-02 13:32:01 +0000422
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000423 Because those letters have a special meaning to the shell, and to be used in
424 a URL specified to curl you must quote them.
Daniel Stenberg29470102000-06-02 13:32:01 +0000425
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000426 An example that downloads two URLs (sequentially) would do:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000427
Daniel Stenbergedcd5df2000-06-06 14:13:36 +0000428 curl '{curl,www}.haxx.se'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000429
Daniel Stenberge26ee092001-01-15 10:26:37 +0000430 To be able to use those letters as actual parts of the URL (without using
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000431 them for the curl URL "globbing" system), use the -g/--globoff option (curl
432 7.6 and later):
Daniel Stenberge26ee092001-01-15 10:26:37 +0000433
434 curl -g 'www.site.com/weirdname[].html'
435
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000436 4.4. Why do I get downloaded data even though the web page doesn't exist?
Daniel Stenberg29470102000-06-02 13:32:01 +0000437
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000438 Curl asks remote servers for the page you specify. If the page doesn't exist
439 at the server, the HTTP protocol defines how the server should respond and
440 that means that headers and a "page" will be returned. That's simply how
441 HTTP works.
Daniel Stenberg29470102000-06-02 13:32:01 +0000442
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000443 By using the --fail option you can tell curl explicitly to not get any data
444 if the HTTP return code doesn't say success.
Daniel Stenberg8f037322000-06-06 14:09:01 +0000445
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000446 4.5 Why do I get return code XXX from a HTTP server?
Daniel Stenberg29470102000-06-02 13:32:01 +0000447
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000448 RFC2616 clearly explains the return codes. This is a short transcript. Go
449 read the RFC for exact details:
Daniel Stenberg29470102000-06-02 13:32:01 +0000450
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000451 4.5.1 "400 Bad Request"
Daniel Stenberg29470102000-06-02 13:32:01 +0000452
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000453 The request could not be understood by the server due to malformed
454 syntax. The client SHOULD NOT repeat the request without modifications.
455
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000456 4.5.2 "401 Unauthorized"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000457
458 The request requires user authentication.
459
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000460 4.5.3 "403 Forbidden"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000461
462 The server understood the request, but is refusing to fulfill it.
463 Authorization will not help and the request SHOULD NOT be repeated.
464
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000465 4.5.4 "404 Not Found"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000466
467 The server has not found anything matching the Request-URI. No indication
468 is given of whether the condition is temporary or permanent.
469
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000470 4.5.5 "405 Method Not Allowed"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000471
472 The method specified in the Request-Line is not allowed for the resource
473 identified by the Request-URI. The response MUST include an Allow header
474 containing a list of valid methods for the requested resource.
475
Daniel Stenbergd60029d2001-12-19 23:25:04 +0000476 4.5.6 "301 Moved Permanently"
477
478 If you get this return code and an HTML outpt similar to this:
479
480 <H1>Moved Permanently</H1> The document has moved <A
481 HREF="http://same_url_now_with_a_trailing_slash/">here</A>.
482
483 it might be because you request a directory URL but without the trailing
484 slash. Try the same operation again _with_ the trailing URL, or use the
485 -L/--location option to follow the redirection.
486
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000487 4.6. Can you tell me what error code 142 means?
Daniel Stenberg29470102000-06-02 13:32:01 +0000488
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000489 All error codes that are larger than the highest documented error code means
Daniel Stenberg13bf9642001-08-23 11:11:13 +0000490 that curl has exited due to a crash. This is a serious error, and we
Daniel Stenberg25fe47f2001-11-14 20:13:38 +0000491 appreciate a detailed bug report from you that describes how we could go
Daniel Stenberg13bf9642001-08-23 11:11:13 +0000492 ahead and repeat this!
Daniel Stenberg29470102000-06-02 13:32:01 +0000493
Daniel Stenberg4c485992001-04-22 15:45:27 +0000494 4.7. How do I keep user names and passwords secret in Curl command lines?
Daniel Stenberg29470102000-06-02 13:32:01 +0000495
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000496 This problem has two sides:
Daniel Stenberg29470102000-06-02 13:32:01 +0000497
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000498 The first part is to avoid having clear-text passwords in the command line
499 so that they don't appear in 'ps' outputs and similar. That is easily
Daniel Stenberg4c485992001-04-22 15:45:27 +0000500 avoided by using the "-K" option to tell curl to read parameters from a
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000501 file or stdin to which you can pass the secret info.
Daniel Stenberg29470102000-06-02 13:32:01 +0000502
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000503 To keep the passwords in your account secret from the rest of the world is
504 not a task that curl addresses. You could of course encrypt them somehow to
505 at least hide them from being read by human eyes, but that is not what
506 anyone would call security.
Daniel Stenberg29470102000-06-02 13:32:01 +0000507
Daniel Stenberg887e7282001-01-03 09:13:07 +0000508 Also note that regular HTTP and FTP passwords are sent in clear across the
509 network. All it takes for anyone to fetch them is to listen on the network.
Daniel Stenberg4c485992001-04-22 15:45:27 +0000510 Eavesdropping is very easy.
Daniel Stenberg887e7282001-01-03 09:13:07 +0000511
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000512 4.8 I found a bug!
513
Daniel Stenberg4c485992001-04-22 15:45:27 +0000514 It is not a bug if the behavior is documented. Read the docs first.
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000515
516 If it is a problem with a binary you've downloaded or a package for your
517 particular platform, try contacting the person who built the package/archive
518 you have.
519
520 If there is a bug, post a bug report in the Curl Bug Track System over at
Daniel Stenberg9012f8c2001-01-15 10:28:41 +0000521 http://sourceforge.net/bugs/?group_id=976
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000522
523 Always include as many details you can think of, including curl version,
524 operating system name and version and complete instructions how to repeat
525 the bug.
526
Daniel Stenberg2c100372000-12-19 07:30:51 +0000527 4.9. Curl can't authenticate to the server that requires NTLM?
528
529 NTLM is a Microsoft proprietary protocol. Unfortunately, curl does not
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000530 currently support that. Proprietary formats are evil. You should not use
531 such ones.
Daniel Stenberg29470102000-06-02 13:32:01 +0000532
Daniel Stenbergc3318b42000-08-17 14:06:42 +00005335. libcurl Issues
Daniel Stenberg29470102000-06-02 13:32:01 +0000534
Daniel Stenberg7d09e512001-01-11 12:52:07 +0000535 5.1. Is libcurl thread-safe?
Daniel Stenberg29470102000-06-02 13:32:01 +0000536
Daniel Stenberg7d09e512001-01-11 12:52:07 +0000537 Yes.
538
539 We have written the libcurl code specificly adjusted for multi-threaded
540 programs. libcurl will use thread-safe functions instead of non-safe ones if
541 your system has such.
Daniel Stenberg29470102000-06-02 13:32:01 +0000542
Daniel Stenberg4c485992001-04-22 15:45:27 +0000543 We would appreciate some kind of report or README file from those who have
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000544 used libcurl in a threaded environment.
Daniel Stenberg29470102000-06-02 13:32:01 +0000545
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000546 5.2 How can I receive all data into a large memory chunk?
547
Daniel Stenberga84af982001-05-15 13:09:27 +0000548 [ See also the examples/getinmemory.c source ]
549
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000550 You are in full control of the callback function that gets called every time
551 there is data received from the remote server. You can make that callback do
Daniel Stenberg4c485992001-04-22 15:45:27 +0000552 whatever you want. You do not have to write the received data to a file.
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000553
554 One solution to this problem could be to have a pointer to a struct that you
555 pass to the callback function. You set the pointer using the
556 curl_easy_setopt(CURLOPT_FILE) function. Then that pointer will be passed to
557 the callback instead of a FILE * to a file:
558
559 /* imaginary struct */
560 struct MemoryStruct {
561 char *memory;
562 size_t size;
563 };
564
565 /* imaginary callback function */
566 size_t
567 WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
568 {
569 register int realsize = size * nmemb;
570 struct MemoryStruct *mem = (struct MemoryStruct *)data;
571
572 mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
573 if (mem->memory) {
574 memcpy(&(mem->memory[mem->size]), ptr, realsize);
575 mem->size += realsize;
576 mem->memory[mem->size] = 0;
577 }
578 return realsize;
579 }
580
Daniel Stenberg2c100372000-12-19 07:30:51 +0000581 5.3 How do I fetch multiple files with libcurl?
Daniel Stenbergec5ac822000-12-14 08:37:09 +0000582
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000583 Starting with version 7.7, curl and libcurl will have excellent support for
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000584 transferring multiple files. You should just repeatedly set new URLs with
585 curl_easy_setopt() and then transfer it with curl_easy_perform(). The handle
586 you get from curl_easy_init() is not only reusable starting with libcurl
587 7.7, but also you're encouraged to reuse it if you can, as that will enable
Daniel Stenberg4c485992001-04-22 15:45:27 +0000588 libcurl to use persistent connections.
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000589
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000590 For libcurl prior to 7.7, there was no multiple file support. The only
591 available way to do multiple requests was to init/perform/cleanup for each
592 transfer.
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000593
Daniel Stenbergbc5954f2001-03-23 08:16:24 +0000594 5.4 Does libcurl do Winsock initialization on win32 systems?
Daniel Stenberg910fc852000-12-30 11:48:51 +0000595
Daniel Stenberg6d213e22001-11-01 14:51:02 +0000596 Yes (since 7.8.1) if told to in the curl_global_init() call.
Daniel Stenberg910fc852000-12-30 11:48:51 +0000597
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000598 5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ?
Daniel Stenberg41084e52001-01-22 08:42:00 +0000599
600 Yes, but you cannot open a FILE * and pass the pointer to a DLL and have
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000601 that DLL use the FILE *. If you set CURLOPT_FILE you must also use
602 CURLOPT_WRITEFUNCTION as well to set a function that writes the file, even
603 if that simply writes the data to the specified FILE*. Similarly, if you use
604 CURLOPT_INFILE you must also specify CURLOPT_READFUNCTION.
Daniel Stenberg41084e52001-01-22 08:42:00 +0000605
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000606 (Provided by Joel DeYoung and Bob Schader)
Daniel Stenberg41084e52001-01-22 08:42:00 +0000607
Daniel Stenberg4c485992001-04-22 15:45:27 +0000608 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +0000609
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000610 Starting with version 7.7, curl and libcurl will have excellent support for
Daniel Stenberg4c485992001-04-22 15:45:27 +0000611 persistent connections when transferring several files from the same server.
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000612 Curl will attempt to reuse connections for all URLs specified on the same
613 command line/config file, and libcurl will reuse connections for all
614 transfers that are made using the same libcurl handle.
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000615
Daniel Stenberg4c485992001-04-22 15:45:27 +0000616 Previous versions had no persistent connection support.
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +0000617
Daniel Stenbergc3318b42000-08-17 14:06:42 +00006186. License Issues
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000619
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000620 Curl and libcurl are released under a MIT/X derivate license *or* the MPL,
621 the Mozilla Public License. To get a really good answer to your license
622 conflict questions, you should study the MPL and MIT/X licenses and the
623 license you are about to use and check for clashes yourself. This section is
624 just a brief summary for the cases we get the most questions. (Parts of this
625 section was much enhanced by Bjorn Reese.)
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000626
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000627 6.1. I have a GPL program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000628
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000629 Yes!
Daniel Stenberg7d1ef962000-08-14 06:31:59 +0000630
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000631 Since libcurl may be distributed under the MIT/X derivate license, it can be
632 used together with GPL in any software.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000633
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000634 6.2. I have a closed-source program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000635
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000636 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000637
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000638 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000639
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000640 6.3. I have a BSD licensed program, can I use the libcurl library?
641
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000642 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000643
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000644 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000645
646 6.4. I have a program that uses LGPL libraries, can I use libcurl?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000647
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000648 Yes!
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000649
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000650 The LGPL license doesn't clash with other licenses.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000651
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000652 6.5. Can I modify curl/libcurl for my program and keep the changes secret?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000653
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000654 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000655
656 The MIT/X derivate license practically allows you to do almost anything with
657 the sources, on the condition that the copyright texts in the sources are
658 left intact.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000659
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000660 6.6. Can you please change the curl/libcurl license to XXXX?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000661
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000662 No.
663
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000664 We have carefully picked this license after years of development and
665 discussions and a large amount of people have contributed with source code
666 knowing that this is the license we use. This license puts the restrictions
667 we want on curl/libcurl and it does not spread to other programs or
668 libraries that use it. The recent dual license modification should make it
669 possible for everyone to use libcurl or curl in their projects, no matter
670 what license they already have in use.