Curl manual
curl – transfer a URL

curl [options] [URL…]
curl is a client to get documents/files from or send documents to a server, using any of the supported protocols
(HTTP, HTTPS, FTP, GOPHER, DICT, TELNET, LDAP or FILE). The command is designed to work
without user interaction or any kind of interactivity.
curl offers a busload of useful tricks like proxy support, user authentication, ftp upload, HTTP post, SSL
(https:) connections, cookies, file transfer resume and more.

We can specify any amount of URLs on the command line. They will be fetched in a sequential manner in
the specified order.
Curl will attempt to re-use connections for multiple file transfers, so that getting many files from the same
server will not do multiple connects / handshakes. This improves speed. Of course this is only done on files
specified on a single command line and cannot be used between separate curl invokes.

(FTP) When used in a ftp upload, this will tell curl to append to the target file instead of overwriting
it. If the file doesn’t exist, it will be created.
If this option is used twice, the second one will disable append mode again.
-A/–user-agent <agent string>

(HTTP) Specify the User-Agent string to send to the HTTP server. Some badly done CGIs fail if
its not set to “Mozilla/4.0”. To encode blanks in the string, surround the string with single quote
marks. This can also be set with the -H/–header flag of course.
If this option is set more than once, the last one will be the one that’s used.
-b/–cookie <name=data>
(HTTP) Pass the data to the HTTP server as a cookie. It is supposedly the data previously received
from the server in a “Set-Cookie:” line. The data should be in the format “NAME1=VALUE1;
If no ’=’ letter is used in the line, it is treated as a filename to use to read previously stored cookie
lines from, which should be used in this session if they match. Using this method also activates the
“cookie parser” which will make curl record incoming cookies too, which may be handy if you’re
using this in combination with the -L/–location option. The file format of the file to read cookies
from should be plain HTTP headers or the Netscape/Mozilla cookie file format.
NOTE that the file specified with -b/–cookie is only used as input. No cookies will be stored in
the file. To store cookies, save the HTTP headers to a file using -D/–dump-header!
If this option is set more than once, the last one will be the one that’s used.
Use ASCII transfer when getting an FTP file or LDAP info. For FTP, this can also be enforced by
using an URL that ends with “;type=A”. This option causes data sent to stdout to be in text mode
for win32 systems.
If this option is used twice, the second one will disable ASCII usage.
–ciphers <list of ciphers>
(SSL) Specifies which ciphers to use in the connection. The list of ciphers must be using valid
ciphers. Read up on SSL cipher list details on this URL:
If this option is used several times, the last one will override the others.
–connect-timeout <seconds>
Maximum time in seconds that you allow the connection to the server to take. This only limits the
connection phase, once curl has connected this option is of no more use. See also the –max-time
If this option is used several times, the last one will be used.
-c/–cookie-jar <file name>
Specify to which file you want curl to write all cookies after a completed operation. Curl writes all
cookies previously read from a specified file as well as all cookies received from remote server(s).
If no cookies are known, no file will be written. The file will be written using the Netscape cookie
file format. If you set the file name to a single dash, “-“, the cookies will be written to stdout.

If this option is used several times, the last specfied file name will be used.
-C/–continue-at <offset>
Continue/Resume a previous file transfer at the given offset. The given offset is the exact number
of bytes that will be skipped counted from the beginning of the source file before it is transfered to
the destination. If used with uploads, the ftp server command SIZE will not be used by curl.
Use “-C -” to tell curl to automatically find out where/how to resume the transfer. It then uses the
given output/input files to figure that out.
If this option is used several times, the last one will be used.
–crlf (FTP) Convert LF to CRLF in upload. Useful for MVS (OS/390).
If this option is used twice, the second will again disable crlf converting.
-d/–data <data>
(HTTP) Sends the specified data in a POST request to the HTTP server, in a way that can emulate
as if a user has filled in a HTML form and pressed the submit button. Note that the data is sent
exactly as specified with no extra processing (with all newlines cut off). The data is expected to be
“url-encoded”. This will cause curl to pass the data to the server using the content-type

Available variables in curl:
url_effective:The URL that was fetched last. This is mostly meaningful if you’ve told curl to
follow location: headers

http_code  :The numerical code that was found in the last retrieved HTTP(S) page.
time_pretransfer :The time, in seconds, it took from the start until the file transfer is just about to begin. This includes all        pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.
The time, in seconds, it took from the start until the first byte is just about to be
transfered. This includes time_pretransfer and also the time the server needs to
calculate the result.
size_download: The total amount of bytes that were downloaded.
size_upload: The total amount of bytes that were uploaded.
size_header: The total amount of bytes of the downloaded headers.
size_request: The total amount of bytes that were sent in the HTTP request.
speed_download: The average download speed that curl measured for the complete download.
speed_upload: The average upload speed that curl measured for the complete upload.
content_type :The Content-Type of the requested document, if there was any.

time_total : The total time, in seconds, that the full operation lasted. The time will be displayed
with millisecond resolution.
time_namelookup :The time, in seconds, it took from the start until the name resolving was completed.
time_connect  :The time, in seconds, it took from the start until the connect to the remote host
(or proxy) was completed.

EXIT CODES in curl
There exists a bunch of different error codes and their corresponding error messages that may appear during
bad conditions. At the time of this writing, the exit codes are:
1 Unsupported protocol. This build of curl has no support for this protocol.
2 Failed to initialize.
3 URL malformat. The syntax was not correct.
4 URL user malformatted. The user-part of the URL syntax was not correct.
5 Couldn’t resolve proxy. The given proxy host could not be resolved.
6 Couldn’t resolve host. The given remote host was not resolved.
7 Failed to connect to host.
8 FTP weird server reply. The server sent data curl couldn’t parse.
9 FTP access denied. The server denied login.
10 FTP user/password incorrect. Either one or both were not accepted by the server.
11 FTP weird PASS reply. Curl couldn’t parse the reply sent to the PASS request.
12 FTP weird USER reply. Curl couldn’t parse the reply sent to the USER request.
13 FTP weird PASV reply, Curl couldn’t parse the reply sent to the PASV request.
14 FTP weird 227 format. Curl couldn’t parse the 227-line the server sent.
15 FTP can’t get host. Couldn’t resolve the host IP we got in the 227-line.
16 FTP can’t reconnect. Couldn’t connect to the host we got in the 227-line.
17 FTP couldn’t set binary. Couldn’t change transfer method to binary.
18 Partial file. Only a part of the file was transfered.
19 FTP couldn’t RETR file. The RETR command failed.
20 FTP write error. The transfer was reported bad by the server.
21 FTP quote error. A quote command returned error from the server.
22 HTTP not found. The requested page was not found. This return code only appears if –fail is used.
23 Write error. Curl couldn’t write data to a local filesystem or similar.
24 Malformat user. User name badly specified.
25 FTP couldn’t STOR file. The server denied the STOR operation.
26 Read error. Various reading problems.
27 Out of memory. A memory allocation request failed.
28 Operation timeout. The specified time-out period was reached according to the conditions.
29 FTP couldn’t set ASCII. The server returned an unknown reply.
30 FTP PORT failed. The PORT command failed.
31 FTP couldn’t use REST. The REST command failed.
32 FTP couldn’t use SIZE. The SIZE command failed. The command is an extension to the original
FTP spec RFC 959.
33 HTTP range error. The range “command” didn’t work.
34 HTTP post error. Internal post-request generation error.
35 SSL connect error. The SSL handshaking failed.
36 FTP bad download resume. Couldn’t continue an earlier aborted download.
37 FILE couldn’t read file. Failed to open the file. Permissions?
38 LDAP cannot bind. LDAP bind operation failed.
39 LDAP search failed.
40 Library not found. The LDAP library was not found.
41 Function not found. A required LDAP function was not found.
42 Aborted by callback. An application told curl to abort the operation.
43 Internal error. A function was called with a bad parameter.
44 Internal error. A function was called in a bad order.
45 Interface error. A specified outgoing interface could not be used.
46 Bad password entered. An error was signaled when the password was entered.
47 Too many redirects. When following redirects, curl hit the maximum amount.
48 Unknown TELNET option specified.
49 Malformed telnet option.
51 The remote peer’s SSL certificate wasn’t ok
52 The server didn’t reply anything, which here is considered an error.
53 SSL crypto engine not found
54 Cannot set SSL crypto engine as default
55 Failed sending network data
56 Failure in receiving network data
57 Share is in use (internal error)
58 Problem with the local certificate
59 Couldn’t use specified SSL cipher
60 Problem with the CA cert (path? permission?)
61 Unrecognized transfer encoding
XX There will appear more error codes here in future releases. The existing ones are meant to never

How to use curl language