remove docs and tests from our in tree libcurl. You will need to do a fresh bootstrap or autoreconf -fi in the libs/curl directory.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4915 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
f4820a6b31
commit
36055cf98d
|
@ -29,13 +29,12 @@ EXTRA_DIST = CHANGES COPYING maketgz reconf Makefile.dist curl-config.in \
|
|||
bin_SCRIPTS = curl-config
|
||||
|
||||
SUBDIRS = lib src
|
||||
DIST_SUBDIRS = $(SUBDIRS) tests include packages docs
|
||||
DIST_SUBDIRS = $(SUBDIRS) include packages
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libcurl.pc
|
||||
|
||||
dist-hook:
|
||||
rm -rf $(top_builddir)/tests/log
|
||||
find $(distdir) -name "*.dist" -exec rm {} \;
|
||||
(distit=`find $(srcdir) -name "*.dist"`; \
|
||||
for file in $$distit; do \
|
||||
|
@ -43,88 +42,11 @@ dist-hook:
|
|||
cp $$file $(distdir)$$strip; \
|
||||
done)
|
||||
|
||||
html:
|
||||
cd docs; make html
|
||||
|
||||
pdf:
|
||||
cd docs; make pdf
|
||||
|
||||
check: test
|
||||
|
||||
if CROSSCOMPILING
|
||||
test-full: test
|
||||
test-torture: test
|
||||
|
||||
test:
|
||||
@echo "NOTICE: we can't run the tests when cross-compiling!"
|
||||
|
||||
else
|
||||
|
||||
test:
|
||||
@(cd tests; $(MAKE) all quiet-test)
|
||||
|
||||
test-full:
|
||||
@(cd tests; $(MAKE) all full-test)
|
||||
|
||||
test-torture:
|
||||
@(cd tests; $(MAKE) all torture-test)
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# Build source and binary rpms. For rpm-3.0 and above, the ~/.rpmmacros
|
||||
# must contain the following line:
|
||||
# %_topdir /home/loic/local/rpm
|
||||
# and that /home/loic/local/rpm contains the directory SOURCES, BUILD etc.
|
||||
#
|
||||
# cd /home/loic/local/rpm ; mkdir -p SOURCES BUILD RPMS/i386 SPECS SRPMS
|
||||
#
|
||||
# If additional configure flags are needed to build the package, add the
|
||||
# following in ~/.rpmmacros
|
||||
# %configure CFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{_prefix} ${AM_CONFIGFLAGS}
|
||||
# and run make rpm in the following way:
|
||||
# AM_CONFIGFLAGS='--with-uri=/home/users/loic/local/RedHat-6.2' make rpm
|
||||
#
|
||||
|
||||
rpms:
|
||||
$(MAKE) RPMDIST=curl rpm
|
||||
$(MAKE) RPMDIST=curl-ssl rpm
|
||||
|
||||
rpm:
|
||||
RPM_TOPDIR=`rpm --showrc | $(PERL) -n -e 'print if(s/.*_topdir\s+(.*)/$$1/)'` ; \
|
||||
cp $(srcdir)/packages/Linux/RPM/$(RPMDIST).spec $$RPM_TOPDIR/SPECS ; \
|
||||
cp $(PACKAGE)-$(VERSION).tar.gz $$RPM_TOPDIR/SOURCES ; \
|
||||
rpm -ba --clean --rmsource $$RPM_TOPDIR/SPECS/$(RPMDIST).spec ; \
|
||||
mv $$RPM_TOPDIR/RPMS/i386/$(RPMDIST)-*.rpm . ; \
|
||||
mv $$RPM_TOPDIR/SRPMS/$(RPMDIST)-*.src.rpm .
|
||||
|
||||
#
|
||||
# Build a Solaris pkkgadd format file
|
||||
# run 'make pkgadd' once you've done './configure' and 'make' to make a Solaris pkgadd format
|
||||
# file (which ends up back in this directory).
|
||||
# The pkgadd file is in 'pkgtrans' format, so to install on Solaris, do
|
||||
# pkgadd -d ./HAXXcurl-*
|
||||
#
|
||||
|
||||
# gak - libtool requires an absoulte directory, hence the pwd below...
|
||||
pkgadd:
|
||||
umask 022 ; \
|
||||
make install DESTDIR=`/bin/pwd`/packages/Solaris/root ; \
|
||||
cat COPYING > $(srcdir)/packages/Solaris/copyright ; \
|
||||
cd $(srcdir)/packages/Solaris && $(MAKE) package
|
||||
|
||||
#
|
||||
# Build a cygwin binary tarball installation file
|
||||
# resulting .tar.bz2 file will end up at packages/Win32/cygwin
|
||||
cygwinbin:
|
||||
$(MAKE) -C packages/Win32/cygwin cygwinbin
|
||||
|
||||
# We extend the standard install with a custom hook:
|
||||
install-data-hook:
|
||||
cd include && $(MAKE) install
|
||||
cd docs && $(MAKE) install
|
||||
|
||||
# We extend the standard uninstall with a custom hook:
|
||||
uninstall-hook:
|
||||
cd include && $(MAKE) uninstall
|
||||
cd docs && $(MAKE) uninstall
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ terms of the curl license; see COPYING for more details])
|
|||
|
||||
AC_CONFIG_SRCDIR([lib/urldata.h])
|
||||
AM_CONFIG_HEADER(lib/config.h src/config.h)
|
||||
AM_MAINTAINER_MODE
|
||||
#AM_MAINTAINER_MODE
|
||||
|
||||
dnl SED is needed by some of the tools
|
||||
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
|
||||
|
@ -2038,17 +2038,10 @@ fi
|
|||
AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes)
|
||||
|
||||
AC_CONFIG_FILES([Makefile \
|
||||
docs/Makefile \
|
||||
docs/examples/Makefile \
|
||||
docs/libcurl/Makefile \
|
||||
include/Makefile \
|
||||
include/curl/Makefile \
|
||||
src/Makefile \
|
||||
lib/Makefile \
|
||||
tests/Makefile \
|
||||
tests/data/Makefile \
|
||||
tests/server/Makefile \
|
||||
tests/libtest/Makefile \
|
||||
packages/Makefile \
|
||||
packages/Win32/Makefile \
|
||||
packages/Win32/cygwin/Makefile \
|
||||
|
|
|
@ -1,190 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
libcurl bindings
|
||||
|
||||
Creative people have written bindings or interfaces for various environments
|
||||
and programming languages. Using one of these allows you to take advantage of
|
||||
curl powers from within your favourite language or system.
|
||||
|
||||
This is a list of all known interfaces as of this writing.
|
||||
|
||||
The bindings listed below are not part of the curl/libcurl distribution
|
||||
archives, but must be downloaded and installed separately.
|
||||
|
||||
Ada95
|
||||
|
||||
Writtten by Andreas Almroth
|
||||
http://www.almroth.com/adacurl/index.html
|
||||
|
||||
Basic
|
||||
|
||||
ScriptBasic bindings to libcurl. Writtten by Peter Verhas
|
||||
http://scriptbasic.com/
|
||||
|
||||
C
|
||||
libcurl is a C library in itself!
|
||||
http://curl.haxx.se/libcurl/
|
||||
|
||||
C++
|
||||
|
||||
Written by Jean-Philippe Barrette-LaPierre
|
||||
http://rrette.com/curlpp.html
|
||||
|
||||
Ch
|
||||
|
||||
Written by Stephen Nestinger and Jonathan Rogado
|
||||
http://chcurl.sourceforge.net/
|
||||
|
||||
Cocoa
|
||||
|
||||
Written by Dan Wood
|
||||
http://curlhandle.sourceforge.net/
|
||||
|
||||
D
|
||||
|
||||
Written by Kenneth Bogert
|
||||
http://curl.haxx.se/libcurl/d/
|
||||
|
||||
Dylan
|
||||
|
||||
Written by Chris Double
|
||||
http://dylanlibs.sourceforge.net/
|
||||
|
||||
Euphoria
|
||||
|
||||
Written by Ray Smith
|
||||
http://rays-web.com/eulibcurl.htm
|
||||
|
||||
Ferite
|
||||
Written by Paul Querna
|
||||
http://www.ferite.org/
|
||||
|
||||
Gambas
|
||||
http://gambas.sourceforge.net
|
||||
|
||||
glib/GTK+
|
||||
Written by Richard Atterer
|
||||
http://atterer.net/glibcurl/
|
||||
|
||||
Java
|
||||
|
||||
Maintained by Vic Hanson
|
||||
http://curl.haxx.se/libcurl/java/
|
||||
|
||||
Lisp
|
||||
|
||||
Written by Liam Healy
|
||||
http://common-lisp.net/project/cl-curl/
|
||||
|
||||
Lua
|
||||
|
||||
LuaCURL Written by Alexander Marinov
|
||||
http://luacurl.luaforge.net/
|
||||
|
||||
Mono
|
||||
|
||||
Written by Jeffrey Phillips
|
||||
http://forge.novell.com/modules/xfmod/project/?libcurl-mono
|
||||
|
||||
.NET
|
||||
|
||||
libcurl-net Written by Jeffrey Phillips
|
||||
http://sourceforge.net/projects/libcurl-net/
|
||||
|
||||
Object-Pascal
|
||||
|
||||
Free Pascal, Delphi and Kylix binding written by Christophe Espern.
|
||||
http://www.tekool.com/opcurl
|
||||
|
||||
O'Caml
|
||||
|
||||
Written by Lars Nilsson
|
||||
http://sourceforge.net/projects/ocurl/
|
||||
|
||||
Pascal
|
||||
|
||||
Free Pascal, Delphi and Kylix binding written by Jeffrey Pohlmeyer.
|
||||
http://houston.quik.com/jkp/curlpas/
|
||||
|
||||
Perl
|
||||
|
||||
Maintained by Cris Bailiff
|
||||
http://curl.haxx.se/libcurl/perl/
|
||||
|
||||
PHP
|
||||
|
||||
Written by Sterling Hughes
|
||||
http://curl.haxx.se/libcurl/php/
|
||||
|
||||
PostgreSQL
|
||||
|
||||
Written by Gian Paolo Ciceri
|
||||
http://gborg.postgresql.org/project/pgcurl/projdisplay.php
|
||||
|
||||
Python
|
||||
|
||||
PycURL is written by Kjetil Jacobsen
|
||||
http://pycurl.sourceforge.net/
|
||||
|
||||
R
|
||||
|
||||
RCurl is written by Duncan Temple Lang
|
||||
http://www.omegahat.org/RCurl/
|
||||
|
||||
Rexx
|
||||
|
||||
Written Mark Hessling
|
||||
http://rexxcurl.sourceforge.net/
|
||||
|
||||
Ruby
|
||||
|
||||
Written by Hirotaka Matsuyuki
|
||||
http://www.d1.dion.ne.jp/~matuyuki/ruby.html
|
||||
|
||||
Scheme
|
||||
|
||||
Bigloo binding written by Kirill Lisovsky
|
||||
http://curl.haxx.se/libcurl/scheme/
|
||||
|
||||
S-Lang
|
||||
|
||||
S-Lang binding written by John E Davis
|
||||
http://www.jedsoft.org/slang/modules/curl.html
|
||||
|
||||
Smalltalk
|
||||
|
||||
Smalltalk binding written by Danil Osipchuk
|
||||
http://www.squeaksource.com/CurlPlugin/
|
||||
|
||||
SPL
|
||||
|
||||
SPL binding written by Clifford Wolf
|
||||
http://www.clifford.at/spl/
|
||||
|
||||
Tcl
|
||||
|
||||
Tclcurl is written by Andrés García
|
||||
http://personal1.iddeo.es/andresgarci/tclcurl/english/docs.html
|
||||
|
||||
Visual Basic
|
||||
|
||||
libcurl-vb is written by Jeffrey Phillips
|
||||
http://sourceforge.net/projects/libcurl-vb/
|
||||
|
||||
Q
|
||||
The libcurl module is part of the default install
|
||||
http://q-lang.sourceforge.net/
|
||||
|
||||
wxWidgets
|
||||
|
||||
Written by Casey O'Donnell
|
||||
http://homepage.mac.com/codonnell/wxcurldav/
|
||||
|
||||
XBLite
|
||||
|
||||
Written by David Szafranski
|
||||
http://perso.wanadoo.fr/xblite/libraries.html
|
|
@ -1,81 +0,0 @@
|
|||
$Id: BUGS,v 1.7 2003/08/18 15:24:46 bagder Exp $
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
BUGS
|
||||
|
||||
Curl and libcurl have grown substantially since the beginning. At the time
|
||||
of writing (August 2003), there are about 40000 lines of source code, and by
|
||||
the time you read this it has probably grown even more.
|
||||
|
||||
Of course there are lots of bugs left. And lots of misfeatures.
|
||||
|
||||
To help us make curl the stable and solid product we want it to be, we need
|
||||
bug reports and bug fixes.
|
||||
|
||||
WHERE TO REPORT
|
||||
|
||||
If you can't fix a bug yourself and submit a fix for it, try to report an as
|
||||
detailed report as possible to a curl mailing list to allow one of us to
|
||||
have a go at a solution. You should also post your bug/problem at curl's bug
|
||||
tracking system over at
|
||||
|
||||
http://sourceforge.net/bugs/?group_id=976
|
||||
|
||||
(but please read the sections below first before doing that)
|
||||
|
||||
If you feel you need to ask around first, find a suitable mailing list and
|
||||
post there. The lists are available on http://curl.haxx.se/mail/
|
||||
|
||||
WHAT TO REPORT
|
||||
|
||||
When reporting a bug, you should include all information that will help us
|
||||
understand what's wrong, what you expected to happen and how to repeat the
|
||||
bad behavior. You therefore need to tell us:
|
||||
|
||||
- your operating system's name and version number (uname -a under a unix
|
||||
is fine)
|
||||
- what version of curl you're using (curl -V is fine)
|
||||
- what URL you were working with (if possible), at least which protocol
|
||||
|
||||
and anything and everything else you think matters. Tell us what you
|
||||
expected to happen, tell use what did happen, tell us how you could make it
|
||||
work another way. Dig around, try out, test. Then include all the tiny bits
|
||||
and pieces in your report. You will benefit from this yourself, as it will
|
||||
enable us to help you quicker and more accurately.
|
||||
|
||||
Since curl deals with networks, it often helps us if you include a protocol
|
||||
debug dump with your bug report. The output you get by using the -v or
|
||||
--trace options.
|
||||
|
||||
If curl crashed, causing a core dump (in unix), there is hardly any use to
|
||||
send that huge file to anyone of us. Unless we have an exact same system
|
||||
setup as you, we can't do much with it. Instead we ask you to get a stack
|
||||
trace and send that (much smaller) output to us instead!
|
||||
|
||||
The address and how to subscribe to the mailing lists are detailed in the
|
||||
MANUAL file.
|
||||
|
||||
HOW TO GET A STACK TRACE
|
||||
|
||||
First, you must make sure that you compile all sources with -g and that you
|
||||
don't 'strip' the final executable. Try to avoid optimizing the code as
|
||||
well, remove -O, -O2 etc from the compiler options.
|
||||
|
||||
Run the program until it cores.
|
||||
|
||||
Run your debugger on the core file, like '<debugger> curl core'. <debugger>
|
||||
should be replaced with the name of your debugger, in most cases that will
|
||||
be 'gdb', but 'dbx' and others also occur.
|
||||
|
||||
When the debugger has finished loading the core file and presents you a
|
||||
prompt, enter 'where' (without the quotes) and press return.
|
||||
|
||||
The list that is presented is the stack trace. If everything worked, it is
|
||||
supposed to contain the chain of functions that were called when curl
|
||||
crashed. Include the stack trace with your detailed bug report. It'll help a
|
||||
lot.
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
When Contributing Source Code
|
||||
|
||||
This document is intended to offer guidelines that can be useful to keep in
|
||||
mind when you decide to contribute to the project. This concerns new features
|
||||
as well as corrections to existing flaws or bugs.
|
||||
|
||||
Join the Community
|
||||
|
||||
Skip over to http://curl.haxx.se/mail/ and join the appropriate mailing
|
||||
list(s). Read up on details before you post questions. Read this file before
|
||||
you start sending patches! We prefer patches and discussions being held on
|
||||
the mailing list(s), not sent to individuals.
|
||||
|
||||
The License Issue
|
||||
|
||||
When contributing with code, you agree to put your changes and new code under
|
||||
the same license curl and libcurl is already using unless stated and agreed
|
||||
otherwise.
|
||||
|
||||
If you add a larger piece of code, you can opt to make that file or set of
|
||||
files to use a different license as long as they don't enforce any changes to
|
||||
the rest of the package and they make sense. Such "separate parts" can not be
|
||||
GPL licensed (as we don't want copyleft to affect users of libcurl) but they
|
||||
must use "GPL compatible" licenses (as we want to allow users to use libcurl
|
||||
properly in GPL licensed environments).
|
||||
|
||||
When changing existing source code, you do not alter the copyright of the
|
||||
original file(s). The copyright will still be owned by the original
|
||||
creator(s) or those who have been assigned copyright by the original
|
||||
author(s).
|
||||
|
||||
By submitting a patch to the curl project, you are assumed to have the right
|
||||
to the code and to be allowed by your employer or whatever to hand over that
|
||||
patch/code to us. We will credit you for your changes as far as possible, to
|
||||
give credit but also to keep a trace back to who made what changes. Please
|
||||
always provide us with your full real name when contributing!
|
||||
|
||||
What To Read
|
||||
|
||||
Source code, the man pages, the INTERNALS document, the TODO, the most recent
|
||||
CHANGES. Just lurking on the libcurl mailing list is gonna give you a lot of
|
||||
insights on what's going on right now. Asking there is a good idea too.
|
||||
|
||||
Naming
|
||||
|
||||
Try using a non-confusing naming scheme for your new functions and variable
|
||||
names. It doesn't necessarily have to mean that you should use the same as in
|
||||
other places of the code, just that the names should be logical,
|
||||
understandable and be named according to what they're used for. File-local
|
||||
functions should be made static. We like lower case names.
|
||||
|
||||
See the INTERNALS document on how we name non-exported library-global
|
||||
symbols.
|
||||
|
||||
Indenting
|
||||
|
||||
Please try using the same indenting levels and bracing method as all the
|
||||
other code already does. It makes the source code a lot easier to follow if
|
||||
all of it is written using the same style. We don't ask you to like it, we
|
||||
just ask you to follow the tradition! ;-) This mainly means: 2-level indents,
|
||||
using spaces only (no tabs) and having the opening brace ({) on the same line
|
||||
as the if() or while().
|
||||
|
||||
Commenting
|
||||
|
||||
Comment your source code extensively using C comments (/* comment */), DO NOT
|
||||
use C++ comments (// this style). Commented code is quality code and enables
|
||||
future modifications much more. Uncommented code risk having to be completely
|
||||
replaced when someone wants to extend things, since other persons' source
|
||||
code can get quite hard to read.
|
||||
|
||||
General Style
|
||||
|
||||
Keep your functions small. If they're small you avoid a lot of mistakes and
|
||||
you don't accidentally mix up variables etc.
|
||||
|
||||
Non-clobbering All Over
|
||||
|
||||
When you write new functionality or fix bugs, it is important that you don't
|
||||
fiddle all over the source files and functions. Remember that it is likely
|
||||
that other people have done changes in the same source files as you have and
|
||||
possibly even in the same functions. If you bring completely new
|
||||
functionality, try writing it in a new source file. If you fix bugs, try to
|
||||
fix one bug at a time and send them as separate patches.
|
||||
|
||||
Platform Dependent Code
|
||||
|
||||
Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
|
||||
particular operating systems or hardware in the #ifdef lines. The
|
||||
HAVE_FEATURE shall be generated by the configure script for unix-like systems
|
||||
and they are hard-coded in the config-[system].h files for the others.
|
||||
|
||||
Separate Patches
|
||||
|
||||
It is annoying when you get a huge patch from someone that is said to fix 511
|
||||
odd problems, but discussions and opinions don't agree with 510 of them - or
|
||||
509 of them were already fixed in a different way. Then the patcher needs to
|
||||
extract the single interesting patch from somewhere within the huge pile of
|
||||
source, and that gives a lot of extra work. Preferably, all fixes that
|
||||
correct different problems should be in their own patch with an attached
|
||||
description exactly what they correct so that all patches can be selectively
|
||||
applied by the maintainer or other interested parties.
|
||||
|
||||
Patch Against Recent Sources
|
||||
|
||||
Please try to get the latest available sources to make your patches
|
||||
against. It makes the life of the developers so much easier. The very best is
|
||||
if you get the most up-to-date sources from the CVS repository, but the
|
||||
latest release archive is quite OK as well!
|
||||
|
||||
Document
|
||||
|
||||
Writing docs is dead boring and one of the big problems with many open source
|
||||
projects. Someone's gotta do it. It makes it a lot easier if you submit a
|
||||
small description of your fix or your new features with every contribution so
|
||||
that it can be swiftly added to the package documentation.
|
||||
|
||||
The documentation is always made in man pages (nroff formatted) or plain
|
||||
ASCII files. All HTML files on the web site and in the release archives are
|
||||
generated from the nroff/ASCII versions.
|
||||
|
||||
Write Access to CVS Repository
|
||||
|
||||
If you are a frequent contributor, or have another good reason, you can of
|
||||
course get write access to the CVS repository and then you'll be able to
|
||||
check-in all your changes straight into the CVS tree instead of sending all
|
||||
changes by mail as patches. Just ask if this is what you'd want. You will be
|
||||
required to have posted a few quality patches first, before you can be
|
||||
granted write access.
|
||||
|
||||
Test Cases
|
||||
|
||||
Since the introduction of the test suite, we can quickly verify that the main
|
||||
features are working as they're supposed to. To maintain this situation and
|
||||
improve it, all new features and functions that are added need to be tested
|
||||
in the test suite. Every feature that is added should get at least one valid
|
||||
test case that verifies that it works as documented. If every submitter also
|
||||
posts a few test cases, it won't end up as a heavy burden on a single person!
|
||||
|
||||
How To Make a Patch
|
||||
|
||||
Keep a copy of the unmodified curl sources. Make your changes in a separate
|
||||
source tree. When you think you have something that you want to offer the
|
||||
curl community, use GNU diff to generate patches.
|
||||
|
||||
If you have modified a single file, try something like:
|
||||
|
||||
diff -u unmodified-file.c my-changed-one.c > my-fixes.diff
|
||||
|
||||
If you have modified several files, possibly in different directories, you
|
||||
can use diff recursively:
|
||||
|
||||
diff -ur curl-original-dir curl-modified-sources-dir > my-fixes.diff
|
||||
|
||||
The GNU diff and GNU patch tools exist for virtually all platforms, including
|
||||
all kinds of Unixes and Windows:
|
||||
|
||||
For unix-like operating systems:
|
||||
|
||||
http://www.fsf.org/software/patch/patch.html
|
||||
http://www.gnu.org/directory/diffutils.html
|
||||
|
||||
For Windows:
|
||||
|
||||
http://gnuwin32.sourceforge.net/packages/patch.htm
|
||||
http://gnuwin32.sourceforge.net/packages/diffutils.htm
|
|
@ -1,211 +0,0 @@
|
|||
Date: May 15, 2006
|
||||
Author: Daniel Stenberg <daniel@haxx.se>
|
||||
URL: http://curl.haxx.se/legal/distro-dilemma.html
|
||||
|
||||
Condition
|
||||
|
||||
This document is written to describe the situation as it is right
|
||||
now. libcurl 7.15.3 is currently the latest version available. Things may of
|
||||
course change in the future.
|
||||
|
||||
This document reflects my view and understanding of these things. Please tell
|
||||
me where and how you think I'm wrong, and I'll try to correct my mistakes.
|
||||
|
||||
Background
|
||||
|
||||
The Free Software Foundation has deemed the Original BSD license[1] to be
|
||||
"incompatible"[2] with GPL[3]. I'd rather say it is the other way around, but
|
||||
the point is the same: if you distribute a binary version of a GPL program,
|
||||
it MUST NOT be linked with any Original BSD-licensed parts or libraries.
|
||||
Doing so will violate the GPL license. For a long time, very many GPL
|
||||
licensed programs have avoided this license mess by adding an exception[8] to
|
||||
their license. And many others have just closed their eyes for this problem.
|
||||
|
||||
libcurl is MIT-style[4] licensed - how on earth did this dilemma fall onto
|
||||
our plates?
|
||||
|
||||
libcurl is only a little library. libcurl can be built to use OpenSSL for its
|
||||
SSL/TLS capabilities. OpenSSL is basically Original BSD licensed[5].
|
||||
|
||||
If libcurl built to use OpenSSL is used by a GPL-licensed application and you
|
||||
decide to distribute a binary version of it (Linux distros - for example -
|
||||
tend to), you have a clash. GPL vs Original BSD.
|
||||
|
||||
This dilemma is not libcurl-specific nor is it specific to any particular
|
||||
Linux distro. (This article mentions and refers to Debian several times, but
|
||||
only because Debian seems to be the only Linux distro to have faced this
|
||||
issue yet since no other distro is shipping libcurl built with two SSL
|
||||
libraries.)
|
||||
|
||||
Part of the Operating System
|
||||
|
||||
This would not be a problem if the used lib would be considered part of the
|
||||
underlying operating system, as then the GPL license has an exception
|
||||
clause[6] that allows applications to use such libs without having to be
|
||||
allowed to distribute it or its sources. Possibly some distros will claim
|
||||
that OpenSSL is part of their operating system.
|
||||
|
||||
Debian does however not take this stance and has officially(?) claimed that
|
||||
OpenSSL is not a required part of the Debian operating system
|
||||
|
||||
GnuTLS
|
||||
|
||||
With the release of libcurl 7.14.0 (May 2005), libcurl can now get built to
|
||||
use GnuTLS instead of OpenSSL. GnuTLS is an LGPL[7] licensed library that
|
||||
offers a matching set of features as OpenSSL does. Now, you can build and
|
||||
distribute an TLS/SSL capable libcurl without including any Original BSD
|
||||
licensed code.
|
||||
|
||||
I believe Debian is the first distro to provide libcurl/GnutTLS packages.
|
||||
|
||||
GnuTLS vs OpenSSL
|
||||
|
||||
While these two libraries offer similar features, they are not equal. Both
|
||||
libraries have features the other one lacks. libcurl does not (yet) offer a
|
||||
standardized stable ABI if you decide to switch from using libcurl-openssl to
|
||||
libcurl-gnutls or vice versa. The GnuTLS support is very recent in libcurl
|
||||
and it has not been tested nor used very extensively, while the OpenSSL
|
||||
equivalent code has been used and thus matured for more than seven (7) years.
|
||||
|
||||
GnuTLS
|
||||
- LGPL licensened
|
||||
- supports SRP
|
||||
- lacks SSLv2 support
|
||||
- lacks MD2 support (used by at least some CA certs)
|
||||
- lacks the crypto functions libcurl uses for NTLM
|
||||
|
||||
OpenSSL
|
||||
- Original BSD licensened
|
||||
- lacks SRP
|
||||
- supports SSLv2
|
||||
- older and more widely used
|
||||
- provides crypto functions libcurl uses for NTLM
|
||||
- libcurl can do non-blocking connects with it in 7.15.4 and later
|
||||
|
||||
The Better License, Original BSD or LGPL?
|
||||
|
||||
It isn't obvious or without debate to any objective interested party that
|
||||
either of these licenses are the "better" or even the "preferred" one in a
|
||||
generic situation.
|
||||
|
||||
Instead, I think we should accept the fact that the SSL/TLS libraries and
|
||||
their different licenses will fit different applications and their authors
|
||||
differently depending on the applications' licenses and their general usage
|
||||
pattern (considering how LGPL libraries for example can be burdensome for
|
||||
embedded systems usage).
|
||||
|
||||
In Debian land, there seems to be a common opinion that LGPL is "maximally
|
||||
compatible" with apps while Original BSD is not. Like this:
|
||||
|
||||
http://lists.debian.org/debian-devel/2005/09/msg01417.html
|
||||
|
||||
More SSL Libraries
|
||||
|
||||
In libcurl, there's no stopping us here. There are at least a few more Open
|
||||
Source/Free SSL/TLS libraries and we would very much like to support them as
|
||||
well, to offer application authors an even wider scope of choice.
|
||||
|
||||
Application Angle of this Problem
|
||||
|
||||
libcurl is built to use one SSL/TLS library. It uses a single fixed name (by
|
||||
default) on the built/created lib file, and applications are built/linked to
|
||||
use that single lib. Replacing one libcurl instance with another one that
|
||||
uses the other SSL/TLS library might break one or more applications (due to
|
||||
ABI differences and/or different feature set). You want your application to
|
||||
use the libcurl it was built for.
|
||||
|
||||
Project cURL Angle of this Problem
|
||||
|
||||
We distribute libcurl and everyone may build libcurl with either library at
|
||||
their choice. This problem is not directly a problem of ours. It merely
|
||||
affects users - GPL application authors only - of our lib as it comes
|
||||
included and delivered on some distros.
|
||||
|
||||
libcurl has different ABI when built with different SSL/TLS libraries due to
|
||||
these reasons:
|
||||
|
||||
1. No one has worked on fixing this. The mutex/lock callbacks should be set
|
||||
with a generic libcurl function that should use the proper underlying
|
||||
functions.
|
||||
|
||||
2. The CURLOPT_SSL_CTX_FUNCTION option is not possible to "emulate" on GnuTLS
|
||||
but simply requires OpenSSL.
|
||||
|
||||
3. There might be some other subtle differences just because nobody has yet
|
||||
tried to make a fixed ABI like this.
|
||||
|
||||
Distro Angle of this Problem
|
||||
|
||||
To my knowledge there is only one distro that ships libcurl built with either
|
||||
one of the SSL libs supported.
|
||||
|
||||
Debian Linux is now (since mid September 2005) providing two different
|
||||
libcurl packages, one for libcurl built with OpenSSL and one built with
|
||||
GnuTLS. They use different .so names and can this both be installed in a
|
||||
single system simultaneously. This has been said to be a transitional system
|
||||
not desired to keep in the long run.
|
||||
|
||||
Fixing the Only Problem
|
||||
|
||||
The only problem is thus for distributions that want to offer libcurl
|
||||
versions built with more than one SSL/TLS library.
|
||||
|
||||
Since multiple libcurl binaries using different names are ruled out, we need
|
||||
to come up with a way to have one single libcurl that someone uses different
|
||||
underlying libraries. The best(?) approach currently suggested involves this:
|
||||
|
||||
A new intermediate library (named lib2 so far in the discussions) with the
|
||||
single purpose of providing libcurl with SSL/TLS capabilities. It would have
|
||||
a unified API and ABI no matter what underlying library it would use.
|
||||
|
||||
There would be one lib2 binary provided for each supported SSL/TLS library.
|
||||
For example: lib2-openssl, lib2-gnutls, lib2-yassl, lib2-matrixssl and
|
||||
lib2-nossl. Yes, take note of the last one that provides the lib2 ABI but
|
||||
that lacks the actual powers.
|
||||
|
||||
When libcurl is built and linked, it will be linked against a lib2 with the
|
||||
set ABI.
|
||||
|
||||
When you link an app against libcurl, it would also need to provide one of
|
||||
the (many) lib2 libs to decide what approach that fits the app. An app that
|
||||
doesn't want SSL at all would still need to link with the lib2-nossl lib.
|
||||
|
||||
GPL apps can pick the lib2-gnutls, others may pick the lib2-openssl.
|
||||
|
||||
This concept works equally well both for shared and static libraries.
|
||||
|
||||
A positive side effect of this approach could be a more generic "de facto"
|
||||
standard API for SSL/TLS libraries.
|
||||
|
||||
When Will This Happen
|
||||
|
||||
This is not a problem in curl, it doesn't solve any actual technical problems
|
||||
in our project. Don't hold your breath for this to happen very soon (if at
|
||||
all) unless you step forward and contribute.
|
||||
|
||||
The suggestion that is outlined above is still only a suggestion. Feel free
|
||||
to bring a better idea!
|
||||
|
||||
Also, to keep in mind: I don't want this new concept to have too much of an
|
||||
impact on the existing code. Preferably it should be possible to build the
|
||||
code like today (without the use of lib2), should you decide to ignore the
|
||||
problems outlined in this document.
|
||||
|
||||
Work on this was suggested by Richard Atterer:
|
||||
|
||||
http://curl.haxx.se/mail/lib-2005-09/0066.html
|
||||
|
||||
Footnotes
|
||||
|
||||
[1] = http://www.xfree86.org/3.3.6/COPYRIGHT2.html#6
|
||||
[2] = http://www.fsf.org/licensing/essays/bsd.html
|
||||
[3] = http://www.fsf.org/licensing/licenses/gpl.html
|
||||
[4] = http://curl.haxx.se/docs/copyright.html
|
||||
[5] = http://www.openssl.org/source/license.html
|
||||
[6] = http://www.fsf.org/licensing/licenses/gpl.html end of section 3
|
||||
[7] = http://www.fsf.org/licensing/licenses/lgpl.html
|
||||
[8] = http://en.wikipedia.org/wiki/OpenSSL_exception
|
||||
|
||||
Feedback/Updates provided by
|
||||
|
||||
Eric Cooper
|
1113
libs/curl/docs/FAQ
1113
libs/curl/docs/FAQ
File diff suppressed because it is too large
Load Diff
|
@ -1,125 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
FEATURES
|
||||
|
||||
curl tool
|
||||
- config file support
|
||||
- multiple URLs in a single command line
|
||||
- range "globbing" support: [0-13], {one,two,three}
|
||||
- multiple file upload on a single command line
|
||||
- custom maximum transfer rate
|
||||
- redirectable stderr
|
||||
|
||||
libcurl supports
|
||||
- full URL syntax with no length limit
|
||||
- custom maximum download time
|
||||
- custom least download speed acceptable
|
||||
- custom output result after completion
|
||||
- guesses protocol from host name unless specified
|
||||
- uses .netrc
|
||||
- progress bar/time specs while downloading
|
||||
- "standard" proxy environment variables support
|
||||
- compiles on win32 (reported builds on 40+ operating systems)
|
||||
- selectable network interface for outgoing traffic
|
||||
- IPv6 support on unix and Windows
|
||||
- persistant connections
|
||||
- socks5 support
|
||||
- supports user name + password in proxy environment variables
|
||||
- operations through proxy "tunnel" (using CONNECT)
|
||||
- supports large files (>2GB and >4GB) both upload/download
|
||||
- replacable memory functions (malloc, free, realloc, etc)
|
||||
- asynchronous name resolving (*6)
|
||||
|
||||
HTTP
|
||||
- HTTP/1.1 compliant (optionally uses 1.0)
|
||||
- GET
|
||||
- PUT
|
||||
- HEAD
|
||||
- POST
|
||||
- multipart formpost (RFC1867-style)
|
||||
- authentication: Basic, Digest, NTLM(*1), GSS-Negotiate/Negotiate(*3) and
|
||||
SPNEGO (*4) to server and proxy
|
||||
- resume (both GET and PUT)
|
||||
- follow redirects
|
||||
- maximum amount of redirects to follow
|
||||
- custom HTTP request
|
||||
- cookie get/send fully parsed
|
||||
- reads/writes the netscape cookie file format
|
||||
- custom headers (replace/remove internally generated headers)
|
||||
- custom user-agent string
|
||||
- custom referer string
|
||||
- range
|
||||
- proxy authentication
|
||||
- time conditions
|
||||
- via http-proxy
|
||||
- retrieve file modification date
|
||||
- Content-Encoding support for deflate and gzip
|
||||
- "Transfer-Encoding: chunked" support for "uploads"
|
||||
|
||||
HTTPS (*1)
|
||||
- (all the HTTP features)
|
||||
- using client certificates
|
||||
- verify server certificate
|
||||
- via http-proxy
|
||||
- select desired encryption
|
||||
- force usage of a specific SSL version (SSLv2(*7), SSLv3 or TLSv1)
|
||||
|
||||
FTP
|
||||
- download
|
||||
- authentication
|
||||
- kerberos4 (*5)
|
||||
- active/passive using PORT, EPRT, PASV or EPSV
|
||||
- single file size information (compare to HTTP HEAD)
|
||||
- 'type=' URL support
|
||||
- dir listing
|
||||
- dir listing names-only
|
||||
- upload
|
||||
- upload append
|
||||
- upload via http-proxy as HTTP PUT
|
||||
- download resume
|
||||
- upload resume
|
||||
- custom ftp commands (before and/or after the transfer)
|
||||
- simple "range" support
|
||||
- via http-proxy
|
||||
- all operations can be tunneled through a http-proxy
|
||||
- customizable to retrieve file modification date
|
||||
- no dir depth limit
|
||||
|
||||
FTPS (*1)
|
||||
- implicit ftps:// support that use SSL on both connections
|
||||
- explicit "AUTH TSL" and "AUTH SSL" usage to "upgrade" plain ftp://
|
||||
connection to use SSL for both or one of the connections
|
||||
|
||||
TFTP
|
||||
- download / upload
|
||||
|
||||
TELNET
|
||||
- connection negotiation
|
||||
- custom telnet options
|
||||
- stdin/stdout I/O
|
||||
|
||||
LDAP (*2)
|
||||
- full LDAP URL support
|
||||
|
||||
DICT
|
||||
- extended DICT URL support
|
||||
|
||||
FILE
|
||||
- URL support
|
||||
- "uploads"
|
||||
- resume
|
||||
|
||||
FOOTNOTES
|
||||
=========
|
||||
|
||||
*1 = requires OpenSSL or GnuTLS
|
||||
*2 = requires OpenLDAP
|
||||
*3 = requires a GSSAPI-compliant library, such as Heimdal or similar.
|
||||
*4 = requires FBopenssl
|
||||
*5 = requires a krb4 library, such as the MIT one or similar.
|
||||
*6 = requires c-ares
|
||||
*7 = requires OpenSSL specificly, as GnuTLS only supports SSLv3 and TLSv1
|
|
@ -1,153 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
How cURL Became Like This
|
||||
|
||||
|
||||
In the second half of 1997, Daniel Stenberg came up with the idea to make
|
||||
currency-exchange calculations available to Internet Relay Chat (IRC)
|
||||
users. All the necessary data are published on the Web; he just needed to
|
||||
automate their retrieval.
|
||||
|
||||
Daniel simply adopted an existing command-line open-source tool, httpget, that
|
||||
Brazilian Rafael Sagula had written. After a few minor adjustments, it did
|
||||
just what he needed.
|
||||
|
||||
Soon, he found currencies on a GOPHER site, so support for that had to go in,
|
||||
and not before long FTP download support was added as well. The name of the
|
||||
project was changed to urlget to better fit what it actually did now, since
|
||||
the http-only days were already passed.
|
||||
|
||||
The project slowly grew bigger. When upload capabilities were added and the
|
||||
name once again was misleading, a second name change was made and on March 20,
|
||||
1998 curl 4 was released. (The version numbering from the previous names was
|
||||
kept.)
|
||||
|
||||
(Unrelated to this project a company called Curl Corporation registered a US
|
||||
trademark on the name "CURL" on May 18 1998. That company had then already
|
||||
registered the curl.com domain back in November of the previous year. All this
|
||||
was revealed to us much later.)
|
||||
|
||||
SSL support was added, powered by the SSLeay library.
|
||||
|
||||
August 1998, first announcement of curl on freshmeat.net.
|
||||
|
||||
October 1998, with the curl 4.9 release and the introduction of cookie
|
||||
support, curl was no longer released under the GPL license. Now we're at 4000
|
||||
lines of code, we switched over to the MPL license to restrict the effects of
|
||||
"copyleft".
|
||||
|
||||
November 1998, configure script and reported successful compiles on several
|
||||
major operating systems. The never-quite-understood -F option was added and
|
||||
curl could now simulate quite a lot of a browser. TELNET support was added.
|
||||
|
||||
Curl 5 was released in December 1998 and introduced the first ever curl man
|
||||
page. People started making Linux RPM packages out of it.
|
||||
|
||||
January 1999, DICT support added.
|
||||
|
||||
OpenSSL took over where SSLeay was abandoned.
|
||||
|
||||
May 1999, first Debian package.
|
||||
|
||||
August 1999, LDAP:// and FILE:// support added. The curl web site gets 1300
|
||||
visits weekly.
|
||||
|
||||
Released curl 6.0 in September. 15000 lines of code.
|
||||
|
||||
December 28 1999, added the project on Sourceforge and started using its
|
||||
services for managing the project.
|
||||
|
||||
Spring 2000, major internal overhaul to provide a suitable library interface.
|
||||
The first non-beta release was named 7.1 and arrived in August. This offered
|
||||
the easy interface and turned out to be the beginning of actually getting
|
||||
other software and programs to get based on and powered by libcurl. Almost
|
||||
20000 lines of code.
|
||||
|
||||
August 2000, the curl web site gets 4000 visits weekly.
|
||||
|
||||
The PHP guys adopted libcurl already the same month, when the first ever third
|
||||
party libcurl binding showed up. CURL has been a supported module in PHP since
|
||||
the release of PHP 4.0.2. This would soon get followers. More than 16
|
||||
different bindings exist at the time of this writing.
|
||||
|
||||
September 2000, kerberos4 support was added.
|
||||
|
||||
In November 2000 started the work on a test suite for curl. It was later
|
||||
re-written from scratch again.
|
||||
|
||||
January 2001, Daniel released curl 7.5.2 under a new license again: MIT (or
|
||||
MPL). The MIT license is extremely liberal and can be used combined with GPL
|
||||
in other projects. This would finally put an end to the "complaints" from
|
||||
people involved in GPLed projects that previously were prohibited from using
|
||||
libcurl while it was released under MPL only. (Due to the fact that MPL is
|
||||
deemed "GPL incompatible".)
|
||||
|
||||
curl supports HTTP 1.1 starting with the release of 7.7, March 22 2001. This
|
||||
also introduced libcurl's ability to do persistent connections. 24000 lines of
|
||||
code.
|
||||
|
||||
The first experimental ftps:// support was added in March 2001.
|
||||
|
||||
August 2001. curl is bundled in Mac OS X, 10.1. It was already becoming more
|
||||
and more of a standard utility of Linux distributions and a regular in the BSD
|
||||
ports collections. The curl web site gets 8000 visits weekly. Curl Corporation
|
||||
contacted Daniel to discuss "the name issue". After Daniel's reply, they have
|
||||
never since got in touch again.
|
||||
|
||||
September 2001, libcurl 7.9 introduces cookie jar and curl_formadd(). During
|
||||
the forthcoming 7.9.x releases, we introduced the multi interface slowly and
|
||||
without much whistles.
|
||||
|
||||
June 2002, the curl web site gets 13000 visits weekly. curl and libcurl is
|
||||
35000 lines of code. Reported successful compiles on more than 40 combinations
|
||||
of CPUs and operating systems.
|
||||
|
||||
To estimate number of users of the curl tool or libcurl library is next to
|
||||
impossible. Around 5000 downloaded packages each week from the main site gives
|
||||
a hint, but the packages are mirrored extensively, bundled with numerous OS
|
||||
distributions and otherwise retrieved as part of other software.
|
||||
|
||||
September 2002, with the release of curl 7.10 it is released under the MIT
|
||||
license only.
|
||||
|
||||
January 2003. Started working on the distributed curl tests. The autobuilds.
|
||||
|
||||
February 2003, the curl site averages at 20000 visits weekly. At any given
|
||||
moment, there's an average of 3 people browsing the curl.haxx.se site.
|
||||
|
||||
Multiple new authentication schemes are supported: Digest (May), NTLM (June)
|
||||
and Negotiate (June).
|
||||
|
||||
November 2003: curl 7.10.8 is released. 45000 lines of code. ~55000 unique
|
||||
visitors to the curl.haxx.se site. Five official web mirrors.
|
||||
|
||||
December 2003, full-fledged SSL for FTP is supported.
|
||||
|
||||
January 2004: curl 7.11.0 introduced large file support.
|
||||
|
||||
June 2004: curl 7.12.0 introduced IDN support. 10 official web mirrors.
|
||||
|
||||
August 2004:
|
||||
Curl and libcurl 7.12.1
|
||||
|
||||
Public curl release number: 82
|
||||
Releases counted from the very beginning: 109
|
||||
Available command line options: 96
|
||||
Available curl_easy_setopt() options: 120
|
||||
Number of public functions in libcurl: 36
|
||||
Amount of public web site mirrors: 12
|
||||
Number of known libcurl bindings: 26
|
||||
|
||||
April 2005:
|
||||
|
||||
GnuTLS can now optionally be used for the secure layer when curl is built.
|
||||
|
||||
September 2005:
|
||||
|
||||
TFTP support was added.
|
||||
|
||||
More than 100,000 unique visitors of the curl web site. 25 mirrors.
|
|
@ -1,719 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
How To Compile
|
||||
|
||||
Installing Binary Packages
|
||||
==========================
|
||||
|
||||
Lots of people download binary distributions of curl and libcurl. This
|
||||
document does not describe how to install curl or libcurl using such a
|
||||
binary package. This document describes how to compile, build and install
|
||||
curl and libcurl from source code.
|
||||
|
||||
UNIX
|
||||
====
|
||||
A normal unix installation is made in three or four steps (after you've
|
||||
unpacked the source archive):
|
||||
|
||||
./configure
|
||||
make
|
||||
make test (optional)
|
||||
make install
|
||||
|
||||
You probably need to be root when doing the last command.
|
||||
|
||||
If you have checked out the sources from the CVS repository, read the
|
||||
CVS-INFO on how to proceed.
|
||||
|
||||
Get a full listing of all available configure options by invoking it like:
|
||||
|
||||
./configure --help
|
||||
|
||||
If you want to install curl in a different file hierarchy than /usr/local,
|
||||
you need to specify that already when running configure:
|
||||
|
||||
./configure --prefix=/path/to/curl/tree
|
||||
|
||||
If you happen to have write permission in that directory, you can do 'make
|
||||
install' without being root. An example of this would be to make a local
|
||||
install in your own home directory:
|
||||
|
||||
./configure --prefix=$HOME
|
||||
make
|
||||
make install
|
||||
|
||||
The configure script always tries to find a working SSL library unless
|
||||
explicitly told not to. If you have OpenSSL installed in the default search
|
||||
path for your compiler/linker, you don't need to do anything special. If
|
||||
you have OpenSSL installed in /usr/local/ssl, you can run configure like:
|
||||
|
||||
./configure --with-ssl
|
||||
|
||||
If you have OpenSSL installed somewhere else (for example, /opt/OpenSSL,)
|
||||
you can run configure like this:
|
||||
|
||||
./configure --with-ssl=/opt/OpenSSL
|
||||
|
||||
If you insist on forcing a build without SSL support, even though you may
|
||||
have OpenSSL installed in your system, you can run configure like this:
|
||||
|
||||
./configure --without-ssl
|
||||
|
||||
If you have OpenSSL installed, but with the libraries in one place and the
|
||||
header files somewhere else, you have to set the LDFLAGS and CPPFLAGS
|
||||
environment variables prior to running configure. Something like this
|
||||
should work:
|
||||
|
||||
(with the Bourne shell and its clones):
|
||||
|
||||
CPPFLAGS="-I/path/to/ssl/include" LDFLAGS="-L/path/to/ssl/lib" \
|
||||
./configure
|
||||
|
||||
(with csh, tcsh and their clones):
|
||||
|
||||
env CPPFLAGS="-I/path/to/ssl/include" LDFLAGS="-L/path/to/ssl/lib" \
|
||||
./configure
|
||||
|
||||
If you have shared SSL libs installed in a directory where your run-time
|
||||
linker doesn't find them (which usually causes configure failures), you can
|
||||
provide the -R option to ld on some operating systems to set a hard-coded
|
||||
path to the run-time linker:
|
||||
|
||||
LDFLAGS=-R/usr/local/ssl/lib ./configure --with-ssl
|
||||
|
||||
Another option to the previous trick, is to set LD_LIBRARY_PATH or edit the
|
||||
/etc/ld.so.conf file.
|
||||
|
||||
If your SSL library was compiled with rsaref (this was common in the past
|
||||
when used in the United States), you may also need to set:
|
||||
|
||||
LIBS=-lRSAglue -lrsaref
|
||||
(as suggested by Doug Kaufman)
|
||||
|
||||
MORE OPTIONS
|
||||
|
||||
To force configure to use the standard cc compiler if both cc and gcc are
|
||||
present, run configure like
|
||||
|
||||
CC=cc ./configure
|
||||
or
|
||||
env CC=cc ./configure
|
||||
|
||||
To force a static library compile, disable the shared library creation
|
||||
by running configure like:
|
||||
|
||||
./configure --disable-shared
|
||||
|
||||
To tell the configure script to skip searching for thread-safe functions,
|
||||
add an option like:
|
||||
|
||||
./configure --disable-thread
|
||||
|
||||
To build curl with kerberos4 support enabled, curl requires the krb4 libs
|
||||
and headers installed. You can then use a set of options to tell
|
||||
configure where those are:
|
||||
|
||||
--with-krb4-includes[=DIR] Specify location of kerberos4 headers
|
||||
--with-krb4-libs[=DIR] Specify location of kerberos4 libs
|
||||
--with-krb4[=DIR] where to look for Kerberos4
|
||||
|
||||
In most cases, /usr/athena is the install prefix and then it works with
|
||||
|
||||
./configure --with-krb4=/usr/athena
|
||||
|
||||
If you're a curl developer and use gcc, you might want to enable more
|
||||
debug options with the --enable-debug option.
|
||||
|
||||
curl can be built to use a whole range of libraries to provide various
|
||||
useful services, and configure will try to auto-detect a decent
|
||||
default. But if you want to alter it, you can select how to deal with
|
||||
each individual library.
|
||||
|
||||
To build with GnuTLS support instead of OpenSSL for SSL/TLS, note that
|
||||
you need to use both --without-ssl and --with-gnutls.
|
||||
|
||||
To build with yassl support instead of OpenSSL or GunTLS, you must build
|
||||
yassl with its OpenSSL emulation enabled and point to that directory root
|
||||
with configure --with-ssl.
|
||||
|
||||
|
||||
Win32
|
||||
=====
|
||||
|
||||
MingW32
|
||||
-------
|
||||
|
||||
Run the 'mingw32.bat' file to get the proper environment variables set,
|
||||
then run 'make mingw32' in the root dir. Use 'make mingw32-ssl' to build
|
||||
curl SSL enabled.
|
||||
|
||||
If you have any problems linking libraries or finding header files, be sure
|
||||
to verify that the provided "Makefile.m32" files use the proper paths, and
|
||||
adjust as necessary.
|
||||
|
||||
Cygwin
|
||||
------
|
||||
|
||||
Almost identical to the unix installation. Run the configure script in the
|
||||
curl root with 'sh configure'. Make sure you have the sh executable in
|
||||
/bin/ or you'll see the configure fail towards the end.
|
||||
|
||||
Run 'make'
|
||||
|
||||
Dev-Cpp
|
||||
-------
|
||||
|
||||
See the separate INSTALL.devcpp file for details.
|
||||
|
||||
MSVC from command line
|
||||
----------------------
|
||||
|
||||
Run the 'vcvars32.bat' file to get a proper environment. The
|
||||
vcvars32.bat file is part of the Microsoft development environment and
|
||||
you may find it in 'C:\Program Files\Microsoft Visual Studio\vc98\bin'
|
||||
provided that you installed Visual C/C++ 6 in the default directory.
|
||||
|
||||
Then run 'nmake vc' in curl's root directory.
|
||||
|
||||
If you want to compile with zlib support, you will need to build
|
||||
zlib (http://www.gzip.org/zlib/) as well. Please read the zlib
|
||||
documentation on how to compile zlib. Define the ZLIB_PATH environment
|
||||
variable to the location of zlib.h and zlib.lib, for example:
|
||||
|
||||
set ZLIB_PATH=c:\zlib-1.2.1
|
||||
|
||||
Then run 'nmake vc-zlib' in curl's root directory.
|
||||
|
||||
If you want to compile with SSL support you need the OpenSSL package.
|
||||
Please read the OpenSSL documentation on how to compile and install
|
||||
the OpenSSL libraries. The build process of OpenSSL generates the
|
||||
libeay32.dll and ssleay32.dll files in the out32dll subdirectory in
|
||||
the OpenSSL home directory. OpenSSL static libraries (libeay32.lib,
|
||||
ssleay32.lib, RSAglue.lib) are created in the out32 subdirectory.
|
||||
|
||||
Before running nmake define the OPENSSL_PATH environment variable with
|
||||
the root/base directory of OpenSSL, for example:
|
||||
|
||||
set OPENSSL_PATH=c:\openssl-0.9.7d
|
||||
|
||||
Then run 'nmake vc-ssl' or 'nmake vc-ssl-dll' in curl's root
|
||||
directory. 'nmake vc-ssl' will create a libcurl static and dynamic
|
||||
libraries in the lib subdirectory, as well as a statically linked
|
||||
version of curl.exe in the src subdirectory. This statically linked
|
||||
version is a standalone executable not requiring any DLL at
|
||||
runtime. This make method requires that you have the static OpenSSL
|
||||
libraries available in OpenSSL's out32 subdirectory.
|
||||
'nmake vc-ssl-dll' creates the libcurl dynamic library and
|
||||
links curl.exe against libcurl and OpenSSL dynamically.
|
||||
This executable requires libcurl.dll and the OpenSSL DLLs
|
||||
at runtime.
|
||||
Run 'nmake vc-ssl-zlib' to build with both ssl and zlib support.
|
||||
|
||||
Borland C++ compiler
|
||||
---------------------
|
||||
|
||||
compile openssl
|
||||
|
||||
Make sure you include the paths to curl/include and openssl/inc32 in
|
||||
your bcc32.cnf file
|
||||
|
||||
eg : -I"c:\Bcc55\include;c:\path_curl\include;c:\path_openssl\inc32"
|
||||
|
||||
Check to make sure that all of the sources listed in lib/Makefile.b32
|
||||
are present in the /path_to_curl/lib directory. (Check the src
|
||||
directory for missing ones.)
|
||||
|
||||
Make sure the environment variable "BCCDIR" is set to the install
|
||||
location for the compiler eg : c:\Borland\BCC55
|
||||
|
||||
command line:
|
||||
make -f /path_to_curl/lib/Makefile-ssl.b32
|
||||
|
||||
compile simplessl.c with appropriate links
|
||||
|
||||
c:\curl\docs\examples\> bcc32 -L c:\path_to_curl\lib\libcurl.lib
|
||||
-L c:\borland\bcc55\lib\psdk\ws2_32.lib
|
||||
-L c:\openssl\out32\libeay32.lib
|
||||
-L c:\openssl\out32\ssleay32.lib
|
||||
simplessl.c
|
||||
|
||||
|
||||
MSVC IDE
|
||||
--------
|
||||
|
||||
If you use VC++, Borland or similar compilers. Include all lib source
|
||||
files in a static lib "project" (all .c and .h files that is).
|
||||
(you should name it libcurl or similar)
|
||||
|
||||
Make the sources in the src/ drawer be a "win32 console application"
|
||||
project. Name it curl.
|
||||
|
||||
For VC++ 6, there's an included Makefile.vc6 that should be possible
|
||||
to use out-of-the-box.
|
||||
|
||||
|
||||
Disabling Specific Protocols in Win32 builds
|
||||
--------------------------------------------
|
||||
|
||||
The configure utility, unfortunately, is not available for the Windows
|
||||
environment, therefore, you cannot use the various disable-protocol
|
||||
options of the configure utility on this platform.
|
||||
|
||||
However, you can use the following defines to disable specific
|
||||
protocols:
|
||||
|
||||
HTTP_ONLY disables all protocols except HTTP
|
||||
CURL_DISABLE_FTP disables FTP
|
||||
CURL_DISABLE_LDAP disables LDAP
|
||||
CURL_DISABLE_TELNET disables TELNET
|
||||
CURL_DISABLE_DICT disables DICT
|
||||
CURL_DISABLE_FILE disables FILE
|
||||
|
||||
If you want to set any of these defines you have the following
|
||||
possibilities:
|
||||
|
||||
- Modify lib/setup.h
|
||||
- Modify lib/Makefile.vc6
|
||||
- Add defines to Project/Settings/C/C++/General/Preprocessor Definitions
|
||||
in the curllib.dsw/curllib.dsp Visual C++ 6 IDE project.
|
||||
|
||||
|
||||
Important static libcurl usage note
|
||||
-----------------------------------
|
||||
|
||||
When building an application that uses the static libcurl library, you must
|
||||
add '-DCURL_STATICLIB' to your CFLAGS. Otherwise the linker will look for
|
||||
dynamic import symbols.
|
||||
|
||||
|
||||
IBM OS/2
|
||||
========
|
||||
Building under OS/2 is not much different from building under unix.
|
||||
You need:
|
||||
|
||||
- emx 0.9d
|
||||
- GNU make
|
||||
- GNU patch
|
||||
- ksh
|
||||
- GNU bison
|
||||
- GNU file utilities
|
||||
- GNU sed
|
||||
- autoconf 2.13
|
||||
|
||||
If you want to build with OpenSSL or OpenLDAP support, you'll need to
|
||||
download those libraries, too. Dirk Ohme has done some work to port SSL
|
||||
libraries under OS/2, but it looks like he doesn't care about emx. You'll
|
||||
find his patches on: http://come.to/Dirk_Ohme
|
||||
|
||||
If during the linking you get an error about _errno being an undefined
|
||||
symbol referenced from the text segment, you need to add -D__ST_MT_ERRNO__
|
||||
in your definitions.
|
||||
|
||||
If everything seems to work fine but there's no curl.exe, you need to add
|
||||
-Zexe to your linker flags.
|
||||
|
||||
If you're getting huge binaries, probably your makefiles have the -g in
|
||||
CFLAGS.
|
||||
|
||||
|
||||
VMS
|
||||
===
|
||||
(The VMS section is in whole contributed by the friendly Nico Baggus)
|
||||
|
||||
Curl seems to work with FTP & HTTP other protocols are not tested. (the
|
||||
perl http/ftp testing server supplied as testing too cannot work on VMS
|
||||
because vms has no concept of fork(). [ I tried to give it a whack, but
|
||||
thats of no use.
|
||||
|
||||
SSL stuff has not been ported.
|
||||
|
||||
Telnet has about the same issues as for Win32. When the changes for Win32
|
||||
are clear maybe they'll work for VMS too. The basic problem is that select
|
||||
ONLY works for sockets.
|
||||
|
||||
Marked instances of fopen/[f]stat that might become a problem, especially
|
||||
for non stream files. In this regard, the files opened for writing will be
|
||||
created stream/lf and will thus be safe. Just keep in mind that non-binary
|
||||
read/wring from/to files will have a records size limit of 32767 bytes
|
||||
imposed.
|
||||
|
||||
Stat to get the size of the files is again only safe for stream files &
|
||||
fixed record files without implied CC.
|
||||
|
||||
-- My guess is that only allowing access to stream files is the quickest
|
||||
way to get around the most issues. Therefore all files need to to be
|
||||
checked to be sure they will be stream/lf before processing them. This is
|
||||
the easiest way out, I know. The reason for this is that code that needs to
|
||||
report the filesize will become a pain in the ass otherwise.
|
||||
|
||||
Exit status.... Well we needed something done here,
|
||||
|
||||
VMS has a structured exist status:
|
||||
| 3 | 2 | 1 | 0|
|
||||
|1098|765432109876|5432109876543|210|
|
||||
+----+------------+-------------+---+
|
||||
|Ctrl| Facility | Error code |sev|
|
||||
+----+------------+-------------+---+
|
||||
|
||||
With the Ctrl-bits an application can tell if part or the whole message has
|
||||
already been printed from the program, DCL doesn't need to print it again.
|
||||
|
||||
Facility - basically the program ID. A code assigned to the program
|
||||
the name can be fetched from external or internal message libraries
|
||||
Errorcode - the errodes assigned by the application
|
||||
Sev. - severity: Even = error, off = non error
|
||||
0 = Warning
|
||||
1 = Success
|
||||
2 = Error
|
||||
3 = Information
|
||||
4 = Fatal
|
||||
<5-7> reserved.
|
||||
|
||||
This all presents itself with:
|
||||
%<FACILITY>-<SeV>-<Errorname>, <Error message>
|
||||
|
||||
See also the src/curlmsg.msg file, it has the source for the messages In
|
||||
src/main.c a section is devoted to message status values, the globalvalues
|
||||
create symbols with certain values, referenced from a compiled message
|
||||
file. Have all exit function use a exit status derived from a translation
|
||||
table with the compiled message codes.
|
||||
|
||||
This was all compiled with:
|
||||
|
||||
Compaq C V6.2-003 on OpenVMS Alpha V7.1-1H2
|
||||
|
||||
So far for porting notes as of:
|
||||
13-jul-2001
|
||||
N. Baggus
|
||||
|
||||
|
||||
QNX
|
||||
===
|
||||
(This section was graciously brought to us by David Bentham)
|
||||
|
||||
As QNX is targeted for resource constrained environments, the QNX headers
|
||||
set conservative limits. This includes the FD_SETSIZE macro, set by default
|
||||
to 32. Socket descriptors returned within the CURL library may exceed this,
|
||||
resulting in memory faults/SIGSEGV crashes when passed into select(..)
|
||||
calls using fd_set macros.
|
||||
|
||||
A good all-round solution to this is to override the default when building
|
||||
libcurl, by overriding CFLAGS during configure, example
|
||||
# configure CFLAGS='-DFD_SETSIZE=64 -g -O2'
|
||||
|
||||
|
||||
RISC OS
|
||||
=======
|
||||
The library can be cross-compiled using gccsdk as follows:
|
||||
|
||||
CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \
|
||||
--host=arm-riscos-aof --without-random --disable-shared
|
||||
make
|
||||
|
||||
where riscos-gcc and riscos-ar are links to the gccsdk tools.
|
||||
You can then link your program with curl/lib/.libs/libcurl.a
|
||||
|
||||
|
||||
AmigaOS
|
||||
=======
|
||||
(This section was graciously brought to us by Diego Casorran)
|
||||
|
||||
To build cURL/libcurl on AmigaOS just type 'make amiga' ...
|
||||
|
||||
What you need is: (not tested with others versions)
|
||||
|
||||
GeekGadgets / gcc 2.95.3 (http://www.geekgadgets.org/)
|
||||
|
||||
AmiTCP SDK v4.3 (http://www.aminet.net/comm/tcp/AmiTCP-SDK-4.3.lha)
|
||||
|
||||
Native Developer Kit (http://www.amiga.com/3.9/download/NDK3.9.lha)
|
||||
|
||||
As no ixemul.library is required you will be able to build it for
|
||||
WarpOS/PowerPC (not tested by me), as well a MorphOS version should be
|
||||
possible with no problems.
|
||||
|
||||
To enable SSL support, you need a OpenSSL native version (without ixemul),
|
||||
you can find a precompiled package at http://amiga.sourceforge.net/OpenSSL/
|
||||
|
||||
|
||||
NetWare
|
||||
=======
|
||||
To compile curl.nlm / libcurl.nlm you need:
|
||||
- either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later.
|
||||
- gnu make and awk running on the platform you compile on;
|
||||
native Win32 versions can be downloaded from:
|
||||
http://www.gknw.net/development/prgtools/
|
||||
- recent Novell LibC SDK available from:
|
||||
http://developer.novell.com/ndk/libc.htm
|
||||
- optional zlib sources (at the moment only dynamic linking with zlib.imp);
|
||||
sources with NetWare Makefile can be obtained from:
|
||||
http://www.gknw.net/mirror/zlib/
|
||||
- optional OpenSSL sources (version 0.9.8 or later which builds with BSD);
|
||||
|
||||
Set a search path to your compiler, linker and tools; on Linux make
|
||||
sure that the var OSTYPE contains the string 'linux'; and then type
|
||||
'make netware' from the top source directory; other tagets available
|
||||
are 'netware-ssl', 'netware-ssl-zlib', 'netware-zlib' and 'netware-ares';
|
||||
if you need other combinations you can control the build with the
|
||||
environment variables WITH_SSL, WITH_ZLIB, WITH_ARES and ENABLE_IPV6.
|
||||
I found on some Linux systems (RH9) that OS detection didnt work although
|
||||
a 'set | grep OSTYPE' shows the var present and set; I simply overwrote it
|
||||
with 'OSTYPE=linux-rh9-gnu' and the detection in the Makefile worked...
|
||||
Any help in testing appreciated!
|
||||
Builds automatically created 8 times a day from current CVS are here:
|
||||
http://www.gknw.net/mirror/curl/autobuilds/
|
||||
the status of these builds can be viewed at the autobuild table:
|
||||
http://curl.haxx.se/auto/
|
||||
|
||||
|
||||
eCos
|
||||
====
|
||||
curl does not use the eCos build system, so you must first build eCos
|
||||
separately, then link curl to the resulting eCos library. Here's a sample
|
||||
configure line to do so on an x86 Linux box targeting x86:
|
||||
|
||||
GCCLIB=`gcc -print-libgcc-file-name` && \
|
||||
CFLAGS="-D__ECOS=1 -nostdinc -I$ECOS_INSTALL/include \
|
||||
-I`dirname $GCCLIB`/include" \
|
||||
LDFLAGS="-nostdlib -Wl,--gc-sections -Wl,-static \
|
||||
-L$ECOS_INSTALL/lib -Ttarget.ld -ltarget" \
|
||||
./configure --host=i386 --disable-shared \
|
||||
--without-ssl --without-zlib --disable-manual --disable-ldap
|
||||
|
||||
In most cases, eCos users will be using libcurl from within a custom
|
||||
embedded application. Using the standard 'curl' executable from
|
||||
within eCos means facing the limitation of the standard eCos C
|
||||
startup code which does not allow passing arguments in main(). To
|
||||
run 'curl' from eCos and have it do something useful, you will need
|
||||
to either modify the eCos startup code to pass in some arguments, or
|
||||
modify the curl application itself to retrieve its arguments from
|
||||
some location set by the bootloader or hard-code them.
|
||||
|
||||
Something like the following patch could be used to hard-code some
|
||||
arguments. The MTAB_ENTRY line mounts a RAM disk as the root filesystem
|
||||
(without mounting some kind of filesystem, eCos errors out all file
|
||||
operations which curl does not take to well). The next section synthesizes
|
||||
some command-line arguments for curl to use, in this case to direct curl
|
||||
to read further arguments from a file. It then creates that file on the
|
||||
RAM disk and places within it a URL to download: a file: URL that
|
||||
just happens to point to the configuration file itself. The results
|
||||
of running curl in this way is the contents of the configuration file
|
||||
printed to the console.
|
||||
|
||||
--- src/main.c 19 Jul 2006 19:09:56 -0000 1.363
|
||||
+++ src/main.c 24 Jul 2006 21:37:23 -0000
|
||||
@@ -4286,11 +4286,31 @@
|
||||
}
|
||||
|
||||
|
||||
+#ifdef __ECOS
|
||||
+#include <cyg/fileio/fileio.h>
|
||||
+MTAB_ENTRY( testfs_mte1,
|
||||
+ "/",
|
||||
+ "ramfs",
|
||||
+ "",
|
||||
+ 0);
|
||||
+#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int res;
|
||||
struct Configurable config;
|
||||
+#ifdef __ECOS
|
||||
+ char *args[] = {"ecos-curl", "-K", "curlconf.txt"};
|
||||
+ FILE *f;
|
||||
+ argc = sizeof(args)/sizeof(args[0]);
|
||||
+ argv = args;
|
||||
+
|
||||
+ f = fopen("curlconf.txt", "w");
|
||||
+ if (f) {
|
||||
+ fprintf(f, "--url file:curlconf.txt");
|
||||
+ fclose(f);
|
||||
+ }
|
||||
+#endif
|
||||
memset(&config, 0, sizeof(struct Configurable));
|
||||
|
||||
config.errors = stderr; /* default errors to stderr */
|
||||
|
||||
|
||||
Minix
|
||||
=====
|
||||
curl can be compiled on Minix 3 using gcc (ACK has a few problems due
|
||||
to mismatched headers and libraries as of ver. 3.1.2). The gcc and bash
|
||||
packages must be installed first. The default heap size allocated to
|
||||
bash is inadequate for running configure and will result in out of memory
|
||||
errors. Increase it with the command:
|
||||
|
||||
chmem =2048000 /usr/local/bin/bash
|
||||
|
||||
Make sure gcc and bash are in the PATH then configure curl with a
|
||||
command like this:
|
||||
|
||||
./configure GREP=/usr/bin/grep AR=/usr/gnu/bin/gar --disable-ldap
|
||||
|
||||
Then simply run 'make'.
|
||||
|
||||
|
||||
CROSS COMPILE
|
||||
=============
|
||||
(This section was graciously brought to us by Jim Duey, with additions by
|
||||
Dan Fandrich)
|
||||
|
||||
Download and unpack the cURL package. Version should be 7.9.1 or later.
|
||||
|
||||
'cd' to the new directory. (e.g. cd curl-7.12.3)
|
||||
|
||||
Set environment variables to point to the cross-compile toolchain and call
|
||||
configure with any options you need. Be sure and specify the '--host' and
|
||||
'--build' parameters at configuration time. The following script is an
|
||||
example of cross-compiling for the IBM 405GP PowerPC processor using the
|
||||
toolchain from MonteVista for Hardhat Linux.
|
||||
|
||||
(begin script)
|
||||
|
||||
#! /bin/sh
|
||||
|
||||
export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
|
||||
export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
|
||||
export AR=ppc_405-ar
|
||||
export AS=ppc_405-as
|
||||
export LD=ppc_405-ld
|
||||
export RANLIB=ppc_405-ranlib
|
||||
export CC=ppc_405-gcc
|
||||
export NM=ppc_405-nm
|
||||
|
||||
./configure --target=powerpc-hardhat-linux \
|
||||
--host=powerpc-hardhat-linux \
|
||||
--build=i586-pc-linux-gnu \
|
||||
--prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \
|
||||
--exec-prefix=/usr/local
|
||||
|
||||
(end script)
|
||||
|
||||
You may also need to provide a parameter like '--with-random=/dev/urandom'
|
||||
to configure as it cannot detect the presence of a random number
|
||||
generating device for a target system. The '--prefix' parameter
|
||||
specifies where cURL will be installed. If 'configure' completes
|
||||
successfully, do 'make' and 'make install' as usual.
|
||||
|
||||
In some cases, you may be able to simplify the above commands to as
|
||||
little as:
|
||||
|
||||
./configure --host=ARCH-OS
|
||||
|
||||
|
||||
REDUCING SIZE
|
||||
=============
|
||||
There are a number of configure options that can be used to reduce the
|
||||
size of libcurl for embedded applications where binary size is an
|
||||
important factor. First, be sure to set the CFLAGS variable when
|
||||
configuring with any relevant compiler optimization flags to reduce the
|
||||
size of the binary. For gcc, this would mean at minimum the -Os option
|
||||
and probably the -march=X option as well, e.g.:
|
||||
|
||||
./configure CFLAGS='-Os' ...
|
||||
|
||||
Be sure to specify as many --disable- and --without- flags on the configure
|
||||
command-line as you can to disable all the libcurl features that you
|
||||
know your application is not going to need. Besides specifying the
|
||||
--disable-PROTOCOL flags for all the types of URLs your application
|
||||
will not use, here are some other flags that can reduce the size of the
|
||||
library:
|
||||
|
||||
--disable-ares (disables support for the ARES DNS library)
|
||||
--disable-cookies (disables support for HTTP cookies)
|
||||
--disable-crypto-auth (disables HTTP cryptographic authentication)
|
||||
--disable-ipv6 (disables support for IPv6)
|
||||
--disable-verbose (eliminates debugging strings and error code strings)
|
||||
--enable-hidden-symbols (eliminates unneeded symbols in the shared library)
|
||||
--without-libidn (disables support for the libidn DNS library)
|
||||
--without-ssl (disables support for SSL/TLS)
|
||||
--without-zlib (disables support for on-the-fly decompression)
|
||||
|
||||
The GNU linker has a number of options to reduce the size of the libcurl
|
||||
dynamic libraries on some platforms even further. Specify them by giving
|
||||
the options -Wl,-Bsymbolic and -Wl,-s on the gcc command-line.
|
||||
Be sure also to strip debugging symbols from your binaries after
|
||||
compiling using 'strip' (or the appropriate variant if cross-compiling).
|
||||
If space is really tight, you may be able to remove some unneeded
|
||||
sections of the shared library using the -R option to objcopy (e.g. the
|
||||
.comment section).
|
||||
|
||||
Using these techniques it is possible to create an HTTP-only shared
|
||||
libcurl library for i386 Linux platforms that is less than 90 KB in
|
||||
size (as of version 7.15.4).
|
||||
|
||||
You may find that statically linking libcurl to your application will
|
||||
result in a lower total size.
|
||||
|
||||
|
||||
PORTS
|
||||
=====
|
||||
This is a probably incomplete list of known hardware and operating systems
|
||||
that curl has been compiled for. If you know a system curl compiles and
|
||||
runs on, that isn't listed, please let us know!
|
||||
|
||||
- Alpha DEC OSF 4
|
||||
- Alpha Digital UNIX v3.2
|
||||
- Alpha FreeBSD 4.1, 4.5
|
||||
- Alpha Linux 2.2, 2.4
|
||||
- Alpha NetBSD 1.5.2
|
||||
- Alpha OpenBSD 3.0
|
||||
- Alpha OpenVMS V7.1-1H2
|
||||
- Alpha Tru64 v5.0 5.1
|
||||
- HP-PA HP-UX 9.X 10.X 11.X
|
||||
- HP-PA Linux
|
||||
- HP3000 MPE/iX
|
||||
- MIPS IRIX 6.2, 6.5
|
||||
- MIPS Linux
|
||||
- Pocket PC/Win CE 3.0
|
||||
- Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2
|
||||
- PowerPC Darwin 1.0
|
||||
- PowerPC Linux
|
||||
- PowerPC Mac OS 9
|
||||
- PowerPC Mac OS X
|
||||
- SINIX-Z v5
|
||||
- Sparc Linux
|
||||
- Sparc Solaris 2.4, 2.5, 2.5.1, 2.6, 7, 8, 9, 10
|
||||
- Sparc SunOS 4.1.X
|
||||
- StrongARM (and other ARM) RISC OS 3.1, 4.02
|
||||
- StrongARM/ARM7/ARM9 Linux 2.4, 2.6
|
||||
- StrongARM NetBSD 1.4.1
|
||||
- Ultrix 4.3a
|
||||
- UNICOS 9.0
|
||||
- i386 BeOS
|
||||
- i386 DOS
|
||||
- i386 eCos 1.3.1
|
||||
- i386 Esix 4.1
|
||||
- i386 FreeBSD
|
||||
- i386 HURD
|
||||
- i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6
|
||||
- i386 MINIX 3.1.2
|
||||
- i386 NetBSD
|
||||
- i386 Novell NetWare
|
||||
- i386 OS/2
|
||||
- i386 OpenBSD
|
||||
- i386 SCO unix
|
||||
- i386 Solaris 2.7
|
||||
- i386 Windows 95, 98, ME, NT, 2000, XP, 2003
|
||||
- i386 QNX 6
|
||||
- i486 ncr-sysv4.3.03 (NCR MP-RAS)
|
||||
- ia64 Linux 2.3.99
|
||||
- m68k AmigaOS 3
|
||||
- m68k Linux
|
||||
- m68k OpenBSD
|
||||
- m88k dg-dgux5.4R3.00
|
||||
- s390 Linux
|
||||
- XScale/PXA250 Linux 2.4
|
||||
|
||||
Useful URLs
|
||||
===========
|
||||
|
||||
OpenSSL http://www.openssl.org
|
||||
MingW http://www.mingw.org
|
||||
OpenLDAP http://www.openldap.org
|
||||
Zlib http://www.gzip.org/zlib/
|
|
@ -1,302 +0,0 @@
|
|||
DevCpp-Mingw Install & Compilation Sept 2005
|
||||
==================================
|
||||
|
||||
Reference Emails available at curl@haxx.se:
|
||||
|
||||
Libcurl Install and Use Issues
|
||||
Awaiting an Answer for Win 32 Install
|
||||
res = curl_easy_perform(curl); Error
|
||||
Makefile Issues
|
||||
|
||||
|
||||
Having previously done a thorough review of what was available that met my
|
||||
requirements under GPL, I settled for Libcurl as the software of choice for
|
||||
many reasons not the least of which was the support.
|
||||
|
||||
Background
|
||||
----------
|
||||
|
||||
This quest started when I innocently tried to incorporate the libcurl library
|
||||
into my simple source code. I figured that a few easy steps would accomplish
|
||||
this without major headaches. I had no idea that I would be facing an almost
|
||||
insurmountable challenge.
|
||||
|
||||
The main problem lies in two areas. First the bulk of support for libcurl
|
||||
exists for a Unix/linux command line environments. This is of little help when
|
||||
it comes to Windows O/S.
|
||||
|
||||
Secondly the help that does exist for the Windows O/S focused around mingw
|
||||
thru a command line argument environment.
|
||||
|
||||
You may ask "Why is this a problem?"
|
||||
|
||||
I'm using a Windows O/S with DevCpp. For those of you who are unfamiliar with
|
||||
DevCpp, it is a window shell GUI that replaces the command line environment
|
||||
for gcc. A definite improvement that I am unwilling to give up. However using
|
||||
DevCpp presented its own set of issues. Inadvertently I also made some
|
||||
careless errors such as compiling the 7.14 version of Makefile with an older
|
||||
version of source code. Thanks to Dan Fandrich for picking this up.
|
||||
|
||||
I did eventually with the help of Daniel, Phillipe and others manage to
|
||||
implement successfully (the only mingw available version)
|
||||
curl-7.13.0-win32-ssl-devel-mingw32 into the DevCpp environment. Only the
|
||||
dynamic libcurl.dll libcurldll.a libraries worked. The static library which I
|
||||
was interested in did not. Furthermore when I tried to implement one of the
|
||||
examples included with the curl package (get info.c) it caused the executable
|
||||
to crash. Tracing the bug I found it in the code and function res =
|
||||
curl_easy_perform(curl);.
|
||||
|
||||
At this point I had to make a choice as to whether invest my limited
|
||||
time-energy resource to fixing the bug or to compile the new version
|
||||
available. After searching the archives I found a very similar or the same bug
|
||||
reported from version 7.12x on. Daniel did inform me that he thought that this
|
||||
bug had been fixed with the latest version. So I proceeded to compile the
|
||||
latest SSL version where I faced other challenges.
|
||||
|
||||
In order to make this process unremarkable for others using the same
|
||||
environment I decided to document the process so that others will find it
|
||||
routine. It would be a shame if newbies could not implement this excellent
|
||||
package for their use.
|
||||
|
||||
I would like to thank the many others in this forum and in the DevCpp forum
|
||||
for their help. Without your help I may either have given up or it would have
|
||||
taken me many times longer to achieve success.
|
||||
|
||||
The Cookbook Approach
|
||||
---------------------
|
||||
|
||||
This discussion will be confined to a SSL static library compilation and
|
||||
installation. Limited mention and comments will be inserted where appropriate
|
||||
to help with non-SSL, dynamic libraries and executables.
|
||||
|
||||
|
||||
Using Makefile from DevCpp to compile Libcurl libraries
|
||||
|
||||
Preamble
|
||||
--------
|
||||
|
||||
Using the latest version release - curl-7.14.0.tar.gz. Curl source code is
|
||||
platform independent. This simply means that the source code can be compiled
|
||||
for any Operating System (Linux/Unix Windows etc. and variations of thereof).
|
||||
|
||||
The first thing to note is that inside curl-7.14.0 you will find two folders
|
||||
lib and src. Both contain Makefile.m32 (required for win mingw library or exe
|
||||
compilation) files which are different. The main difference between these two
|
||||
folders and the makefiles is that the src folder contents are used to compile
|
||||
an executable file(curl.exe) while the lib folder contents are used to compile
|
||||
a static (libcurl.a) and dynamic (libcurl.dll & libcurldll.a) file that can be
|
||||
used to compile libcurl with your own source code so that one can use and
|
||||
access all libcurl functions.
|
||||
|
||||
Before we start please make sure that DevCpp is installed properly. In
|
||||
particular make sure you have no spaces in the name of any of the directories
|
||||
and subdirectories where DevCpp is installed. Failure to comply with the
|
||||
install instructions may produce erratic behaviour in DevCpp. For further info
|
||||
check the following sites
|
||||
|
||||
http://aditsu.freeunixhost.com/dev-cpp-faq.html
|
||||
http://sourceforge.net/forum/message.php?msg_id=3252213
|
||||
|
||||
As I have mentioned before I will confine this to the SSL Library compilations
|
||||
but the process is very similar for compilation of the executable - curl.exe;
|
||||
just substitute the src folder makefile in its stead.
|
||||
|
||||
First use a text processor Notepad, or your own favourite text processor. To
|
||||
engage your favourite text processor, select Makefile.m32 click once with your
|
||||
mouse on file icon; icon turns blue, press the shift key and right-click on
|
||||
mouse, menu appears select "Open with", select your favourite text processor.
|
||||
|
||||
Next read the contents of Makefile.m32. It includes instructions on its use.
|
||||
|
||||
Method I - DOS Command Line
|
||||
---------------------------
|
||||
|
||||
Note - The only reason I have included this method is that Method II which is
|
||||
the preferred method for compiling does not allow for the setting of option
|
||||
switches (e.g. SSL = 1 or SSL =0). At least that's what they tell me at the
|
||||
Dev-Cpp forum.
|
||||
|
||||
1 - Make a copy of (D:\Dev-Cpp\bin) bin folder and name it "bin Original"
|
||||
place it in the Dev-Cpp installed directory (D:\Dev-Cpp\ for this example)
|
||||
|
||||
2 - Copy the entire contents of the LIB folder of curl-7.14.0.tar.gz or zip
|
||||
version into the bin folder above (D:\Dev-Cpp\bin). The reason being is that
|
||||
the make.exe file resides in this folder. Make.exe will use - Makefile.m32,
|
||||
Makefile.inc, and the source code included in the lib folder to compile the
|
||||
source code. There is a PATH issue with make.exe that remains unresolved at
|
||||
least for me. Unless the entire source code to be compiled is placed entirely
|
||||
within the directory of make.exe an error message will be generated - "file
|
||||
xxxx.yyy not available".
|
||||
|
||||
3- Go to Dev-Cpp\bin and double click on make .exe. You will see a DOS window
|
||||
quickly pop up and close very quickly. Not to worry! Please do not skip this
|
||||
step.
|
||||
|
||||
4- Click on the start button\Programs\MS-DOS Prompt.Once the DOS Window is up
|
||||
Type the disk drive letter (e.g. E: ) engage the enter button. The path should
|
||||
automatically take you to the directory of the make.exe file.
|
||||
|
||||
5- To compile the source code simply type at the DOS prompt make -f
|
||||
Makefile.m32 as per instructions contained in the Makefile.m32 file (use any
|
||||
text processor to read instructions). I don't believe that this makefile
|
||||
allows for the option of non SSL. Ignore any warnings.
|
||||
|
||||
6- Collect and make copies of libcurl.a, libcurl.dll, libcurldll.a and any *.o
|
||||
compilations you might need in another directory outside of the bin directory
|
||||
as you will need this files shortly to set up libcurl for use with
|
||||
Dev-cpp. For most apps *.o is not required. Later on we will show what to do
|
||||
with these files.
|
||||
|
||||
7- You are finished but before closing we need to do cleanup - erase the bin
|
||||
folder and rename the "bin Original" folder created in step 1 to bin.
|
||||
|
||||
Note to compile a curl executable the process is probably similar but instead
|
||||
of using the LIB folder contents use the SRC folder contents and Makefiles in
|
||||
curl-7.14.0.tar.gz. File directories relative placements must be respected for
|
||||
compiling to take place successfully. This may not be possible with the PATH
|
||||
problem that make.exe experiences. If anyone has solved this PATH issue and
|
||||
please make sure it actually works on Win 9x/2000/XP before letting me
|
||||
know. Then please let me or Daniel in on the solution so that it can be
|
||||
included with these instructions. Thanks.
|
||||
|
||||
or
|
||||
|
||||
Method II - Dev-Cpp GUI
|
||||
-----------------------
|
||||
|
||||
1- Copy the entire contents of the LIB folder of curl-7.14.0.tar.gz or zip
|
||||
version into any folder outside of (Dev-Cpp\bin).
|
||||
|
||||
2- Drop the File/New/click on Project.
|
||||
|
||||
3- New Project Dialogue box appears. Double click on the Static Library.
|
||||
|
||||
4- Create Project Dialogue box appears. Select the LIB folder location to
|
||||
place and locate your Project File Name. Placing the Project File Name
|
||||
elsewhere may cause problems (PATH issue problem again).
|
||||
|
||||
5- Drop down the Project/Project Options. Project Options Dialogue box
|
||||
appears.
|
||||
|
||||
6- Select the Makefile tab in the Project Options Dialogue Box. Check Box -
|
||||
Use Custom Makefile. Click on the Folder icon at the extreme right of the
|
||||
Check Box. Select Makefile.m32 in the folder wherever you have placed the
|
||||
contents of the LIB Folder. Press OK and close the Dialogue Box.
|
||||
|
||||
7- Drop the Menu Project/Click on Add to Project. Open File Dialogue Box
|
||||
appears. The Dialogue Box should open in the folder wherever you have placed
|
||||
the contents of the LIB Folder. If not go there.
|
||||
|
||||
8- Select Crtl-A to select all files in the LIB folder. Click on open to add
|
||||
files and close box. Wait till all files are added. This may take 30 seconds
|
||||
or longer.
|
||||
|
||||
9- Drop the Menu Execute/Click on Compile.
|
||||
|
||||
10- That's it.
|
||||
|
||||
|
||||
The following steps must be completed if Curl is to work properly
|
||||
=================================================================
|
||||
|
||||
LIB folder inclusions (*.a placement)
|
||||
-------------------------------------
|
||||
|
||||
1- Refer to Method I - DOS Command Line point # 6 Take libcurl.a, libcurldll.a
|
||||
and install it in the directory C( or whichever drive Dev is installed)
|
||||
:\Dev-Cpp\lib.
|
||||
|
||||
|
||||
Include Folder
|
||||
--------------
|
||||
|
||||
1- Create a new folder by the name of curl (do not change the name curl to
|
||||
some other name as it will cause major issues) in the directory
|
||||
C:\Dev-Cpp\include.
|
||||
|
||||
2- Copy the entire contents of the curl folder of curl-7.14.0.tar.gz or zip
|
||||
version into the newly created curl directory - C:\Dev-Cpp\include\curl.
|
||||
|
||||
Links To Include And Lib Folder
|
||||
-------------------------------
|
||||
|
||||
1- Drop the Menu - Tools\Compiler Options\Directories\Libraries. Make sure
|
||||
that C( or whichever drive Dev is installed):\DEV-CPP\lib is included.
|
||||
|
||||
2- Next select the Menu - Tools\Compiler Options\Directories\C Includes. Make
|
||||
sure that C:\DEV-CPP\include and C:\Dev-Cpp\include\curl are included.
|
||||
|
||||
3- Next select the Menu - Tools\Compiler Options\Directories\C++
|
||||
Includes. Make sure that C:\DEV-CPP\include and C:\Dev-Cpp\include\curl are
|
||||
included.
|
||||
|
||||
Linker Links
|
||||
------------
|
||||
|
||||
1- Drop the Menu - Tools\Compiler Options\Directories\Compiler.
|
||||
|
||||
2- Make sure that the box "Add these commands to the linker command line" is
|
||||
checked.
|
||||
|
||||
3- Include in the white space immediately below the box referred in 2 -lcurl
|
||||
-lws2_32 -lwinmm.
|
||||
|
||||
SSL Files
|
||||
---------
|
||||
|
||||
1- Get the latest openSSL (as of time of this writing)
|
||||
openssl-0.9.7e-win32-bin.zip for the minimalist package of the openssl-0.9.7e
|
||||
binaries ported to MS Windows 95/98/NT/XP using the MingW32/GCC-3.1
|
||||
development environment. The file may be downloaded at
|
||||
http://curl.haxx.se/download/.
|
||||
|
||||
2- Open the above zip file. You will find two files - SDL.dll,
|
||||
SDL_mixer.dll. Install them in the directory C:\WINDOWS\SYSTEM32 for Win 9x
|
||||
users and c:\winnt\system32 for NT-family users.
|
||||
|
||||
Multithreading Files
|
||||
--------------------
|
||||
|
||||
To be completed
|
||||
|
||||
#define
|
||||
-------
|
||||
|
||||
1- Make sure that your program includes the following - #define CURL_STATICLIB
|
||||
must be declared FIRST before any other define functions may be
|
||||
added. Otherwise you may experience link errors.
|
||||
|
||||
2- Don't forget to include #include "curl/curl.h".
|
||||
|
||||
e.g.
|
||||
#define CURL_STATICLIB
|
||||
#include <windows.h>
|
||||
#include "curl/curl.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
etc...
|
||||
|
||||
|
||||
Static or Dynamic Library
|
||||
-------------------------
|
||||
|
||||
The above steps apply for the use by a static library. Should you choose to
|
||||
use a dynamic library you will be required to perform these additional steps.
|
||||
|
||||
1- Refer to Method I - DOS Command Line point # 6. Install libcurl.dll in the
|
||||
directory C:\WINDOWS\SYSTEM32 for Win 9x users and c:\winnt\system32 for
|
||||
NT-family users.
|
||||
|
||||
2- Refer to Linker Links point 3 - Replace -lcurl with -lcurldll.
|
||||
|
||||
Voila you're done.
|
||||
|
||||
The non-SSL static Library build may not be possible to use at least as of the
|
||||
time of this writing - v7.14. Check reference emails - Phillipe and I found it
|
||||
impossible to fully compile as certain files were missing for linking. No big
|
||||
loss as SSL is a major plus.
|
||||
|
||||
Hope this Helps
|
||||
|
||||
Tom
|
|
@ -1,381 +0,0 @@
|
|||
Updated for curl 7.9.1 on November 2, 2001
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
INTERNALS
|
||||
|
||||
The project is split in two. The library and the client. The client part uses
|
||||
the library, but the library is designed to allow other applications to use
|
||||
it.
|
||||
|
||||
The largest amount of code and complexity is in the library part.
|
||||
|
||||
CVS
|
||||
===
|
||||
All changes to the sources are committed to the CVS repository as soon as
|
||||
they're somewhat verified to work. Changes shall be commited as independently
|
||||
as possible so that individual changes can be easier spotted and tracked
|
||||
afterwards.
|
||||
|
||||
Tagging shall be used extensively, and by the time we release new archives we
|
||||
should tag the sources with a name similar to the released version number.
|
||||
|
||||
Windows vs Unix
|
||||
===============
|
||||
|
||||
There are a few differences in how to program curl the unix way compared to
|
||||
the Windows way. The four perhaps most notable details are:
|
||||
|
||||
1. Different function names for socket operations.
|
||||
|
||||
In curl, this is solved with defines and macros, so that the source looks
|
||||
the same at all places except for the header file that defines them. The
|
||||
macros in use are sclose(), sread() and swrite().
|
||||
|
||||
2. Windows requires a couple of init calls for the socket stuff.
|
||||
|
||||
Those must be made by the application that uses libcurl, in curl that means
|
||||
src/main.c has some code #ifdef'ed to do just that.
|
||||
|
||||
3. The file descriptors for network communication and file operations are
|
||||
not easily interchangable as in unix.
|
||||
|
||||
We avoid this by not trying any funny tricks on file descriptors.
|
||||
|
||||
4. When writing data to stdout, Windows makes end-of-lines the DOS way, thus
|
||||
destroying binary data, although you do want that conversion if it is
|
||||
text coming through... (sigh)
|
||||
|
||||
We set stdout to binary under windows
|
||||
|
||||
Inside the source code, We make an effort to avoid '#ifdef [Your OS]'. All
|
||||
conditionals that deal with features *should* instead be in the format
|
||||
'#ifdef HAVE_THAT_WEIRD_FUNCTION'. Since Windows can't run configure scripts,
|
||||
we maintain two config-win32.h files (one in lib/ and one in src/) that are
|
||||
supposed to look exactly as a config.h file would have looked like on a
|
||||
Windows machine!
|
||||
|
||||
Generally speaking: always remember that this will be compiled on dozens of
|
||||
operating systems. Don't walk on the edge.
|
||||
|
||||
Library
|
||||
=======
|
||||
|
||||
There are plenty of entry points to the library, namely each publicly defined
|
||||
function that libcurl offers to applications. All of those functions are
|
||||
rather small and easy-to-follow. All the ones prefixed with 'curl_easy' are
|
||||
put in the lib/easy.c file.
|
||||
|
||||
curl_global_init_() and curl_global_cleanup() should be called by the
|
||||
application to initialize and clean up global stuff in the library. As of
|
||||
today, it can handle the global SSL initing if SSL is enabled and it can init
|
||||
the socket layer on windows machines. libcurl itself has no "global" scope.
|
||||
|
||||
All printf()-style functions use the supplied clones in lib/mprintf.c. This
|
||||
makes sure we stay absolutely platform independent.
|
||||
|
||||
curl_easy_init() allocates an internal struct and makes some initializations.
|
||||
The returned handle does not reveal internals. This is the 'SessionHandle'
|
||||
struct which works as an "anchor" struct for all curl_easy functions. All
|
||||
connections performed will get connect-specific data allocated that should be
|
||||
used for things related to particular connections/requests.
|
||||
|
||||
curl_easy_setopt() takes three arguments, where the option stuff must be
|
||||
passed in pairs: the parameter-ID and the parameter-value. The list of
|
||||
options is documented in the man page. This function mainly sets things in
|
||||
the 'SessionHandle' struct.
|
||||
|
||||
curl_easy_perform() does a whole lot of things:
|
||||
|
||||
It starts off in the lib/easy.c file by calling Curl_perform() and the main
|
||||
work then continues in lib/url.c. The flow continues with a call to
|
||||
Curl_connect() to connect to the remote site.
|
||||
|
||||
o Curl_connect()
|
||||
|
||||
... analyzes the URL, it separates the different components and connects to
|
||||
the remote host. This may involve using a proxy and/or using SSL. The
|
||||
Curl_gethost() function in lib/hostip.c is used for looking up host names.
|
||||
|
||||
When Curl_connect is done, we are connected to the remote site. Then it is
|
||||
time to tell the server to get a document/file. Curl_do() arranges this.
|
||||
|
||||
This function makes sure there's an allocated and initiated 'connectdata'
|
||||
struct that is used for this particular connection only (although there may
|
||||
be several requests performed on the same connect). A bunch of things are
|
||||
inited/inherited from the SessionHandle struct.
|
||||
|
||||
o Curl_do()
|
||||
|
||||
Curl_do() makes sure the proper protocol-specific function is called. The
|
||||
functions are named after the protocols they handle. Curl_ftp(),
|
||||
Curl_http(), Curl_dict(), etc. They all reside in their respective files
|
||||
(ftp.c, http.c and dict.c). HTTPS is handled by Curl_http() and FTPS by
|
||||
Curl_ftp().
|
||||
|
||||
The protocol-specific functions of course deal with protocol-specific
|
||||
negotiations and setup. They have access to the Curl_sendf() (from
|
||||
lib/sendf.c) function to send printf-style formatted data to the remote
|
||||
host and when they're ready to make the actual file transfer they call the
|
||||
Curl_Transfer() function (in lib/transfer.c) to setup the transfer and
|
||||
returns.
|
||||
|
||||
Starting in 7.9.1, if this DO function fails and the connection is being
|
||||
re-used, libcurl will then close this connection, setup a new connection
|
||||
and re-issue the DO request on that. This is because there is no way to be
|
||||
perfectly sure that we have discovered a dead connection before the DO
|
||||
function and thus we might wrongly be re-using a connection that was closed
|
||||
by the remote peer.
|
||||
|
||||
o Transfer()
|
||||
|
||||
Curl_perform() then calls Transfer() in lib/transfer.c that performs
|
||||
the entire file transfer.
|
||||
|
||||
During transfer, the progress functions in lib/progress.c are called at a
|
||||
frequent interval (or at the user's choice, a specified callback might get
|
||||
called). The speedcheck functions in lib/speedcheck.c are also used to
|
||||
verify that the transfer is as fast as required.
|
||||
|
||||
o Curl_done()
|
||||
|
||||
Called after a transfer is done. This function takes care of everything
|
||||
that has to be done after a transfer. This function attempts to leave
|
||||
matters in a state so that Curl_do() should be possible to call again on
|
||||
the same connection (in a persistent connection case). It might also soon
|
||||
be closed with Curl_disconnect().
|
||||
|
||||
o Curl_disconnect()
|
||||
|
||||
When doing normal connections and transfers, no one ever tries to close any
|
||||
connections so this is not normally called when curl_easy_perform() is
|
||||
used. This function is only used when we are certain that no more transfers
|
||||
is going to be made on the connection. It can be also closed by force, or
|
||||
it can be called to make sure that libcurl doesn't keep too many
|
||||
connections alive at the same time (there's a default amount of 5 but that
|
||||
can be changed with the CURLOPT_MAXCONNECTS option).
|
||||
|
||||
This function cleans up all resources that are associated with a single
|
||||
connection.
|
||||
|
||||
Curl_perform() is the function that does the main "connect - do - transfer -
|
||||
done" loop. It loops if there's a Location: to follow.
|
||||
|
||||
When completed, the curl_easy_cleanup() should be called to free up used
|
||||
resources. It runs Curl_disconnect() on all open connectons.
|
||||
|
||||
A quick roundup on internal function sequences (many of these call
|
||||
protocol-specific function-pointers):
|
||||
|
||||
curl_connect - connects to a remote site and does initial connect fluff
|
||||
This also checks for an existing connection to the requested site and uses
|
||||
that one if it is possible.
|
||||
|
||||
curl_do - starts a transfer
|
||||
curl_transfer() - transfers data
|
||||
curl_done - ends a transfer
|
||||
|
||||
curl_disconnect - disconnects from a remote site. This is called when the
|
||||
disconnect is really requested, which doesn't necessarily have to be
|
||||
exactly after curl_done in case we want to keep the connection open for
|
||||
a while.
|
||||
|
||||
HTTP(S)
|
||||
|
||||
HTTP offers a lot and is the protocol in curl that uses the most lines of
|
||||
code. There is a special file (lib/formdata.c) that offers all the multipart
|
||||
post functions.
|
||||
|
||||
base64-functions for user+password stuff (and more) is in (lib/base64.c) and
|
||||
all functions for parsing and sending cookies are found in (lib/cookie.c).
|
||||
|
||||
HTTPS uses in almost every means the same procedure as HTTP, with only two
|
||||
exceptions: the connect procedure is different and the function used to read
|
||||
or write from the socket is different, although the latter fact is hidden in
|
||||
the source by the use of curl_read() for reading and curl_write() for writing
|
||||
data to the remote server.
|
||||
|
||||
http_chunks.c contains functions that understands HTTP 1.1 chunked transfer
|
||||
encoding.
|
||||
|
||||
An interesting detail with the HTTP(S) request, is the add_buffer() series of
|
||||
functions we use. They append data to one single buffer, and when the
|
||||
building is done the entire request is sent off in one single write. This is
|
||||
done this way to overcome problems with flawed firewalls and lame servers.
|
||||
|
||||
FTP
|
||||
|
||||
The Curl_if2ip() function can be used for getting the IP number of a
|
||||
specified network interface, and it resides in lib/if2ip.c.
|
||||
|
||||
Curl_ftpsendf() is used for sending FTP commands to the remote server. It was
|
||||
made a separate function to prevent us programmers from forgetting that they
|
||||
must be CRLF terminated. They must also be sent in one single write() to make
|
||||
firewalls and similar happy.
|
||||
|
||||
Kerberos
|
||||
|
||||
The kerberos support is mainly in lib/krb4.c and lib/security.c.
|
||||
|
||||
TELNET
|
||||
|
||||
Telnet is implemented in lib/telnet.c.
|
||||
|
||||
FILE
|
||||
|
||||
The file:// protocol is dealt with in lib/file.c.
|
||||
|
||||
LDAP
|
||||
|
||||
Everything LDAP is in lib/ldap.c.
|
||||
|
||||
GENERAL
|
||||
|
||||
URL encoding and decoding, called escaping and unescaping in the source code,
|
||||
is found in lib/escape.c.
|
||||
|
||||
While transfering data in Transfer() a few functions might get
|
||||
used. curl_getdate() in lib/getdate.c is for HTTP date comparisons (and
|
||||
more).
|
||||
|
||||
lib/getenv.c offers curl_getenv() which is for reading environment variables
|
||||
in a neat platform independent way. That's used in the client, but also in
|
||||
lib/url.c when checking the proxy environment variables. Note that contrary
|
||||
to the normal unix getenv(), this returns an allocated buffer that must be
|
||||
free()ed after use.
|
||||
|
||||
lib/netrc.c holds the .netrc parser
|
||||
|
||||
lib/timeval.c features replacement functions for systems that don't have
|
||||
gettimeofday() and a few support functions for timeval convertions.
|
||||
|
||||
A function named curl_version() that returns the full curl version string is
|
||||
found in lib/version.c.
|
||||
|
||||
If authentication is requested but no password is given, a getpass_r() clone
|
||||
exists in lib/getpass.c. libcurl offers a custom callback that can be used
|
||||
instead of this, but it doesn't change much to us.
|
||||
|
||||
Persistent Connections
|
||||
======================
|
||||
|
||||
The persistent connection support in libcurl requires some considerations on
|
||||
how to do things inside of the library.
|
||||
|
||||
o The 'SessionHandle' struct returned in the curl_easy_init() call must never
|
||||
hold connection-oriented data. It is meant to hold the root data as well as
|
||||
all the options etc that the library-user may choose.
|
||||
o The 'SessionHandle' struct holds the "connection cache" (an array of
|
||||
pointers to 'connectdata' structs). There's one connectdata struct
|
||||
allocated for each connection that libcurl knows about.
|
||||
o This also enables the 'curl handle' to be reused on subsequent transfers,
|
||||
something that was illegal before libcurl 7.7.
|
||||
o When we are about to perform a transfer with curl_easy_perform(), we first
|
||||
check for an already existing connection in the cache that we can use,
|
||||
otherwise we create a new one and add to the cache. If the cache is full
|
||||
already when we add a new connection, we close one of the present ones. We
|
||||
select which one to close dependent on the close policy that may have been
|
||||
previously set.
|
||||
o When the transfer operation is complete, we try to leave the connection
|
||||
open. Particular options may tell us not to, and protocols may signal
|
||||
closure on connections and then we don't keep it open of course.
|
||||
o When curl_easy_cleanup() is called, we close all still opened connections.
|
||||
|
||||
You do realize that the curl handle must be re-used in order for the
|
||||
persistent connections to work.
|
||||
|
||||
Library Symbols
|
||||
===============
|
||||
|
||||
All symbols used internally in libcurl must use a 'Curl_' prefix if they're
|
||||
used in more than a single file. Single-file symbols must be made static.
|
||||
Public ("exported") symbols must use a 'curl_' prefix. (There are exceptions,
|
||||
but they are to be changed to follow this pattern in future versions.)
|
||||
|
||||
Return Codes and Informationals
|
||||
===============================
|
||||
|
||||
I've made things simple. Almost every function in libcurl returns a CURLcode,
|
||||
that must be CURLE_OK if everything is OK or otherwise a suitable error code
|
||||
as the curl/curl.h include file defines. The very spot that detects an error
|
||||
must use the Curl_failf() function to set the human-readable error
|
||||
description.
|
||||
|
||||
In aiding the user to understand what's happening and to debug curl usage, we
|
||||
must supply a fair amount of informational messages by using the Curl_infof()
|
||||
function. Those messages are only displayed when the user explicitly asks for
|
||||
them. They are best used when revealing information that isn't otherwise
|
||||
obvious.
|
||||
|
||||
Client
|
||||
======
|
||||
|
||||
main() resides in src/main.c together with most of the client code.
|
||||
|
||||
src/hugehelp.c is automatically generated by the mkhelp.pl perl script to
|
||||
display the complete "manual" and the src/urlglob.c file holds the functions
|
||||
used for the URL-"globbing" support. Globbing in the sense that the {} and []
|
||||
expansion stuff is there.
|
||||
|
||||
The client mostly messes around to setup its 'config' struct properly, then
|
||||
it calls the curl_easy_*() functions of the library and when it gets back
|
||||
control after the curl_easy_perform() it cleans up the library, checks status
|
||||
and exits.
|
||||
|
||||
When the operation is done, the ourWriteOut() function in src/writeout.c may
|
||||
be called to report about the operation. That function is using the
|
||||
curl_easy_getinfo() function to extract useful information from the curl
|
||||
session.
|
||||
|
||||
Recent versions may loop and do all this several times if many URLs were
|
||||
specified on the command line or config file.
|
||||
|
||||
Memory Debugging
|
||||
================
|
||||
|
||||
The file lib/memdebug.c contains debug-versions of a few functions. Functions
|
||||
such as malloc, free, fopen, fclose, etc that somehow deal with resources
|
||||
that might give us problems if we "leak" them. The functions in the memdebug
|
||||
system do nothing fancy, they do their normal function and then log
|
||||
information about what they just did. The logged data can then be analyzed
|
||||
after a complete session,
|
||||
|
||||
memanalyze.pl is the perl script present only present in CVS (not part of the
|
||||
release archives) that analyzes a log file generated by the memdebug
|
||||
system. It detects if resources are allocated but never freed and other kinds
|
||||
of errors related to resource management.
|
||||
|
||||
Use -DMALLOCDEBUG when compiling to enable memory debugging, this is also
|
||||
switched on by running configure with --enable-debug.
|
||||
|
||||
Test Suite
|
||||
==========
|
||||
|
||||
Since November 2000, a test suite has evolved. It is placed in its own
|
||||
subdirectory directly off the root in the curl archive tree, and it contains
|
||||
a bunch of scripts and a lot of test case data.
|
||||
|
||||
The main test script is runtests.pl that will invoke the two servers
|
||||
httpserver.pl and ftpserver.pl before all the test cases are performed. The
|
||||
test suite currently only runs on unix-like platforms.
|
||||
|
||||
You'll find a complete description of the test case data files in the
|
||||
tests/README file.
|
||||
|
||||
The test suite automatically detects if curl was built with the memory
|
||||
debugging enabled, and if it was it will detect memory leaks too.
|
||||
|
||||
Building Releases
|
||||
=================
|
||||
|
||||
There's no magic to this. When you consider everything stable enough to be
|
||||
released, run the 'maketgz' script (using 'make distcheck' will give you a
|
||||
pretty good view on the status of the current sources). maketgz prompts for
|
||||
version number of the client and the library before it creates a release
|
||||
archive. maketgz uses 'make dist' for the actual archive building, why you
|
||||
need to fill in the Makefile.am files properly for which files that should
|
||||
be included in the release archives.
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
These are problems known to exist at the time of this release. Feel free to
|
||||
join in and help us correct one or more of these! Also be sure to check the
|
||||
changelog of the current development status, as one or more of these problems
|
||||
may have been fixed since this was written!
|
||||
|
||||
35. Both SOCKS5 and SOCKS4 proxy connections are done blocking, which is very
|
||||
bad when used with the multi interface.
|
||||
|
||||
34. The SOCKS4 connection codes don't properly acknowledge (connect) timeouts.
|
||||
Also see #12. According to bug #1556528, even the SOCKS5 connect code does
|
||||
not do it right: http://curl.haxx.se/bug/view.cgi?id=1556528,
|
||||
|
||||
33. Doing multi-pass HTTP authentication on a non-default port does not work.
|
||||
This happens because the multi-pass code abuses the redirect following code
|
||||
for doing multiple requests, and when we following redirects to an absolute
|
||||
URL we must use the newly specified port and not the one specified in the
|
||||
original URL. A proper fix to this would need to separate the negotiation
|
||||
"redirect" from an actual redirect.
|
||||
|
||||
32. (At least on Windows) If libcurl is built with c-ares and there's no DNS
|
||||
server configured in the system, the ares_init() call fails and thus
|
||||
curl_easy_init() fails as well. This causes weird effects for people who use
|
||||
numerical IP addresses only.
|
||||
|
||||
31. "curl-config --libs" will include details set in LDFLAGS when configure is
|
||||
run that might be needed only for building libcurl. Similarly, it might
|
||||
include options that perhaps aren't suitable both for static and dynamic
|
||||
linking. Further, curl-config --cflags suffers from the same effects with
|
||||
CFLAGS/CPPFLAGS.
|
||||
|
||||
30. You need to use -g to the command line tool in order to use RFC2732-style
|
||||
IPv6 numerical addresses in URLs.
|
||||
|
||||
29. IPv6 URLs with zone ID is not supported.
|
||||
http://www.ietf.org/internet-drafts/draft-fenner-literal-zone-02.txt
|
||||
specifies the use of a plus sign instead of a percent when specifying zone
|
||||
IDs in URLs to get around the problem of percent signs being
|
||||
special. According to the reporter, Firefox deals with the URL _with_ a
|
||||
percent letter (which seems like a blatant URL spec violation).
|
||||
|
||||
See http://curl.haxx.se/bug/view.cgi?id=1371118
|
||||
|
||||
26. NTLM authentication using SSPI (on Windows) when (lib)curl is running in
|
||||
"system context" will make it use wrong(?) user name - at least when compared
|
||||
to what winhttp does. See http://curl.haxx.se/bug/view.cgi?id=1281867
|
||||
|
||||
25. When doing a CONNECT request with curl it doesn't properly handle if the
|
||||
proxy closes the connection within the authentication "negotiation phase".
|
||||
Like if you do HTTPS or similar over a proxy and you use perhaps
|
||||
--proxy-anyauth.
|
||||
|
||||
23. We don't support SOCKS for IPv6. We don't support FTPS over a SOCKS proxy.
|
||||
We don't have any test cases for SOCKS proxy. We probably have even more
|
||||
bugs and lack of features when a SOCKS proxy is used. And there seem to be a
|
||||
problem with SOCKS when doing FTP: See
|
||||
http://curl.haxx.se/bug/view.cgi?id=1371540
|
||||
|
||||
22. Sending files to a FTP server using curl on VMS, might lead to curl
|
||||
complaining on "unaligned file size" on completion. The problem is related
|
||||
to VMS file structures and the perceived file sizes stat() returns. A
|
||||
possible fix would involve sending a "STRU VMS" command.
|
||||
http://curl.haxx.se/bug/view.cgi?id=1156287
|
||||
|
||||
21. FTP ASCII transfers do not follow RFC959. They don't convert the data
|
||||
accordingly (not for sending nor for receiving). RFC 959 section 3.1.1.1
|
||||
clearly describes how this should be done:
|
||||
|
||||
The sender converts the data from an internal character representation to
|
||||
the standard 8-bit NVT-ASCII representation (see the Telnet
|
||||
specification). The receiver will convert the data from the standard
|
||||
form to his own internal form.
|
||||
|
||||
Since 7.15.4 at least line endings are converted.
|
||||
|
||||
16. FTP URLs passed to curl may contain NUL (0x00) in the RFC 1738 <user>,
|
||||
<password>, and <fpath> components, encoded as "%00". The problem is that
|
||||
curl_unescape does not detect this, but instead returns a shortened C
|
||||
string. From a strict FTP protocol standpoint, NUL is a valid character
|
||||
within RFC 959 <string>, so the way to handle this correctly in curl would
|
||||
be to use a data structure other than a plain C string, one that can handle
|
||||
embedded NUL characters. From a practical standpoint, most FTP servers
|
||||
would not meaningfully support NUL characters within RFC 959 <string>,
|
||||
anyway (e.g., UNIX pathnames may not contain NUL).
|
||||
|
||||
14. Test case 165 might fail on system which has libidn present, but with an
|
||||
old iconv version (2.1.3 is a known bad version), since it doesn't recognize
|
||||
the charset when named ISO8859-1. Changing the name to ISO-8859-1 makes the
|
||||
test pass, but instead makes it fail on Solaris hosts that use its native
|
||||
iconv.
|
||||
|
||||
13. curl version 7.12.2 fails on AIX if compiled with --enable-ares.
|
||||
The workaround is to combine --enable-ares with --disable-shared
|
||||
|
||||
12. When connecting to a SOCKS proxy, the (connect) timeout is not properly
|
||||
acknowledged after the actual TCP connect (during the SOCKS "negotiate"
|
||||
phase).
|
||||
|
||||
11. Using configure --disable-[protocol] may cause 'make test' to fail for
|
||||
tests using the disabled protocol(s).
|
||||
|
||||
10. To get HTTP Negotiate authentication to work fine, you need to provide a
|
||||
(fake) user name (this concerns both curl and the lib) because the code
|
||||
wrongly only considers authentication if there's a user name provided.
|
||||
http://curl.haxx.se/bug/view.cgi?id=1004841. How?
|
||||
http://curl.haxx.se/mail/lib-2004-08/0182.html
|
||||
|
||||
8. Doing resumed upload over HTTP does not work with '-C -', because curl
|
||||
doesn't do a HEAD first to get the initial size. This needs to be done
|
||||
manually for HTTP PUT resume to work, and then '-C [index]'.
|
||||
|
||||
7. CURLOPT_USERPWD and CURLOPT_PROXYUSERPWD have no way of providing user names
|
||||
that contain a colon. This can't be fixed easily in a backwards compatible
|
||||
way without adding new options (and then, they should most probably allow
|
||||
setting user name and password separately).
|
||||
|
||||
6. libcurl ignores empty path parts in FTP URLs, whereas RFC1738 states that
|
||||
such parts should be sent to the server as 'CWD ' (without an argument).
|
||||
The only exception to this rule, is that we knowingly break this if the
|
||||
empty part is first in the path, as then we use the double slashes to
|
||||
indicate that the user wants to reach the root dir (this exception SHALL
|
||||
remain even when this bug is fixed).
|
||||
|
||||
5. libcurl doesn't treat the content-length of compressed data properly, as
|
||||
it seems HTTP servers send the *uncompressed* length in that header and
|
||||
libcurl thinks of it as the *compressed* length. Some explanations are here:
|
||||
http://curl.haxx.se/mail/lib-2003-06/0146.html
|
||||
|
||||
2. If a HTTP server responds to a HEAD request and includes a body (thus
|
||||
violating the RFC2616), curl won't wait to read the response but just stop
|
||||
reading and return back. If a second request (let's assume a GET) is then
|
||||
immediately made to the same server again, the connection will be re-used
|
||||
fine of course, and the second request will be sent off but when the
|
||||
response is to get read, the previous response-body is what curl will read
|
||||
and havoc is what happens.
|
||||
More details on this is found in this libcurl mailing list thread:
|
||||
http://curl.haxx.se/mail/lib-2002-08/0000.html
|
|
@ -1,112 +0,0 @@
|
|||
License Mixing with apps, libcurl and Third Party Libraries
|
||||
===========================================================
|
||||
|
||||
libcurl can be built to use a fair amount of various third party libraries,
|
||||
libraries that are written and provided by other parties that are distributed
|
||||
using their own licenses. Even libcurl itself contains code that may cause
|
||||
problems to some. This document attempts to describe what licenses libcurl and
|
||||
the other libraries use and what possible dilemmas linking and mixing them all
|
||||
can lead to for end users.
|
||||
|
||||
I am not a lawyer and this is not legal advice!
|
||||
|
||||
One common dilemma is that GPL[1]-licensed code is not allowed to be linked
|
||||
with code licensed under the Original BSD license (with the announcement
|
||||
clause). You may still build your own copies that use them all, but
|
||||
distributing them as binaries would be to violate the GPL license - unless you
|
||||
accompany your license with an exception[2]. This particular problem was
|
||||
addressed when the Modified BSD license was created, which does not have the
|
||||
annoncement clause that collides with GPL.
|
||||
|
||||
libcurl http://curl.haxx.se/docs/copyright.html
|
||||
|
||||
Uses an MIT (or Modified BSD)-style license that is as liberal as
|
||||
possible. Some of the source files that deal with KRB4 have Original
|
||||
BSD-style announce-clause licenses. You may not distribute binaries
|
||||
with krb4-enabled libcurl that also link with GPL-licensed code!
|
||||
|
||||
OpenSSL http://www.openssl.org/source/license.html
|
||||
|
||||
(May be used for SSL/TLS support) Uses an Original BSD-style license
|
||||
with an announement clause that makes it "incompatible" with GPL. You
|
||||
are not allowed to ship binaries that link with OpenSSL that includes
|
||||
GPL code (unless that specific GPL code includes an exception for
|
||||
OpenSSL - a habit that is growing more and more common). If OpenSSL's
|
||||
licensing is a problem for you, consider using GnuTLS or yassl
|
||||
instead.
|
||||
|
||||
GnuTLS http://www.gnutls.org/
|
||||
|
||||
(May be used for SSL/TLS support) Uses the LGPL[3] license. If this is
|
||||
a problem for you, consider using OpenSSL instead. Also note that
|
||||
GnuTLS itself depends on and uses other libs (libgcrypt and
|
||||
libgpg-error) and they too are LGPL- or GPL-licensed.
|
||||
|
||||
yassl http://www.yassl.com/
|
||||
|
||||
(May be used for SSL/TLS support) Uses the GPL[1] license. If this is
|
||||
a problem for you, consider using OpenSSL or GnuTLS instead.
|
||||
|
||||
c-ares http://daniel.haxx.se/projects/c-ares/license.html
|
||||
|
||||
(Used for asynchronous name resolves) Uses an MIT license that is very
|
||||
liberal and imposes no restrictions on any other library or part you
|
||||
may link with.
|
||||
|
||||
zlib http://www.gzip.org/zlib/zlib_license.html
|
||||
|
||||
(Used for compressed Transfer-Encoding support) Uses an MIT-style
|
||||
license that shouldn't collide with any other library.
|
||||
|
||||
krb4
|
||||
|
||||
While nothing in particular says that a Kerberos4 library must use any
|
||||
particular license, the one I've tried and used successfully so far
|
||||
(kth-krb4) is partly Original BSD-licensed with the announcement
|
||||
clause. Some of the code in libcurl that is written to deal with
|
||||
Kerberos4 is Modified BSD-licensed.
|
||||
|
||||
MIT Kerberos http://web.mit.edu/kerberos/www/dist/
|
||||
|
||||
(May be used for GSS support) MIT licensed, that shouldn't collide
|
||||
with any other parts.
|
||||
|
||||
Heimdal http://www.pdc.kth.se/heimdal/
|
||||
|
||||
(May be used for GSS support) Heimdal is Original BSD licensed with
|
||||
the announcement clause.
|
||||
|
||||
GNU GSS http://www.gnu.org/software/gss/
|
||||
|
||||
(May be used for GSS support) GNU GSS is GPL licensed. Note that you
|
||||
may not distribute binary curl packages that uses this if you build
|
||||
curl to also link and use any Original BSD licensed libraries!
|
||||
|
||||
fbopenssl
|
||||
|
||||
(Used for SPNEGO support) Unclear license. Based on its name, I assume
|
||||
that it uses the OpenSSL license and thus shares the same issues as
|
||||
described for OpenSSL above.
|
||||
|
||||
libidn http://www.gnu.org/licenses/lgpl.html
|
||||
|
||||
(Used for IDNA support) Uses the GNU Lesser General Public
|
||||
License. LGPL is a variation of GPL with slightly less aggressive
|
||||
"copyleft". This license requires more requirements to be met when
|
||||
distributing binaries, see the license for details. Also note that if
|
||||
you distribute a binary that includes this library, you must also
|
||||
include the full LGPL license text. Please properly point out what
|
||||
parts of the distributed package that the license addresses.
|
||||
|
||||
OpenLDAP http://www.openldap.org/software/release/license.html
|
||||
|
||||
(Used for LDAP support) Uses a Modified BSD-style license. Since
|
||||
libcurl uses OpenLDAP as a shared library only, I have not heard of
|
||||
anyone that ships OpenLDAP linked with libcurl in an app.
|
||||
|
||||
|
||||
[1] = GPL - GNU General Public License: http://www.gnu.org/licenses/gpl.html
|
||||
[2] = http://www.fsf.org/licenses/gpl-faq.html#GPLIncompatibleLibs details on
|
||||
how to write such an exception to the GPL
|
||||
[3] = LGPL - GNU Lesser General Public License:
|
||||
http://www.gnu.org/licenses/lgpl.html
|
|
@ -1,912 +0,0 @@
|
|||
LATEST VERSION
|
||||
|
||||
You always find news about what's going on as well as the latest versions
|
||||
from the curl web pages, located at:
|
||||
|
||||
http://curl.haxx.se
|
||||
|
||||
SIMPLE USAGE
|
||||
|
||||
Get the main page from netscape's web-server:
|
||||
|
||||
curl http://www.netscape.com/
|
||||
|
||||
Get the README file the user's home directory at funet's ftp-server:
|
||||
|
||||
curl ftp://ftp.funet.fi/README
|
||||
|
||||
Get a web page from a server using port 8000:
|
||||
|
||||
curl http://www.weirdserver.com:8000/
|
||||
|
||||
Get a list of a directory of an FTP site:
|
||||
|
||||
curl ftp://cool.haxx.se/
|
||||
|
||||
Get the definition of curl from a dictionary:
|
||||
|
||||
curl dict://dict.org/m:curl
|
||||
|
||||
Fetch two documents at once:
|
||||
|
||||
curl ftp://cool.haxx.se/ http://www.weirdserver.com:8000/
|
||||
|
||||
Get a file off an FTPS server:
|
||||
|
||||
curl ftps://files.are.secure.com/secrets.txt
|
||||
|
||||
or use the more appropriate FTPS way to get the same file:
|
||||
|
||||
curl --ftp-ssl ftp://files.are.secure.com/secrets.txt
|
||||
|
||||
|
||||
DOWNLOAD TO A FILE
|
||||
|
||||
Get a web page and store in a local file:
|
||||
|
||||
curl -o thatpage.html http://www.netscape.com/
|
||||
|
||||
Get a web page and store in a local file, make the local file get the name
|
||||
of the remote document (if no file name part is specified in the URL, this
|
||||
will fail):
|
||||
|
||||
curl -O http://www.netscape.com/index.html
|
||||
|
||||
Fetch two files and store them with their remote names:
|
||||
|
||||
curl -O www.haxx.se/index.html -O curl.haxx.se/download.html
|
||||
|
||||
USING PASSWORDS
|
||||
|
||||
FTP
|
||||
|
||||
To ftp files using name+passwd, include them in the URL like:
|
||||
|
||||
curl ftp://name:passwd@machine.domain:port/full/path/to/file
|
||||
|
||||
or specify them with the -u flag like
|
||||
|
||||
curl -u name:passwd ftp://machine.domain:port/full/path/to/file
|
||||
|
||||
FTPS
|
||||
|
||||
It is just like for FTP, but you may also want to specify and use
|
||||
SSL-specific options for certificates etc.
|
||||
|
||||
Note that using FTPS:// as prefix is the "implicit" way as described in the
|
||||
standards while the recommended "explicit" way is done by using FTP:// and
|
||||
the --ftp-ssl option.
|
||||
|
||||
HTTP
|
||||
|
||||
The HTTP URL doesn't support user and password in the URL string. Curl
|
||||
does support that anyway to provide a ftp-style interface and thus you can
|
||||
pick a file like:
|
||||
|
||||
curl http://name:passwd@machine.domain/full/path/to/file
|
||||
|
||||
or specify user and password separately like in
|
||||
|
||||
curl -u name:passwd http://machine.domain/full/path/to/file
|
||||
|
||||
HTTP offers many different methods of authentication and curl supports
|
||||
several: Basic, Digest, NTLM and Negotiate. Without telling which method to
|
||||
use, curl defaults to Basic. You can also ask curl to pick the most secure
|
||||
ones out of the ones that the server accepts for the given URL, by using
|
||||
--anyauth.
|
||||
|
||||
NOTE! Since HTTP URLs don't support user and password, you can't use that
|
||||
style when using Curl via a proxy. You _must_ use the -u style fetch
|
||||
during such circumstances.
|
||||
|
||||
HTTPS
|
||||
|
||||
Probably most commonly used with private certificates, as explained below.
|
||||
|
||||
PROXY
|
||||
|
||||
Get an ftp file using a proxy named my-proxy that uses port 888:
|
||||
|
||||
curl -x my-proxy:888 ftp://ftp.leachsite.com/README
|
||||
|
||||
Get a file from a HTTP server that requires user and password, using the
|
||||
same proxy as above:
|
||||
|
||||
curl -u user:passwd -x my-proxy:888 http://www.get.this/
|
||||
|
||||
Some proxies require special authentication. Specify by using -U as above:
|
||||
|
||||
curl -U user:passwd -x my-proxy:888 http://www.get.this/
|
||||
|
||||
curl also supports SOCKS4 and SOCKS5 proxies with --socks4 and --socks5.
|
||||
|
||||
See also the environment variables Curl support that offer further proxy
|
||||
control.
|
||||
|
||||
RANGES
|
||||
|
||||
With HTTP 1.1 byte-ranges were introduced. Using this, a client can request
|
||||
to get only one or more subparts of a specified document. Curl supports
|
||||
this with the -r flag.
|
||||
|
||||
Get the first 100 bytes of a document:
|
||||
|
||||
curl -r 0-99 http://www.get.this/
|
||||
|
||||
Get the last 500 bytes of a document:
|
||||
|
||||
curl -r -500 http://www.get.this/
|
||||
|
||||
Curl also supports simple ranges for FTP files as well. Then you can only
|
||||
specify start and stop position.
|
||||
|
||||
Get the first 100 bytes of a document using FTP:
|
||||
|
||||
curl -r 0-99 ftp://www.get.this/README
|
||||
|
||||
UPLOADING
|
||||
|
||||
FTP
|
||||
|
||||
Upload all data on stdin to a specified ftp site:
|
||||
|
||||
curl -T - ftp://ftp.upload.com/myfile
|
||||
|
||||
Upload data from a specified file, login with user and password:
|
||||
|
||||
curl -T uploadfile -u user:passwd ftp://ftp.upload.com/myfile
|
||||
|
||||
Upload a local file to the remote site, and use the local file name remote
|
||||
too:
|
||||
|
||||
curl -T uploadfile -u user:passwd ftp://ftp.upload.com/
|
||||
|
||||
Upload a local file to get appended to the remote file using ftp:
|
||||
|
||||
curl -T localfile -a ftp://ftp.upload.com/remotefile
|
||||
|
||||
Curl also supports ftp upload through a proxy, but only if the proxy is
|
||||
configured to allow that kind of tunneling. If it does, you can run curl in
|
||||
a fashion similar to:
|
||||
|
||||
curl --proxytunnel -x proxy:port -T localfile ftp.upload.com
|
||||
|
||||
HTTP
|
||||
|
||||
Upload all data on stdin to a specified http site:
|
||||
|
||||
curl -T - http://www.upload.com/myfile
|
||||
|
||||
Note that the http server must have been configured to accept PUT before
|
||||
this can be done successfully.
|
||||
|
||||
For other ways to do http data upload, see the POST section below.
|
||||
|
||||
VERBOSE / DEBUG
|
||||
|
||||
If curl fails where it isn't supposed to, if the servers don't let you in,
|
||||
if you can't understand the responses: use the -v flag to get verbose
|
||||
fetching. Curl will output lots of info and what it sends and receives in
|
||||
order to let the user see all client-server interaction (but it won't show
|
||||
you the actual data).
|
||||
|
||||
curl -v ftp://ftp.upload.com/
|
||||
|
||||
To get even more details and information on what curl does, try using the
|
||||
--trace or --trace-ascii options with a given file name to log to, like
|
||||
this:
|
||||
|
||||
curl --trace trace.txt www.haxx.se
|
||||
|
||||
|
||||
DETAILED INFORMATION
|
||||
|
||||
Different protocols provide different ways of getting detailed information
|
||||
about specific files/documents. To get curl to show detailed information
|
||||
about a single file, you should use -I/--head option. It displays all
|
||||
available info on a single file for HTTP and FTP. The HTTP information is a
|
||||
lot more extensive.
|
||||
|
||||
For HTTP, you can get the header information (the same as -I would show)
|
||||
shown before the data by using -i/--include. Curl understands the
|
||||
-D/--dump-header option when getting files from both FTP and HTTP, and it
|
||||
will then store the headers in the specified file.
|
||||
|
||||
Store the HTTP headers in a separate file (headers.txt in the example):
|
||||
|
||||
curl --dump-header headers.txt curl.haxx.se
|
||||
|
||||
Note that headers stored in a separate file can be very useful at a later
|
||||
time if you want curl to use cookies sent by the server. More about that in
|
||||
the cookies section.
|
||||
|
||||
POST (HTTP)
|
||||
|
||||
It's easy to post data using curl. This is done using the -d <data>
|
||||
option. The post data must be urlencoded.
|
||||
|
||||
Post a simple "name" and "phone" guestbook.
|
||||
|
||||
curl -d "name=Rafael%20Sagula&phone=3320780" \
|
||||
http://www.where.com/guest.cgi
|
||||
|
||||
How to post a form with curl, lesson #1:
|
||||
|
||||
Dig out all the <input> tags in the form that you want to fill in. (There's
|
||||
a perl program called formfind.pl on the curl site that helps with this).
|
||||
|
||||
If there's a "normal" post, you use -d to post. -d takes a full "post
|
||||
string", which is in the format
|
||||
|
||||
<variable1>=<data1>&<variable2>=<data2>&...
|
||||
|
||||
The 'variable' names are the names set with "name=" in the <input> tags, and
|
||||
the data is the contents you want to fill in for the inputs. The data *must*
|
||||
be properly URL encoded. That means you replace space with + and that you
|
||||
write weird letters with %XX where XX is the hexadecimal representation of
|
||||
the letter's ASCII code.
|
||||
|
||||
Example:
|
||||
|
||||
(page located at http://www.formpost.com/getthis/
|
||||
|
||||
<form action="post.cgi" method="post">
|
||||
<input name=user size=10>
|
||||
<input name=pass type=password size=10>
|
||||
<input name=id type=hidden value="blablabla">
|
||||
<input name=ding value="submit">
|
||||
</form>
|
||||
|
||||
We want to enter user 'foobar' with password '12345'.
|
||||
|
||||
To post to this, you enter a curl command line like:
|
||||
|
||||
curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" (continues)
|
||||
http://www.formpost.com/getthis/post.cgi
|
||||
|
||||
|
||||
While -d uses the application/x-www-form-urlencoded mime-type, generally
|
||||
understood by CGI's and similar, curl also supports the more capable
|
||||
multipart/form-data type. This latter type supports things like file upload.
|
||||
|
||||
-F accepts parameters like -F "name=contents". If you want the contents to
|
||||
be read from a file, use <@filename> as contents. When specifying a file,
|
||||
you can also specify the file content type by appending ';type=<mime type>'
|
||||
to the file name. You can also post the contents of several files in one
|
||||
field. For example, the field name 'coolfiles' is used to send three files,
|
||||
with different content types using the following syntax:
|
||||
|
||||
curl -F "coolfiles=@fil1.gif;type=image/gif,fil2.txt,fil3.html" \
|
||||
http://www.post.com/postit.cgi
|
||||
|
||||
If the content-type is not specified, curl will try to guess from the file
|
||||
extension (it only knows a few), or use the previously specified type (from
|
||||
an earlier file if several files are specified in a list) or else it will
|
||||
using the default type 'text/plain'.
|
||||
|
||||
Emulate a fill-in form with -F. Let's say you fill in three fields in a
|
||||
form. One field is a file name which to post, one field is your name and one
|
||||
field is a file description. We want to post the file we have written named
|
||||
"cooltext.txt". To let curl do the posting of this data instead of your
|
||||
favourite browser, you have to read the HTML source of the form page and
|
||||
find the names of the input fields. In our example, the input field names
|
||||
are 'file', 'yourname' and 'filedescription'.
|
||||
|
||||
curl -F "file=@cooltext.txt" -F "yourname=Daniel" \
|
||||
-F "filedescription=Cool text file with cool text inside" \
|
||||
http://www.post.com/postit.cgi
|
||||
|
||||
To send two files in one post you can do it in two ways:
|
||||
|
||||
1. Send multiple files in a single "field" with a single field name:
|
||||
|
||||
curl -F "pictures=@dog.gif,cat.gif"
|
||||
|
||||
2. Send two fields with two field names:
|
||||
|
||||
curl -F "docpicture=@dog.gif" -F "catpicture=@cat.gif"
|
||||
|
||||
To send a field value literally without interpreting a leading '@'
|
||||
or '<', or an embedded ';type=', use --form-string instead of
|
||||
-F. This is recommended when the value is obtained from a user or
|
||||
some other unpredictable source. Under these circumstances, using
|
||||
-F instead of --form-string would allow a user to trick curl into
|
||||
uploading a file.
|
||||
|
||||
REFERRER
|
||||
|
||||
A HTTP request has the option to include information about which address
|
||||
that referred to actual page. Curl allows you to specify the
|
||||
referrer to be used on the command line. It is especially useful to
|
||||
fool or trick stupid servers or CGI scripts that rely on that information
|
||||
being available or contain certain data.
|
||||
|
||||
curl -e www.coolsite.com http://www.showme.com/
|
||||
|
||||
NOTE: The referer field is defined in the HTTP spec to be a full URL.
|
||||
|
||||
USER AGENT
|
||||
|
||||
A HTTP request has the option to include information about the browser
|
||||
that generated the request. Curl allows it to be specified on the command
|
||||
line. It is especially useful to fool or trick stupid servers or CGI
|
||||
scripts that only accept certain browsers.
|
||||
|
||||
Example:
|
||||
|
||||
curl -A 'Mozilla/3.0 (Win95; I)' http://www.nationsbank.com/
|
||||
|
||||
Other common strings:
|
||||
'Mozilla/3.0 (Win95; I)' Netscape Version 3 for Windows 95
|
||||
'Mozilla/3.04 (Win95; U)' Netscape Version 3 for Windows 95
|
||||
'Mozilla/2.02 (OS/2; U)' Netscape Version 2 for OS/2
|
||||
'Mozilla/4.04 [en] (X11; U; AIX 4.2; Nav)' NS for AIX
|
||||
'Mozilla/4.05 [en] (X11; U; Linux 2.0.32 i586)' NS for Linux
|
||||
|
||||
Note that Internet Explorer tries hard to be compatible in every way:
|
||||
'Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)' MSIE for W95
|
||||
|
||||
Mozilla is not the only possible User-Agent name:
|
||||
'Konqueror/1.0' KDE File Manager desktop client
|
||||
'Lynx/2.7.1 libwww-FM/2.14' Lynx command line browser
|
||||
|
||||
COOKIES
|
||||
|
||||
Cookies are generally used by web servers to keep state information at the
|
||||
client's side. The server sets cookies by sending a response line in the
|
||||
headers that looks like 'Set-Cookie: <data>' where the data part then
|
||||
typically contains a set of NAME=VALUE pairs (separated by semicolons ';'
|
||||
like "NAME1=VALUE1; NAME2=VALUE2;"). The server can also specify for what
|
||||
path the "cookie" should be used for (by specifying "path=value"), when the
|
||||
cookie should expire ("expire=DATE"), for what domain to use it
|
||||
("domain=NAME") and if it should be used on secure connections only
|
||||
("secure").
|
||||
|
||||
If you've received a page from a server that contains a header like:
|
||||
Set-Cookie: sessionid=boo123; path="/foo";
|
||||
|
||||
it means the server wants that first pair passed on when we get anything in
|
||||
a path beginning with "/foo".
|
||||
|
||||
Example, get a page that wants my name passed in a cookie:
|
||||
|
||||
curl -b "name=Daniel" www.sillypage.com
|
||||
|
||||
Curl also has the ability to use previously received cookies in following
|
||||
sessions. If you get cookies from a server and store them in a file in a
|
||||
manner similar to:
|
||||
|
||||
curl --dump-header headers www.example.com
|
||||
|
||||
... you can then in a second connect to that (or another) site, use the
|
||||
cookies from the 'headers' file like:
|
||||
|
||||
curl -b headers www.example.com
|
||||
|
||||
While saving headers to a file is a working way to store cookies, it is
|
||||
however error-prone and not the preferred way to do this. Instead, make curl
|
||||
save the incoming cookies using the well-known netscape cookie format like
|
||||
this:
|
||||
|
||||
curl -c cookies.txt www.example.com
|
||||
|
||||
Note that by specifying -b you enable the "cookie awareness" and with -L
|
||||
you can make curl follow a location: (which often is used in combination
|
||||
with cookies). So that if a site sends cookies and a location, you can
|
||||
use a non-existing file to trigger the cookie awareness like:
|
||||
|
||||
curl -L -b empty.txt www.example.com
|
||||
|
||||
The file to read cookies from must be formatted using plain HTTP headers OR
|
||||
as netscape's cookie file. Curl will determine what kind it is based on the
|
||||
file contents. In the above command, curl will parse the header and store
|
||||
the cookies received from www.example.com. curl will send to the server the
|
||||
stored cookies which match the request as it follows the location. The
|
||||
file "empty.txt" may be a nonexistent file.
|
||||
|
||||
Alas, to both read and write cookies from a netscape cookie file, you can
|
||||
set both -b and -c to use the same file:
|
||||
|
||||
curl -b cookies.txt -c cookies.txt www.example.com
|
||||
|
||||
PROGRESS METER
|
||||
|
||||
The progress meter exists to show a user that something actually is
|
||||
happening. The different fields in the output have the following meaning:
|
||||
|
||||
% Total % Received % Xferd Average Speed Time Curr.
|
||||
Dload Upload Total Current Left Speed
|
||||
0 151M 0 38608 0 0 9406 0 4:41:43 0:00:04 4:41:39 9287
|
||||
|
||||
From left-to-right:
|
||||
% - percentage completed of the whole transfer
|
||||
Total - total size of the whole expected transfer
|
||||
% - percentage completed of the download
|
||||
Received - currently downloaded amount of bytes
|
||||
% - percentage completed of the upload
|
||||
Xferd - currently uploaded amount of bytes
|
||||
Average Speed
|
||||
Dload - the average transfer speed of the download
|
||||
Average Speed
|
||||
Upload - the average transfer speed of the upload
|
||||
Time Total - expected time to complete the operation
|
||||
Time Current - time passed since the invoke
|
||||
Time Left - expected time left to completion
|
||||
Curr.Speed - the average transfer speed the last 5 seconds (the first
|
||||
5 seconds of a transfer is based on less time of course.)
|
||||
|
||||
The -# option will display a totally different progress bar that doesn't
|
||||
need much explanation!
|
||||
|
||||
SPEED LIMIT
|
||||
|
||||
Curl allows the user to set the transfer speed conditions that must be met
|
||||
to let the transfer keep going. By using the switch -y and -Y you
|
||||
can make curl abort transfers if the transfer speed is below the specified
|
||||
lowest limit for a specified time.
|
||||
|
||||
To have curl abort the download if the speed is slower than 3000 bytes per
|
||||
second for 1 minute, run:
|
||||
|
||||
curl -Y 3000 -y 60 www.far-away-site.com
|
||||
|
||||
This can very well be used in combination with the overall time limit, so
|
||||
that the above operation must be completed in whole within 30 minutes:
|
||||
|
||||
curl -m 1800 -Y 3000 -y 60 www.far-away-site.com
|
||||
|
||||
Forcing curl not to transfer data faster than a given rate is also possible,
|
||||
which might be useful if you're using a limited bandwidth connection and you
|
||||
don't want your transfer to use all of it (sometimes referred to as
|
||||
"bandwidth throttle").
|
||||
|
||||
Make curl transfer data no faster than 10 kilobytes per second:
|
||||
|
||||
curl --limit-rate 10K www.far-away-site.com
|
||||
|
||||
or
|
||||
|
||||
curl --limit-rate 10240 www.far-away-site.com
|
||||
|
||||
Or prevent curl from uploading data faster than 1 megabyte per second:
|
||||
|
||||
curl -T upload --limit-rate 1M ftp://uploadshereplease.com
|
||||
|
||||
When using the --limit-rate option, the transfer rate is regulated on a
|
||||
per-second basis, which will cause the total transfer speed to become lower
|
||||
than the given number. Sometimes of course substantially lower, if your
|
||||
transfer stalls during periods.
|
||||
|
||||
CONFIG FILE
|
||||
|
||||
Curl automatically tries to read the .curlrc file (or _curlrc file on win32
|
||||
systems) from the user's home dir on startup.
|
||||
|
||||
The config file could be made up with normal command line switches, but you
|
||||
can also specify the long options without the dashes to make it more
|
||||
readable. You can separate the options and the parameter with spaces, or
|
||||
with = or :. Comments can be used within the file. If the first letter on a
|
||||
line is a '#'-letter the rest of the line is treated as a comment.
|
||||
|
||||
If you want the parameter to contain spaces, you must inclose the entire
|
||||
parameter within double quotes ("). Within those quotes, you specify a
|
||||
quote as \".
|
||||
|
||||
NOTE: You must specify options and their arguments on the same line.
|
||||
|
||||
Example, set default time out and proxy in a config file:
|
||||
|
||||
# We want a 30 minute timeout:
|
||||
-m 1800
|
||||
# ... and we use a proxy for all accesses:
|
||||
proxy = proxy.our.domain.com:8080
|
||||
|
||||
White spaces ARE significant at the end of lines, but all white spaces
|
||||
leading up to the first characters of each line are ignored.
|
||||
|
||||
Prevent curl from reading the default file by using -q as the first command
|
||||
line parameter, like:
|
||||
|
||||
curl -q www.thatsite.com
|
||||
|
||||
Force curl to get and display a local help page in case it is invoked
|
||||
without URL by making a config file similar to:
|
||||
|
||||
# default url to get
|
||||
url = "http://help.with.curl.com/curlhelp.html"
|
||||
|
||||
You can specify another config file to be read by using the -K/--config
|
||||
flag. If you set config file name to "-" it'll read the config from stdin,
|
||||
which can be handy if you want to hide options from being visible in process
|
||||
tables etc:
|
||||
|
||||
echo "user = user:passwd" | curl -K - http://that.secret.site.com
|
||||
|
||||
EXTRA HEADERS
|
||||
|
||||
When using curl in your own very special programs, you may end up needing
|
||||
to pass on your own custom headers when getting a web page. You can do
|
||||
this by using the -H flag.
|
||||
|
||||
Example, send the header "X-you-and-me: yes" to the server when getting a
|
||||
page:
|
||||
|
||||
curl -H "X-you-and-me: yes" www.love.com
|
||||
|
||||
This can also be useful in case you want curl to send a different text in a
|
||||
header than it normally does. The -H header you specify then replaces the
|
||||
header curl would normally send. If you replace an internal header with an
|
||||
empty one, you prevent that header from being sent. To prevent the Host:
|
||||
header from being used:
|
||||
|
||||
curl -H "Host:" www.server.com
|
||||
|
||||
FTP and PATH NAMES
|
||||
|
||||
Do note that when getting files with the ftp:// URL, the given path is
|
||||
relative the directory you enter. To get the file 'README' from your home
|
||||
directory at your ftp site, do:
|
||||
|
||||
curl ftp://user:passwd@my.site.com/README
|
||||
|
||||
But if you want the README file from the root directory of that very same
|
||||
site, you need to specify the absolute file name:
|
||||
|
||||
curl ftp://user:passwd@my.site.com//README
|
||||
|
||||
(I.e with an extra slash in front of the file name.)
|
||||
|
||||
FTP and firewalls
|
||||
|
||||
The FTP protocol requires one of the involved parties to open a second
|
||||
connction as soon as data is about to get transfered. There are two ways to
|
||||
do this.
|
||||
|
||||
The default way for curl is to issue the PASV command which causes the
|
||||
server to open another port and await another connection performed by the
|
||||
client. This is good if the client is behind a firewall that don't allow
|
||||
incoming connections.
|
||||
|
||||
curl ftp.download.com
|
||||
|
||||
If the server for example, is behind a firewall that don't allow connections
|
||||
on other ports than 21 (or if it just doesn't support the PASV command), the
|
||||
other way to do it is to use the PORT command and instruct the server to
|
||||
connect to the client on the given (as parameters to the PORT command) IP
|
||||
number and port.
|
||||
|
||||
The -P flag to curl supports a few different options. Your machine may have
|
||||
several IP-addresses and/or network interfaces and curl allows you to select
|
||||
which of them to use. Default address can also be used:
|
||||
|
||||
curl -P - ftp.download.com
|
||||
|
||||
Download with PORT but use the IP address of our 'le0' interface (this does
|
||||
not work on windows):
|
||||
|
||||
curl -P le0 ftp.download.com
|
||||
|
||||
Download with PORT but use 192.168.0.10 as our IP address to use:
|
||||
|
||||
curl -P 192.168.0.10 ftp.download.com
|
||||
|
||||
NETWORK INTERFACE
|
||||
|
||||
Get a web page from a server using a specified port for the interface:
|
||||
|
||||
curl --interface eth0:1 http://www.netscape.com/
|
||||
|
||||
or
|
||||
|
||||
curl --interface 192.168.1.10 http://www.netscape.com/
|
||||
|
||||
HTTPS
|
||||
|
||||
Secure HTTP requires SSL libraries to be installed and used when curl is
|
||||
built. If that is done, curl is capable of retrieving and posting documents
|
||||
using the HTTPS protocol.
|
||||
|
||||
Example:
|
||||
|
||||
curl https://www.secure-site.com
|
||||
|
||||
Curl is also capable of using your personal certificates to get/post files
|
||||
from sites that require valid certificates. The only drawback is that the
|
||||
certificate needs to be in PEM-format. PEM is a standard and open format to
|
||||
store certificates with, but it is not used by the most commonly used
|
||||
browsers (Netscape and MSIE both use the so called PKCS#12 format). If you
|
||||
want curl to use the certificates you use with your (favourite) browser, you
|
||||
may need to download/compile a converter that can convert your browser's
|
||||
formatted certificates to PEM formatted ones. This kind of converter is
|
||||
included in recent versions of OpenSSL, and for older versions Dr Stephen
|
||||
N. Henson has written a patch for SSLeay that adds this functionality. You
|
||||
can get his patch (that requires an SSLeay installation) from his site at:
|
||||
http://www.drh-consultancy.demon.co.uk/
|
||||
|
||||
Example on how to automatically retrieve a document using a certificate with
|
||||
a personal password:
|
||||
|
||||
curl -E /path/to/cert.pem:password https://secure.site.com/
|
||||
|
||||
If you neglect to specify the password on the command line, you will be
|
||||
prompted for the correct password before any data can be received.
|
||||
|
||||
Many older SSL-servers have problems with SSLv3 or TLS, that newer versions
|
||||
of OpenSSL etc is using, therefore it is sometimes useful to specify what
|
||||
SSL-version curl should use. Use -3, -2 or -1 to specify that exact SSL
|
||||
version to use (for SSLv3, SSLv2 or TLSv1 respectively):
|
||||
|
||||
curl -2 https://secure.site.com/
|
||||
|
||||
Otherwise, curl will first attempt to use v3 and then v2.
|
||||
|
||||
To use OpenSSL to convert your favourite browser's certificate into a PEM
|
||||
formatted one that curl can use, do something like this (assuming netscape,
|
||||
but IE is likely to work similarly):
|
||||
|
||||
You start with hitting the 'security' menu button in netscape.
|
||||
|
||||
Select 'certificates->yours' and then pick a certificate in the list
|
||||
|
||||
Press the 'export' button
|
||||
|
||||
enter your PIN code for the certs
|
||||
|
||||
select a proper place to save it
|
||||
|
||||
Run the 'openssl' application to convert the certificate. If you cd to the
|
||||
openssl installation, you can do it like:
|
||||
|
||||
# ./apps/openssl pkcs12 -in [file you saved] -clcerts -out [PEMfile]
|
||||
|
||||
|
||||
RESUMING FILE TRANSFERS
|
||||
|
||||
To continue a file transfer where it was previously aborted, curl supports
|
||||
resume on http(s) downloads as well as ftp uploads and downloads.
|
||||
|
||||
Continue downloading a document:
|
||||
|
||||
curl -C - -o file ftp://ftp.server.com/path/file
|
||||
|
||||
Continue uploading a document(*1):
|
||||
|
||||
curl -C - -T file ftp://ftp.server.com/path/file
|
||||
|
||||
Continue downloading a document from a web server(*2):
|
||||
|
||||
curl -C - -o file http://www.server.com/
|
||||
|
||||
(*1) = This requires that the ftp server supports the non-standard command
|
||||
SIZE. If it doesn't, curl will say so.
|
||||
|
||||
(*2) = This requires that the web server supports at least HTTP/1.1. If it
|
||||
doesn't, curl will say so.
|
||||
|
||||
TIME CONDITIONS
|
||||
|
||||
HTTP allows a client to specify a time condition for the document it
|
||||
requests. It is If-Modified-Since or If-Unmodified-Since. Curl allow you to
|
||||
specify them with the -z/--time-cond flag.
|
||||
|
||||
For example, you can easily make a download that only gets performed if the
|
||||
remote file is newer than a local copy. It would be made like:
|
||||
|
||||
curl -z local.html http://remote.server.com/remote.html
|
||||
|
||||
Or you can download a file only if the local file is newer than the remote
|
||||
one. Do this by prepending the date string with a '-', as in:
|
||||
|
||||
curl -z -local.html http://remote.server.com/remote.html
|
||||
|
||||
You can specify a "free text" date as condition. Tell curl to only download
|
||||
the file if it was updated since yesterday:
|
||||
|
||||
curl -z yesterday http://remote.server.com/remote.html
|
||||
|
||||
Curl will then accept a wide range of date formats. You always make the date
|
||||
check the other way around by prepending it with a dash '-'.
|
||||
|
||||
DICT
|
||||
|
||||
For fun try
|
||||
|
||||
curl dict://dict.org/m:curl
|
||||
curl dict://dict.org/d:heisenbug:jargon
|
||||
curl dict://dict.org/d:daniel:web1913
|
||||
|
||||
Aliases for 'm' are 'match' and 'find', and aliases for 'd' are 'define'
|
||||
and 'lookup'. For example,
|
||||
|
||||
curl dict://dict.org/find:curl
|
||||
|
||||
Commands that break the URL description of the RFC (but not the DICT
|
||||
protocol) are
|
||||
|
||||
curl dict://dict.org/show:db
|
||||
curl dict://dict.org/show:strat
|
||||
|
||||
Authentication is still missing (but this is not required by the RFC)
|
||||
|
||||
LDAP
|
||||
|
||||
If you have installed the OpenLDAP library, curl can take advantage of it
|
||||
and offer ldap:// support.
|
||||
|
||||
LDAP is a complex thing and writing an LDAP query is not an easy task. I do
|
||||
advice you to dig up the syntax description for that elsewhere. Two places
|
||||
that might suit you are:
|
||||
|
||||
Netscape's "Netscape Directory SDK 3.0 for C Programmer's Guide Chapter 10:
|
||||
Working with LDAP URLs":
|
||||
http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm
|
||||
|
||||
RFC 2255, "The LDAP URL Format" http://curl.haxx.se/rfc/rfc2255.txt
|
||||
|
||||
To show you an example, this is now I can get all people from my local LDAP
|
||||
server that has a certain sub-domain in their email address:
|
||||
|
||||
curl -B "ldap://ldap.frontec.se/o=frontec??sub?mail=*sth.frontec.se"
|
||||
|
||||
If I want the same info in HTML format, I can get it by not using the -B
|
||||
(enforce ASCII) flag.
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
|
||||
Curl reads and understands the following environment variables:
|
||||
|
||||
http_proxy, HTTPS_PROXY, FTP_PROXY
|
||||
|
||||
They should be set for protocol-specific proxies. General proxy should be
|
||||
set with
|
||||
|
||||
ALL_PROXY
|
||||
|
||||
A comma-separated list of host names that shouldn't go through any proxy is
|
||||
set in (only an asterisk, '*' matches all hosts)
|
||||
|
||||
NO_PROXY
|
||||
|
||||
If a tail substring of the domain-path for a host matches one of these
|
||||
strings, transactions with that node will not be proxied.
|
||||
|
||||
|
||||
The usage of the -x/--proxy flag overrides the environment variables.
|
||||
|
||||
NETRC
|
||||
|
||||
Unix introduced the .netrc concept a long time ago. It is a way for a user
|
||||
to specify name and password for commonly visited ftp sites in a file so
|
||||
that you don't have to type them in each time you visit those sites. You
|
||||
realize this is a big security risk if someone else gets hold of your
|
||||
passwords, so therefore most unix programs won't read this file unless it is
|
||||
only readable by yourself (curl doesn't care though).
|
||||
|
||||
Curl supports .netrc files if told so (using the -n/--netrc and
|
||||
--netrc-optional options). This is not restricted to only ftp,
|
||||
but curl can use it for all protocols where authentication is used.
|
||||
|
||||
A very simple .netrc file could look something like:
|
||||
|
||||
machine curl.haxx.se login iamdaniel password mysecret
|
||||
|
||||
CUSTOM OUTPUT
|
||||
|
||||
To better allow script programmers to get to know about the progress of
|
||||
curl, the -w/--write-out option was introduced. Using this, you can specify
|
||||
what information from the previous transfer you want to extract.
|
||||
|
||||
To display the amount of bytes downloaded together with some text and an
|
||||
ending newline:
|
||||
|
||||
curl -w 'We downloaded %{size_download} bytes\n' www.download.com
|
||||
|
||||
KERBEROS4 FTP TRANSFER
|
||||
|
||||
Curl supports kerberos4 for FTP transfers. You need the kerberos package
|
||||
installed and used at curl build time for it to be used.
|
||||
|
||||
First, get the krb-ticket the normal way, like with the kauth tool. Then use
|
||||
curl in way similar to:
|
||||
|
||||
curl --krb4 private ftp://krb4site.com -u username:fakepwd
|
||||
|
||||
There's no use for a password on the -u switch, but a blank one will make
|
||||
curl ask for one and you already entered the real password to kauth.
|
||||
|
||||
TELNET
|
||||
|
||||
The curl telnet support is basic and very easy to use. Curl passes all data
|
||||
passed to it on stdin to the remote server. Connect to a remote telnet
|
||||
server using a command line similar to:
|
||||
|
||||
curl telnet://remote.server.com
|
||||
|
||||
And enter the data to pass to the server on stdin. The result will be sent
|
||||
to stdout or to the file you specify with -o.
|
||||
|
||||
You might want the -N/--no-buffer option to switch off the buffered output
|
||||
for slow connections or similar.
|
||||
|
||||
Pass options to the telnet protocol negotiation, by using the -t option. To
|
||||
tell the server we use a vt100 terminal, try something like:
|
||||
|
||||
curl -tTTYPE=vt100 telnet://remote.server.com
|
||||
|
||||
Other interesting options for it -t include:
|
||||
|
||||
- XDISPLOC=<X display> Sets the X display location.
|
||||
|
||||
- NEW_ENV=<var,val> Sets an environment variable.
|
||||
|
||||
NOTE: the telnet protocol does not specify any way to login with a specified
|
||||
user and password so curl can't do that automatically. To do that, you need
|
||||
to track when the login prompt is received and send the username and
|
||||
password accordingly.
|
||||
|
||||
PERSISTENT CONNECTIONS
|
||||
|
||||
Specifying multiple files on a single command line will make curl transfer
|
||||
all of them, one after the other in the specified order.
|
||||
|
||||
libcurl will attempt to use persistent connections for the transfers so that
|
||||
the second transfer to the same host can use the same connection that was
|
||||
already initiated and was left open in the previous transfer. This greatly
|
||||
decreases connection time for all but the first transfer and it makes a far
|
||||
better use of the network.
|
||||
|
||||
Note that curl cannot use persistent connections for transfers that are used
|
||||
in subsequence curl invokes. Try to stuff as many URLs as possible on the
|
||||
same command line if they are using the same host, as that'll make the
|
||||
transfers faster. If you use a http proxy for file transfers, practically
|
||||
all transfers will be persistent.
|
||||
|
||||
MULTIPLE TRANSFERS WITH A SINGLE COMMAND LINE
|
||||
|
||||
As is mentioned above, you can download multiple files with one command line
|
||||
by simply adding more URLs. If you want those to get saved to a local file
|
||||
instead of just printed to stdout, you need to add one save option for each
|
||||
URL you specify. Note that this also goes for the -O option.
|
||||
|
||||
For example: get two files and use -O for the first and a custom file
|
||||
name for the second:
|
||||
|
||||
curl -O http://url.com/file.txt ftp://ftp.com/moo.exe -o moo.jpg
|
||||
|
||||
You can also upload multiple files in a similar fashion:
|
||||
|
||||
curl -T local1 ftp://ftp.com/moo.exe -T local2 ftp://ftp.com/moo2.txt
|
||||
|
||||
MAILING LISTS
|
||||
|
||||
For your convenience, we have several open mailing lists to discuss curl,
|
||||
its development and things relevant to this. Get all info at
|
||||
http://curl.haxx.se/mail/. Some of the lists available are:
|
||||
|
||||
curl-users
|
||||
|
||||
Users of the command line tool. How to use it, what doesn't work, new
|
||||
features, related tools, questions, news, installations, compilations,
|
||||
running, porting etc.
|
||||
|
||||
curl-library
|
||||
|
||||
Developers using or developing libcurl. Bugs, extensions, improvements.
|
||||
|
||||
curl-announce
|
||||
|
||||
Low-traffic. Only receives announcements of new public versions. At worst,
|
||||
that makes something like one or two mails per month, but usually only one
|
||||
mail every second month.
|
||||
|
||||
curl-and-php
|
||||
|
||||
Using the curl functions in PHP. Everything curl with a PHP angle. Or PHP
|
||||
with a curl angle.
|
||||
|
||||
curl-and-python
|
||||
|
||||
Python hackers using curl with or without the python binding pycurl.
|
||||
|
||||
Please direct curl questions, feature requests and trouble reports to one of
|
||||
these mailing lists instead of mailing any individual.
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# $Id: Makefile.am,v 1.36 2005/10/28 21:34:51 bagder Exp $
|
||||
#
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
man_MANS = curl.1 curl-config.1
|
||||
GENHTMLPAGES = curl.html curl-config.html
|
||||
PDFPAGES = curl.pdf curl-config.pdf
|
||||
|
||||
HTMLPAGES = $(GENHTMLPAGES) index.html
|
||||
|
||||
SUBDIRS = examples libcurl
|
||||
|
||||
CLEANFILES = $(GENHTMLPAGES) $(PDFPAGES)
|
||||
|
||||
EXTRA_DIST = MANUAL BUGS CONTRIBUTE FAQ FEATURES INTERNALS SSLCERTS \
|
||||
README.win32 RESOURCES TODO TheArtOfHttpScripting THANKS VERSIONS \
|
||||
KNOWN_BUGS BINDINGS $(man_MANS) $(HTMLPAGES) HISTORY INSTALL \
|
||||
$(PDFPAGES) LICENSE-MIXING README.netware DISTRO-DILEMMA INSTALL.devcpp
|
||||
|
||||
MAN2HTML= roffit < $< >$@
|
||||
|
||||
SUFFIXES = .1 .html .pdf
|
||||
|
||||
html: $(HTMLPAGES)
|
||||
cd libcurl; make html
|
||||
|
||||
pdf: $(PDFPAGES)
|
||||
cd libcurl; make pdf
|
||||
|
||||
.1.html:
|
||||
$(MAN2HTML)
|
||||
|
||||
.1.pdf:
|
||||
@(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \
|
||||
groff -Tps -man $< >$$foo.ps; \
|
||||
ps2pdf $$foo.ps $@; \
|
||||
rm $$foo.ps; \
|
||||
echo "converted $< to $@")
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
README.netware
|
||||
|
||||
Read the README file first.
|
||||
|
||||
Curl has been successfully compiled with gcc / nlmconv on different flavours
|
||||
of Linux as well as with the official Metrowerks CodeWarrior compiler.
|
||||
While not being the main development target, a continously growing share of
|
||||
curl users are NetWare-based, specially also consuming the lib from PHP.
|
||||
|
||||
The unix-style man pages are tricky to read on windows, so therefore are all
|
||||
those pages converted to HTML as well as pdf, and included in the release
|
||||
archives.
|
||||
|
||||
The main curl.1 man page is also "built-in" in the command line tool. Use a
|
||||
command line similar to this in order to extract a separate text file:
|
||||
|
||||
curl -M >manual.txt
|
||||
|
||||
Read the INSTALL file for instructions how to compile curl self.
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
README.win32
|
||||
|
||||
Read the README file first.
|
||||
|
||||
Curl has been compiled, built and run on all sorts of Windows and win32
|
||||
systems. While not being the main develop target, a fair share of curl users
|
||||
are win32-based.
|
||||
|
||||
The unix-style man pages are tricky to read on windows, so therefore are all
|
||||
those pages converted to HTML as well as pdf, and included in the release
|
||||
archives.
|
||||
|
||||
The main curl.1 man page is also "built-in" in the command line tool. Use a
|
||||
command line similar to this in order to extract a separate text file:
|
||||
|
||||
curl -M >manual.txt
|
|
@ -1,72 +0,0 @@
|
|||
_ _ ____ _
|
||||
Project ___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
|
||||
This document lists documents and standards used by curl.
|
||||
|
||||
RFC 959 - The FTP protocol
|
||||
|
||||
RFC 1635 - How to Use Anonymous FTP
|
||||
|
||||
RFC 1738 - Uniform Resource Locators
|
||||
|
||||
RFC 1777 - defines the LDAP protocol
|
||||
|
||||
RFC 1808 - Relative Uniform Resource Locators
|
||||
|
||||
RFC 1867 - Form-based File Upload in HTML
|
||||
|
||||
RFC 1950 - ZLIB Compressed Data Format Specification
|
||||
|
||||
RFC 1951 - DEFLATE Compressed Data Format Specification
|
||||
|
||||
RFC 1952 - gzip compression format
|
||||
|
||||
RFC 1959 - LDAP URL syntax
|
||||
|
||||
RFC 2045-2049 - Everything you need to know about MIME! (needed for form
|
||||
based upload)
|
||||
|
||||
RFC 2068 - HTTP 1.1 (obsoleted by RFC 2616)
|
||||
|
||||
RFC 2109 - HTTP State Management Mechanism (cookie stuff)
|
||||
- Also, read Netscape's specification at
|
||||
http://curl.haxx.se/rfc/cookie_spec.html
|
||||
|
||||
RFC 2183 - The Content-Disposition Header Field
|
||||
|
||||
RFC 2229 - A Dictionary Server Protocol
|
||||
|
||||
RFC 2255 - Newer LDAP URL syntax document.
|
||||
|
||||
RFC 2231 - MIME Parameter Value and Encoded Word Extensions:
|
||||
Character Sets, Languages, and Continuations
|
||||
|
||||
RFC 2388 - "Returning Values from Forms: multipart/form-data"
|
||||
Use this as an addition to the RFC1867
|
||||
|
||||
RFC 2396 - "Uniform Resource Identifiers: Generic Syntax and Semantics" This
|
||||
one obsoletes RFC 1738, but since RFC 1738 is often mentioned
|
||||
I've left it in this list.
|
||||
|
||||
RFC 2428 - FTP Extensions for IPv6 and NATs
|
||||
|
||||
RFC 2577 - FTP Security Considerations
|
||||
|
||||
RFC 2616 - HTTP 1.1, the latest
|
||||
|
||||
RFC 2617 - HTTP Authentication
|
||||
|
||||
RFC 2718 - Guidelines for new URL Schemes
|
||||
|
||||
RFC 2732 - Format for Literal IPv6 Addresses in URL's
|
||||
|
||||
RFC 2818 - HTTP Over TLS (TLS is the successor to SSL)
|
||||
|
||||
RFC 2964 - Use of HTTP State Management
|
||||
|
||||
RFC 2965 - HTTP State Management Mechanism. Cookies. Obsoletes RFC2109
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
Peer SSL Certificate Verification
|
||||
=================================
|
||||
|
||||
libcurl performs peer SSL certificate verification by default. This is done by
|
||||
installing a default CA cert bundle on 'make install' (or similar), that CA
|
||||
bundle package is used by default on operations against SSL servers.
|
||||
|
||||
If you communicate with HTTPS or FTPS servers using certificates that are
|
||||
signed by CAs present in the bundle, you can be sure that the remote server
|
||||
really is the one it claims to be.
|
||||
|
||||
If the remote server uses a self-signed certificate, if you don't install
|
||||
curl's CA cert bundle, if the server uses a certificate signed by a CA that
|
||||
isn't included in the bundle or if the remote host is an impostor
|
||||
impersonating your favorite site, and you want to transfer files from this
|
||||
server, do one of the following:
|
||||
|
||||
1. Tell libcurl to *not* verify the peer. With libcurl you disable with with
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
|
||||
With the curl command line tool, you disable this with -k/--insecure.
|
||||
|
||||
2. Get a CA certificate that can verify the remote server and use the proper
|
||||
option to point out this CA cert for verification when connecting. For
|
||||
libcurl hackers: curl_easy_setopt(curl, CURLOPT_CAPATH, capath);
|
||||
|
||||
With the curl command line tool: --cacert [file]
|
||||
|
||||
3. Add the CA cert for your server to the existing default CA cert bundle.
|
||||
The default path of the CA bundle installed with the curl package is:
|
||||
/usr/local/share/curl/curl-ca-bundle.crt, which can be changed by running
|
||||
configure with the --with-ca-bundle option pointing out the path of your
|
||||
choice.
|
||||
|
||||
To do this, you need to get the CA cert for your server in PEM format and
|
||||
then append that to your CA cert bundle.
|
||||
|
||||
If you use Internet Explorer, this is one way to get extract the CA cert
|
||||
for a particular server:
|
||||
|
||||
o View the certificate by double-clicking the padlock
|
||||
o Find out where the CA certificate is kept (Certificate>
|
||||
Authority Information Access>URL)
|
||||
o Get a copy of the crt file using curl
|
||||
o Convert it from crt to PEM using the openssl tool:
|
||||
openssl x509 -inform DES -in yourdownloaded.crt \
|
||||
-out outcert.pem -text
|
||||
o Append the 'outcert.pem' to the CA cert bundle or use it stand-alone
|
||||
as described below.
|
||||
|
||||
(Thanks to Frankie V for this description)
|
||||
|
||||
If you use the 'openssl' tool, this is one way to get extract the CA cert
|
||||
for a particular server:
|
||||
|
||||
o openssl s_client -connect xxxxx.com:443 |tee logfile
|
||||
o type "QUIT", followed by the "ENTER" key
|
||||
o The certificate will have "BEGIN CERTIFICATE" and "END CERTIFICATE"
|
||||
markers.
|
||||
o If you want to see the data in the certificate, you can do: "openssl
|
||||
x509 -inform PEM -in certfile -text -out certdata" where certfile is
|
||||
the cert you extracted from logfile. Look in certdata.
|
||||
o If you want to trust the certificate, you can append it to your
|
||||
cert_bundle or use it stand-alone as described. Just remember that the
|
||||
security is no better than the way you obtained the certificate.
|
||||
|
||||
(Thanks to Doug Kaufman for this description)
|
||||
|
||||
4. If you're using the curl command line tool, you can specify your own CA
|
||||
cert path by setting the environment variable CURL_CA_BUNDLE to the path
|
||||
of your choice.
|
||||
|
||||
If you're using the curl command line tool on Windows, curl will search
|
||||
for a CA cert file named "curl-ca-bundle.crt" in these directories and in
|
||||
this order:
|
||||
1. application's directory
|
||||
2. current working directory
|
||||
3. Windows System directory (e.g. C:\windows\system32)
|
||||
4. Windows Directory (e.g. C:\windows)
|
||||
5. all directories along %PATH%
|
||||
|
||||
5. Get a better/different/newer CA cert bundle! One option is to extract the
|
||||
one a recent Mozilla browser uses, by following the instruction found
|
||||
here:
|
||||
|
||||
http://curl.haxx.se/docs/caextract.html
|
||||
|
||||
Neglecting to use one of the above methods when dealing with a server using a
|
||||
certificate that isn't signed by one of the certificates in the installed CA
|
||||
cert bundle, will cause SSL to report an error ("certificate verify failed")
|
||||
during the handshake and SSL will then refuse further communication with that
|
||||
server.
|
|
@ -1,521 +0,0 @@
|
|||
This project has been alive for many years. Countless people have provided
|
||||
feedback that have improved curl. Here follows a list of people that have
|
||||
contributed (a-z order).
|
||||
|
||||
If you have contributed but are missing here, please let us know!
|
||||
|
||||
Adrian Schuur
|
||||
Alan Pinstein
|
||||
Albert Chin-A-Young
|
||||
Albert Choy
|
||||
Ale Vesely
|
||||
Aleksandar Milivojevic
|
||||
Alex Neblett
|
||||
Alex Suykov
|
||||
Alex aka WindEagle
|
||||
Alexander Kourakos
|
||||
Alexander Krasnostavsky
|
||||
Alexander Lazic
|
||||
Alexander Zhuravlev
|
||||
Alexis Carvalho
|
||||
Amol Pattekar
|
||||
Andi Jahja
|
||||
Andreas Damm
|
||||
Andreas Ntaflos
|
||||
Andreas Olsson
|
||||
Andreas Rieke
|
||||
Andres Garcia
|
||||
Andrew Benham
|
||||
Andrew Bushnell
|
||||
Andrew Francis
|
||||
Andrew Fuller
|
||||
Andrés García
|
||||
Andy Cedilnik
|
||||
Andy Serpa
|
||||
Angus Mackay
|
||||
Antoine Calando
|
||||
Anton Kalmykov
|
||||
Arkadiusz Miskiewicz
|
||||
Arve Knudsen
|
||||
Ates Goral
|
||||
Augustus Saunders
|
||||
Avery Fay
|
||||
Ben Greear
|
||||
Ben Madsen
|
||||
Benjamin Gerard
|
||||
Bertrand Demiddelaer
|
||||
Bjorn Reese
|
||||
Björn Stenberg
|
||||
Bob Schader
|
||||
Brad Burdick
|
||||
Bradford Bruce
|
||||
Brent Beardsley
|
||||
Brian Akins
|
||||
Brian Dessent
|
||||
Brian R Duffy
|
||||
Bruce Mitchener
|
||||
Bryan Henderson
|
||||
Bryan Kemp
|
||||
Caolan McNamara
|
||||
Casey O'Donnell
|
||||
Chih-Chung Chang
|
||||
Chris "Bob Bob"
|
||||
Chris Combes
|
||||
Chris Gaukroger
|
||||
Chris Maltby
|
||||
Christian Kurz
|
||||
Christian Robottom Reis
|
||||
Christophe Demory
|
||||
Christophe Legry
|
||||
Christopher R. Palmer
|
||||
Clarence Gardner
|
||||
Clifford Wolf
|
||||
Cody Jones
|
||||
Colin Watson
|
||||
Colm Buckley
|
||||
Cory Nelson
|
||||
Craig Davison
|
||||
Craig Markwardt
|
||||
Cris Bailiff
|
||||
Cyrill Osterwalder
|
||||
Damien Adant
|
||||
Dan Becker
|
||||
Dan C
|
||||
Dan Fandrich
|
||||
Dan Nelson
|
||||
Dan Torop
|
||||
Dan Zitter
|
||||
Daniel Stenberg
|
||||
Daniel at touchtunes
|
||||
Darryl House
|
||||
Dave Dribin
|
||||
Dave Halbakken
|
||||
Dave Hamilton
|
||||
Dave May
|
||||
David Byron
|
||||
David Cohen
|
||||
David Eriksson
|
||||
David Houlder
|
||||
David Hull
|
||||
David J Meyer
|
||||
David James
|
||||
David Kimdon
|
||||
David Lang
|
||||
David LeBlanc
|
||||
David McCreedy
|
||||
David Odin
|
||||
David Phillips
|
||||
David Shaw
|
||||
David Tarendash
|
||||
David Thiel
|
||||
David Yan
|
||||
Detlef Schmier
|
||||
Diego Casorran
|
||||
Dima Barsky
|
||||
Dimitris Sarris
|
||||
Dinar
|
||||
Dirk Eddelbuettel
|
||||
Dirk Manske
|
||||
Dmitry Bartsevich
|
||||
Dolbneff A.V
|
||||
Domenico Andreoli
|
||||
Dominick Meglio
|
||||
Doug Kaufman
|
||||
Doug Porter
|
||||
Douglas E. Wegscheid
|
||||
Douglas R. Horner
|
||||
Dov Murik
|
||||
Duane Cathey
|
||||
Dustin Boswell
|
||||
Dylan Ellicott
|
||||
Dylan Salisbury
|
||||
Early Ehlinger
|
||||
Edin Kadribasic
|
||||
Ellis Pritchard
|
||||
Emiliano Ida
|
||||
Enrico Scholz
|
||||
Enrik Berkhan
|
||||
Eric Cooper
|
||||
Eric Lavigne
|
||||
Eric Melville
|
||||
Eric Rautman
|
||||
Eric Thelin
|
||||
Eric Vergnaud
|
||||
Eric Young
|
||||
Erick Nuwendam
|
||||
Erwan Legrand
|
||||
Erwin Authried
|
||||
Eugene Kotlyarov
|
||||
Evan Jordan
|
||||
Fabrizio Ammollo
|
||||
Fedor Karpelevitch
|
||||
Felix von Leitner
|
||||
Florian Schoppmann
|
||||
Forrest Cahoon
|
||||
Frank Keeney
|
||||
Frank Ticheler
|
||||
Fred New
|
||||
Fred Noz
|
||||
Frederic Lepied
|
||||
Gautam Mani
|
||||
Gaz Iqbal
|
||||
Georg Horn
|
||||
Georg Huettenegger
|
||||
Georg Wicherski
|
||||
Gerd v. Egidy
|
||||
Gerhard Herre
|
||||
Giaslas Georgios
|
||||
Gilad
|
||||
Gilbert Ramirez Jr.
|
||||
Gisle Vanem
|
||||
Giuseppe Attardi
|
||||
Giuseppe D'Ambrosio
|
||||
Glen Nakamura
|
||||
Glen Scott
|
||||
Greg Hewgill
|
||||
Greg Onufer
|
||||
Grigory Entin
|
||||
Guenole Bescon
|
||||
Guillaume Arluison
|
||||
Gustaf Hui
|
||||
Gwenole Beauchesne
|
||||
Götz Babin-Ebell
|
||||
Günter Knauf
|
||||
Hamish Mackenzie
|
||||
Hanno Kranzhoff
|
||||
Hans Steegers
|
||||
Hardeep Singh
|
||||
Harshal Pradhan
|
||||
Heikki Korpela
|
||||
Henrik Storner
|
||||
Hzhijun
|
||||
Ian Ford
|
||||
Ian Gulliver
|
||||
Ian Wilkes
|
||||
Ignacio Vazquez-Abrams
|
||||
Igor Polyakov
|
||||
Ilguiz Latypov
|
||||
Ilja van Sprundel
|
||||
Ingmar Runge
|
||||
Ingo Ralf Blum
|
||||
Ingo Wilken
|
||||
Jacky Lam
|
||||
Jacob Meuser
|
||||
James Bursa
|
||||
James Clancy
|
||||
James Cone
|
||||
James Gallagher
|
||||
James Griffiths
|
||||
James MacMillan
|
||||
Jamie Lokier
|
||||
Jamie Newton
|
||||
Jamie Wilkinson
|
||||
Jan Kunder
|
||||
Jari Sundell
|
||||
Jason S. Priebe
|
||||
Jaz Fresh
|
||||
Jean Jacques Drouin
|
||||
Jean-Claude Chauve
|
||||
Jean-Louis Lemaire
|
||||
Jean-Marc Ranger
|
||||
Jean-Philippe Barrette-LaPierre
|
||||
Jeff Lawson
|
||||
Jeff Phillips
|
||||
Jeff Pohlmeyer
|
||||
Jeffrey Pohlmeyer
|
||||
Jeremy Friesner
|
||||
Jesper Jensen
|
||||
Jesse Noller
|
||||
Jim Drash
|
||||
Joe Halpin
|
||||
Joel Chen
|
||||
Johan Anderson
|
||||
Johan Nilsson
|
||||
John Crow
|
||||
John Janssen
|
||||
John Kelly
|
||||
John Lask
|
||||
John McGowan
|
||||
Jon Grubbs
|
||||
Jon Travis
|
||||
Jon Turner
|
||||
Jonas Forsman
|
||||
Jonatan Lander
|
||||
Jonathan Hseu
|
||||
Jongki Suwandi
|
||||
Josh Kapell
|
||||
Juan F. Codagnone
|
||||
Juan Ignacio Hervás
|
||||
Juergen Wilke
|
||||
Jukka Pihl
|
||||
Julian Noble
|
||||
Jun-ichiro itojun Hagino
|
||||
Jurij Smakov
|
||||
Jörg Mueller-Tolk
|
||||
Jörn Hartroth
|
||||
Kai Sommerfeld
|
||||
Kai-Uwe Rommel
|
||||
Kang-Jin Lee
|
||||
Karl Moerder
|
||||
Karol Pietrzak
|
||||
Katie Wang
|
||||
Keith MacDonald
|
||||
Keith McGuigan
|
||||
Ken Hirsch
|
||||
Ken Rastatter
|
||||
Kent Boortz
|
||||
Kevin Fisk
|
||||
Kevin Lussier
|
||||
Kevin Roth
|
||||
Kimmo Kinnunen
|
||||
Kjell Ericson
|
||||
Kjetil Jacobsen
|
||||
Klevtsov Vadim
|
||||
Kris Kennaway
|
||||
Krishnendu Majumdar
|
||||
Kristian Köhntopp
|
||||
Kyle Sallee
|
||||
Lachlan O'Dea
|
||||
Larry Campbell
|
||||
Larry Fahnoe
|
||||
Lars Gustafsson
|
||||
Lars J. Aas
|
||||
Lars Nilsson
|
||||
Lars Torben Wilson
|
||||
Legoff Vincent
|
||||
Lehel Bernadt
|
||||
Len Krause
|
||||
Linas Vepstas
|
||||
Ling Thio
|
||||
Linus Nielsen Feltzing
|
||||
Loic Dachary
|
||||
Loren Kirkby
|
||||
Luca Altea
|
||||
Luca Alteas
|
||||
Lucas Adamski
|
||||
Lukasz Czekierda
|
||||
Luke Call
|
||||
Luong Dinh Dung
|
||||
Maciej Karpiuk
|
||||
Maciej W. Rozycki
|
||||
Marc Boucher
|
||||
Marcelo Juchem
|
||||
Marcin Konicki
|
||||
Marco G. Salvagno
|
||||
Marcus Webster
|
||||
Mario Schroeder
|
||||
Mark Butler
|
||||
Mark Eichin
|
||||
Mark Lentczner
|
||||
Markus Koetter
|
||||
Markus Moeller
|
||||
Markus Oberhumer
|
||||
Martijn Koster
|
||||
Martin C. Martin
|
||||
Martin Hedenfalk
|
||||
Marty Kuhrt
|
||||
Maruko
|
||||
Massimiliano Ziccardi
|
||||
Mathias Axelsson
|
||||
Mats Lidell
|
||||
Matt Veenstra
|
||||
Matthew Blain
|
||||
Matthew Clarke
|
||||
Maurice Barnum
|
||||
Mekonikum
|
||||
Mettgut Jamalla
|
||||
Michael Benedict
|
||||
Michael Curtis
|
||||
Michael Jahn
|
||||
Michael Jerris
|
||||
Michael Mealling
|
||||
Michael Wallner
|
||||
Michal Bonino
|
||||
Michal Marek
|
||||
Michele Bini
|
||||
Mihai Ionescu
|
||||
Mikael Sennerholm
|
||||
Mike Bytnar
|
||||
Mike Dobbs
|
||||
Miklos Nemeth
|
||||
Mitz Wark
|
||||
Mohamed Lrhazi
|
||||
Mohun Biswas
|
||||
Moonesamy
|
||||
Nathan O'Sullivan
|
||||
Naveen Noel
|
||||
Neil Dunbar
|
||||
Neil Spring
|
||||
Nic Roets
|
||||
Nick Gimbrone
|
||||
Nick Humfrey
|
||||
Nico Baggus
|
||||
Nicolas Berloquin
|
||||
Nicolas Croiset
|
||||
Nicolas François
|
||||
Niels van Tongeren
|
||||
Nikita Schmidt
|
||||
Nis Jorgensen
|
||||
Nodak Sodak
|
||||
Norbert Novotny
|
||||
Ofer
|
||||
Olaf Stüben
|
||||
Oren Tirosh
|
||||
P R Schaffner
|
||||
Patrick Bihan-Faou
|
||||
Patrick Smith
|
||||
Paul Harrington
|
||||
Paul Marquis
|
||||
Paul Moore
|
||||
Paul Nolan
|
||||
Paul Querna
|
||||
Pavel Cenek
|
||||
Pavel Orehov
|
||||
Pawel A. Gajda
|
||||
Pedro Neves
|
||||
Pete Su
|
||||
Peter Bray
|
||||
Peter Forret
|
||||
Peter Heuchert
|
||||
Peter Pentchev
|
||||
Peter Silva
|
||||
Peter Su
|
||||
Peter Sylvester
|
||||
Peter Todd
|
||||
Peter Verhas
|
||||
Peter Wullinger
|
||||
Peteris Krumins
|
||||
Phil Karn
|
||||
Philip Gladstone
|
||||
Philippe Hameau
|
||||
Philippe Raoult
|
||||
Philippe Vaucher
|
||||
Pierre
|
||||
Puneet Pawaia
|
||||
Quagmire
|
||||
Rafael Sagula
|
||||
Ralph Beckmann
|
||||
Ralph Mitchell
|
||||
Ramana Mokkapati
|
||||
Randy McMurchy
|
||||
Reinout van Schouwen
|
||||
Renaud Chaillat
|
||||
Renaud Duhaut
|
||||
Rene Bernhardt
|
||||
Rene Rebe
|
||||
Ricardo Cadime
|
||||
Rich Gray
|
||||
Richard Archer
|
||||
Richard Atterer
|
||||
Richard Bramante
|
||||
Richard Clayton
|
||||
Richard Cooper
|
||||
Richard Gorton
|
||||
Richard Prescott
|
||||
Rick Jones
|
||||
Rick Richardson
|
||||
Rob Stanzel
|
||||
Robert D. Young
|
||||
Robert Olson
|
||||
Robert Weaver
|
||||
Robin Kay
|
||||
Robson Braga Araujo
|
||||
Rodney Simmons
|
||||
Roland Blom
|
||||
Roland Krikava
|
||||
Roland Zimmermann
|
||||
Roman Koifman
|
||||
Ron Zapp
|
||||
Rosimildo da Silva
|
||||
Roy Shan
|
||||
Rune Kleveland
|
||||
Ryan Nelson
|
||||
S. Moonesamy
|
||||
Salvador Dávila
|
||||
Salvatore Sorrentino
|
||||
Sampo Kellomaki
|
||||
Samuel Díaz García
|
||||
Samuel Listopad
|
||||
Sander Gates
|
||||
Saul good
|
||||
Scott Davis
|
||||
Sebastien Willemijns
|
||||
Sergio Ballestrero
|
||||
Seshubabu Pasam
|
||||
Shard
|
||||
Shawn Poulson
|
||||
Shmulik Regev
|
||||
Siddhartha Prakash Jain
|
||||
Simon Dick
|
||||
Simon Josefsson
|
||||
Simon Liu
|
||||
Spiridonoff A.V
|
||||
Stadler Stephan
|
||||
Stefan Esser
|
||||
Stefan Ulrich
|
||||
Stephan Bergmann
|
||||
Stephen Kick
|
||||
Stephen More
|
||||
Sterling Hughes
|
||||
Steve Green
|
||||
Steve Lhomme
|
||||
Steve Marx
|
||||
Steve Oliphant
|
||||
Steven Bazyl
|
||||
Steven G. Johnson
|
||||
Stoned Elipot
|
||||
Sven Neuhaus
|
||||
Sébastien Willemijns
|
||||
T. Bharath
|
||||
T. Yamada
|
||||
Temprimus
|
||||
Thomas Klausner
|
||||
Thomas Schwinge
|
||||
Thomas Tonino
|
||||
Tim Baker
|
||||
Tim Bartley
|
||||
Tim Costello
|
||||
Tim Sneddon
|
||||
Toby Peterson
|
||||
Todd Kulesza
|
||||
Todd Vierling
|
||||
Tom Benoist
|
||||
Tom Lee
|
||||
Tom Mattison
|
||||
Tom Moers
|
||||
Tom Zerucha
|
||||
Tomas Pospisek
|
||||
Tomas Szepe
|
||||
Tomasz Lacki
|
||||
Tommy Tam
|
||||
Ton Voon
|
||||
Tor Arntsen
|
||||
Torsten Foertsch
|
||||
Toshiyuki Maezawa
|
||||
Traian Nicolescu
|
||||
Troels Walsted Hansen
|
||||
Troy Engel
|
||||
Tupone Alfredo
|
||||
Ulf Härnhammar
|
||||
Ulrich Zadow
|
||||
Vilmos Nebehaj
|
||||
Vincent Bronner
|
||||
Vincent Penquerc'h
|
||||
Vincent Sanders
|
||||
Vojtech Janota
|
||||
Vojtech Minarik
|
||||
Walter J. Mack
|
||||
Wayne Haigh
|
||||
Werner Koch
|
||||
Wesley Laxton
|
||||
Wez Furlong
|
||||
Wilfredo Sanchez
|
||||
Wojciech Zwiefka
|
||||
Xavier Bouchoux
|
||||
Yang Tse
|
||||
Yarram Sunil
|
||||
Yves Lejeune
|
||||
Zvi Har'El
|
||||
nk
|
||||
swalkaus at yahoo.com
|
||||
tommink[at]post.pl
|
|
@ -1,307 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
TODO
|
||||
|
||||
Things to do in project cURL. Please tell us what you think, contribute and
|
||||
send us patches that improve things! Also check the http://curl.haxx.se/dev
|
||||
web section for various technical development notes.
|
||||
|
||||
All bugs documented in the KNOWN_BUGS document are subject for fixing!
|
||||
|
||||
LIBCURL
|
||||
|
||||
* Introduce another callback interface for upload/download that makes one
|
||||
less copy of data and thus a faster operation.
|
||||
[http://curl.haxx.se/dev/no_copy_callbacks.txt]
|
||||
|
||||
* More data sharing. curl_share_* functions already exist and work, and they
|
||||
can be extended to share more. For example, enable sharing of the ares
|
||||
channel and the connection cache.
|
||||
|
||||
* Introduce a new error code indicating authentication problems (for proxy
|
||||
CONNECT error 407 for example). This cannot be an error code, we must not
|
||||
return informational stuff as errors, consider a new info returned by
|
||||
curl_easy_getinfo() http://curl.haxx.se/bug/view.cgi?id=845941
|
||||
|
||||
* Use 'struct lifreq' and SIOCGLIFADDR instead of 'struct ifreq' and
|
||||
SIOCGIFADDR on newer Solaris versions as they claim the latter is obsolete.
|
||||
To support ipv6 interface addresses properly.
|
||||
|
||||
* Add the following to curl_easy_getinfo(): GET_HTTP_IP, GET_FTP_IP and
|
||||
GET_FTP_DATA_IP. Return a string with the used IP. Suggested by Alan.
|
||||
|
||||
* Add option that changes the interval in which the progress callback is
|
||||
called at most.
|
||||
|
||||
* Make libcurl built with c-ares use c-ares' IPv6 abilities. They weren't
|
||||
present when we first added c-ares support but they have been added since!
|
||||
When this is done and works, we can actually start considering making c-ares
|
||||
powered libcurl the default build (which of course would require that we'd
|
||||
bundle the c-ares source code in the libcurl source code releases).
|
||||
|
||||
* Support CONNECT 407 responses that kill the connection and expect the
|
||||
client to reconnect to complete the authentication. Currently libcurl
|
||||
assumes that a proxy connection will be kept alive.
|
||||
|
||||
* Make the curl/*.h headers include the proper system includes based on what
|
||||
was present at the time when configure was run. Currently, the sys/select.h
|
||||
header is for example included by curl/multi.h only on specific platforms
|
||||
we know MUST have it. This is error-prone. We therefore want the header
|
||||
files to adapt to configure results. Those results must be stored in a new
|
||||
header and they must use a curl name space, i.e not be HAVE_* prefix (as
|
||||
that would risk collide with other apps that use libcurl and that runs
|
||||
configure).
|
||||
|
||||
LIBCURL - multi interface
|
||||
|
||||
* Make sure we don't ever loop because of non-blocking sockets return
|
||||
EWOULDBLOCK or similar. The GnuTLS connection etc.
|
||||
|
||||
* Make transfers treated more carefully. We need a way to tell libcurl we
|
||||
have data to write, as the current system expects us to upload data each
|
||||
time the socket is writable and there is no way to say that we want to
|
||||
upload data soon just not right now, without that aborting the upload. The
|
||||
opposite situation should be possible as well, that we tell libcurl we're
|
||||
ready to accept read data. Today libcurl feeds the data as soon as it is
|
||||
available for reading, no matter what.
|
||||
|
||||
* Make curl_easy_perform() a wrapper-function that simply creates a multi
|
||||
handle, adds the easy handle to it, runs curl_multi_perform() until the
|
||||
transfer is done, then detach the easy handle, destroy the multi handle and
|
||||
return the easy handle's return code. This will thus make everything
|
||||
internally use and assume the multi interface. The select()-loop should use
|
||||
curl_multi_socket().
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
* More and better
|
||||
|
||||
FTP
|
||||
|
||||
* Make the detection of (bad) %0d and %0a codes in FTP url parts earlier in
|
||||
the process to avoid doing a resolve and connect in vain.
|
||||
|
||||
* Support GSS/Kerberos 5 for ftp file transfer. This will allow user
|
||||
authentication and file encryption. Possible libraries and example clients
|
||||
are available from MIT or Heimdal. Requested by Markus Moeller.
|
||||
|
||||
* REST fix for servers not behaving well on >2GB requests. This should fail
|
||||
if the server doesn't set the pointer to the requested index. The tricky
|
||||
(impossible?) part is to figure out if the server did the right thing or
|
||||
not.
|
||||
|
||||
* Support the most common FTP proxies, Philip Newton provided a list
|
||||
allegedly from ncftp:
|
||||
http://curl.haxx.se/mail/archive-2003-04/0126.html
|
||||
|
||||
* Make CURLOPT_FTPPORT support an additional port number on the IP/if/name,
|
||||
like "blabla:[port]" or possibly even "blabla:[portfirst]-[portsecond]".
|
||||
|
||||
* FTP ASCII transfers do not follow RFC959. They don't convert the data
|
||||
accordingly.
|
||||
|
||||
* Since USERPWD always override the user and password specified in URLs, we
|
||||
might need another way to specify user+password for anonymous ftp logins.
|
||||
|
||||
* The FTP code should get a way of returning errors that is known to still
|
||||
have the control connection alive and sound. Currently, a returned error
|
||||
from within ftp-functions does not tell if the control connection is still
|
||||
OK to use or not. This causes libcurl to fail to re-use connections
|
||||
slightly too often.
|
||||
|
||||
HTTP
|
||||
|
||||
* When doing CONNECT to a HTTP proxy, libcurl always uses HTTP/1.0. This has
|
||||
never been reported as causing trouble to anyone, but should be considered
|
||||
to use the HTTP version the user has chosen.
|
||||
|
||||
TELNET
|
||||
|
||||
* Reading input (to send to the remote server) on stdin is a crappy solution
|
||||
for library purposes. We need to invent a good way for the application to
|
||||
be able to provide the data to send.
|
||||
|
||||
* Move the telnet support's network select() loop go away and merge the code
|
||||
into the main transfer loop. Until this is done, the multi interface won't
|
||||
work for telnet.
|
||||
|
||||
SSL
|
||||
|
||||
* Provide a libcurl API for setting mutex callbacks in the underlying SSL
|
||||
library, so that the same application code can use mutex-locking
|
||||
independently of OpenSSL or GnutTLS being used.
|
||||
|
||||
* Anton Fedorov's "dumpcert" patch:
|
||||
http://curl.haxx.se/mail/lib-2004-03/0088.html
|
||||
|
||||
* Evaluate/apply Gertjan van Wingerde's SSL patches:
|
||||
http://curl.haxx.se/mail/lib-2004-03/0087.html
|
||||
|
||||
* "Look at SSL cafile - quick traces look to me like these are done on every
|
||||
request as well, when they should only be necessary once per ssl context
|
||||
(or once per handle)". The major improvement we can rather easily do is to
|
||||
make sure we don't create and kill a new SSL "context" for every request,
|
||||
but instead make one for every connection and re-use that SSL context in
|
||||
the same style connections are re-used. It will make us use slightly more
|
||||
memory but it will libcurl do less creations and deletions of SSL contexts.
|
||||
|
||||
* Add an interface to libcurl that enables "session IDs" to get
|
||||
exported/imported. Cris Bailiff said: "OpenSSL has functions which can
|
||||
serialise the current SSL state to a buffer of your choice, and
|
||||
recover/reset the state from such a buffer at a later date - this is used
|
||||
by mod_ssl for apache to implement and SSL session ID cache".
|
||||
|
||||
* OpenSSL supports a callback for customised verification of the peer
|
||||
certificate, but this doesn't seem to be exposed in the libcurl APIs. Could
|
||||
it be? There's so much that could be done if it were! (brought by Chris
|
||||
Clark)
|
||||
|
||||
* Make curl's SSL layer capable of using other free SSL libraries. Such as
|
||||
Mozilla Security Services
|
||||
(http://www.mozilla.org/projects/security/pki/nss/), MatrixSSL
|
||||
(http://www.matrixssl.org/) or yaSSL (http://yassl.com/). At least the
|
||||
latter two could be alternatives for those looking to reduce the footprint
|
||||
of libcurl built with OpenSSL or GnuTLS.
|
||||
|
||||
* Peter Sylvester's patch for SRP on the TLS layer.
|
||||
Awaits OpenSSL support for this, no need to support this in libcurl before
|
||||
there's an OpenSSL release that does it.
|
||||
|
||||
* make the configure --with-ssl option first check for OpenSSL and then for
|
||||
GnuTLS if OpenSSL wasn't detected.
|
||||
|
||||
GnuTLS
|
||||
|
||||
* Get NTLM working using the functions provided by libgcrypt, since GnuTLS
|
||||
already depends on that to function. Not strictly SSL/TLS related, but
|
||||
hey... Another option is to get available DES and MD4 source code from the
|
||||
cryptopp library. They are fine license-wise, but are C++.
|
||||
|
||||
* SSL engine stuff?
|
||||
|
||||
* Work out a common method with Peter Sylvester's OpenSSL-patch for SRP
|
||||
on the TLS to provide name and password
|
||||
|
||||
* Fix the connection phase to be non-blocking when multi interface is used
|
||||
|
||||
* Add a way to check if the connection seems to be alive, to corrspond to the
|
||||
SSL_peak() way we use with OpenSSL.
|
||||
|
||||
LDAP
|
||||
|
||||
* Look over the implementation. The looping will have to "go away" from the
|
||||
lib/ldap.c source file and get moved to the main network code so that the
|
||||
multi interface and friends will work for LDAP as well.
|
||||
|
||||
NEW PROTOCOLS
|
||||
|
||||
* RTSP - RFC2326 (protocol - very HTTP-like, also contains URL description)
|
||||
|
||||
* SFTP/SCP/SSH (no RFCs for protocol nor URI/URL format). An implementation
|
||||
should most probably use an existing ssh library, such as OpenSSH. or
|
||||
libssh2.org
|
||||
|
||||
* RSYNC (no RFCs for protocol nor URI/URL format). An implementation should
|
||||
most probably use an existing rsync library, such as librsync.
|
||||
|
||||
CLIENT
|
||||
|
||||
* "curl --sync http://example.com/feed[1-100].rss" or
|
||||
"curl --sync http://example.net/{index,calendar,history}.html"
|
||||
|
||||
Downloads a range or set of URLs using the remote name, but only if the
|
||||
remote file is newer than the local file. A Last-Modified HTTP date header
|
||||
should also be used to set the mod date on the downloaded file.
|
||||
(idea from "Brianiac")
|
||||
|
||||
* Globbing support for -d and -F, as in 'curl -d "name=foo[0-9]" URL'.
|
||||
Requested by Dane Jensen and others. This is easily scripted though.
|
||||
|
||||
* Add an option that prevents cURL from overwriting existing local files. When
|
||||
used, and there already is an existing file with the target file name
|
||||
(either -O or -o), a number should be appended (and increased if already
|
||||
existing). So that index.html becomes first index.html.1 and then
|
||||
index.html.2 etc. Jeff Pohlmeyer suggested.
|
||||
|
||||
* "curl ftp://site.com/*.txt"
|
||||
|
||||
* The client could be told to use maximum N simultaneous transfers and then
|
||||
just make sure that happens. It should of course not make more than one
|
||||
connection to the same remote host. This would require the client to use
|
||||
the multi interface.
|
||||
|
||||
* Extending the capabilities of the multipart formposting. How about leaving
|
||||
the ';type=foo' syntax as it is and adding an extra tag (headers) which
|
||||
works like this: curl -F "coolfiles=@fil1.txt;headers=@fil1.hdr" where
|
||||
fil1.hdr contains extra headers like
|
||||
|
||||
Content-Type: text/plain; charset=KOI8-R"
|
||||
Content-Transfer-Encoding: base64
|
||||
X-User-Comment: Please don't use browser specific HTML code
|
||||
|
||||
which should overwrite the program reasonable defaults (plain/text,
|
||||
8bit...) (Idea brough to us by kromJx)
|
||||
|
||||
* ability to specify the classic computing suffixes on the range
|
||||
specifications. For example, to download the first 500 Kilobytes of a file,
|
||||
be able to specify the following for the -r option: "-r 0-500K" or for the
|
||||
first 2 Megabytes of a file: "-r 0-2M". (Mark Smith suggested)
|
||||
|
||||
* --data-encode that URL encodes the data before posting
|
||||
http://curl.haxx.se/mail/archive-2003-11/0091.html (Kevin Roth suggested)
|
||||
|
||||
* Provide a way to make options bound to a specific URL among several on the
|
||||
command line. Possibly by letting ':' separate options between URLs,
|
||||
similar to this:
|
||||
|
||||
curl --data foo --url url.com : \
|
||||
--url url2.com : \
|
||||
--url url3.com --data foo3
|
||||
|
||||
(More details: http://curl.haxx.se/mail/archive-2004-07/0133.html)
|
||||
|
||||
The example would do a POST-GET-POST combination on a single command line.
|
||||
|
||||
BUILD
|
||||
|
||||
* Consider extending 'roffit' to produce decent ASCII output, and use that
|
||||
instead of (g)nroff when building src/hugehelp.c
|
||||
|
||||
TEST SUITE
|
||||
|
||||
* Make the test servers able to serve multiple running test suites. Like if
|
||||
two users run 'make test' at once.
|
||||
|
||||
* If perl wasn't found by the configure script, don't attempt to run the
|
||||
tests but explain something nice why it doesn't.
|
||||
|
||||
* Extend the test suite to include more protocols. The telnet could just do
|
||||
ftp or http operations (for which we have test servers).
|
||||
|
||||
* Make the test suite work on more platforms. OpenBSD and Mac OS. Remove
|
||||
fork()s and it should become even more portable.
|
||||
|
||||
NEXT MAJOR RELEASE
|
||||
|
||||
* curl_easy_cleanup() returns void, but curl_multi_cleanup() returns a
|
||||
CURLMcode. These should be changed to be the same.
|
||||
|
||||
* remove obsolete defines from curl/curl.h
|
||||
|
||||
* make several functions use size_t instead of int in their APIs
|
||||
|
||||
* remove the following functions from the public API:
|
||||
curl_getenv
|
||||
curl_mprintf (and variations)
|
||||
curl_strequal
|
||||
curl_strnequal
|
||||
|
||||
They will instead become curlx_ - alternatives. That makes the curl app
|
||||
still capable of building with them from source.
|
||||
|
||||
* Remove support for CURLOPT_FAILONERROR, it has gotten too kludgy and weird
|
||||
internally. Let the app judge success or not for itself.
|
|
@ -1,453 +0,0 @@
|
|||
Online: http://curl.haxx.se/docs/httpscripting.html
|
||||
Date: December 9, 2004
|
||||
|
||||
The Art Of Scripting HTTP Requests Using Curl
|
||||
=============================================
|
||||
|
||||
This document will assume that you're familiar with HTML and general
|
||||
networking.
|
||||
|
||||
The possibility to write scripts is essential to make a good computer
|
||||
system. Unix' capability to be extended by shell scripts and various tools to
|
||||
run various automated commands and scripts is one reason why it has succeeded
|
||||
so well.
|
||||
|
||||
The increasing amount of applications moving to the web has made "HTTP
|
||||
Scripting" more frequently requested and wanted. To be able to automatically
|
||||
extract information from the web, to fake users, to post or upload data to
|
||||
web servers are all important tasks today.
|
||||
|
||||
Curl is a command line tool for doing all sorts of URL manipulations and
|
||||
transfers, but this particular document will focus on how to use it when
|
||||
doing HTTP requests for fun and profit. I'll assume that you know how to
|
||||
invoke 'curl --help' or 'curl --manual' to get basic information about it.
|
||||
|
||||
Curl is not written to do everything for you. It makes the requests, it gets
|
||||
the data, it sends data and it retrieves the information. You probably need
|
||||
to glue everything together using some kind of script language or repeated
|
||||
manual invokes.
|
||||
|
||||
1. The HTTP Protocol
|
||||
|
||||
HTTP is the protocol used to fetch data from web servers. It is a very simple
|
||||
protocol that is built upon TCP/IP. The protocol also allows information to
|
||||
get sent to the server from the client using a few different methods, as will
|
||||
be shown here.
|
||||
|
||||
HTTP is plain ASCII text lines being sent by the client to a server to
|
||||
request a particular action, and then the server replies a few text lines
|
||||
before the actual requested content is sent to the client.
|
||||
|
||||
Using curl's option -v will display what kind of commands curl sends to the
|
||||
server, as well as a few other informational texts. -v is the single most
|
||||
useful option when it comes to debug or even understand the curl<->server
|
||||
interaction.
|
||||
|
||||
2. URL
|
||||
|
||||
The Uniform Resource Locator format is how you specify the address of a
|
||||
particular resource on the Internet. You know these, you've seen URLs like
|
||||
http://curl.haxx.se or https://yourbank.com a million times.
|
||||
|
||||
3. GET a page
|
||||
|
||||
The simplest and most common request/operation made using HTTP is to get a
|
||||
URL. The URL could itself refer to a web page, an image or a file. The client
|
||||
issues a GET request to the server and receives the document it asked for.
|
||||
If you issue the command line
|
||||
|
||||
curl http://curl.haxx.se
|
||||
|
||||
you get a web page returned in your terminal window. The entire HTML document
|
||||
that that URL holds.
|
||||
|
||||
All HTTP replies contain a set of headers that are normally hidden, use
|
||||
curl's -i option to display them as well as the rest of the document. You can
|
||||
also ask the remote server for ONLY the headers by using the -I option (which
|
||||
will make curl issue a HEAD request).
|
||||
|
||||
4. Forms
|
||||
|
||||
Forms are the general way a web site can present a HTML page with fields for
|
||||
the user to enter data in, and then press some kind of 'OK' or 'submit'
|
||||
button to get that data sent to the server. The server then typically uses
|
||||
the posted data to decide how to act. Like using the entered words to search
|
||||
in a database, or to add the info in a bug track system, display the entered
|
||||
address on a map or using the info as a login-prompt verifying that the user
|
||||
is allowed to see what it is about to see.
|
||||
|
||||
Of course there has to be some kind of program in the server end to receive
|
||||
the data you send. You cannot just invent something out of the air.
|
||||
|
||||
4.1 GET
|
||||
|
||||
A GET-form uses the method GET, as specified in HTML like:
|
||||
|
||||
<form method="GET" action="junk.cgi">
|
||||
<input type=text name="birthyear">
|
||||
<input type=submit name=press value="OK">
|
||||
</form>
|
||||
|
||||
In your favorite browser, this form will appear with a text box to fill in
|
||||
and a press-button labeled "OK". If you fill in '1905' and press the OK
|
||||
button, your browser will then create a new URL to get for you. The URL will
|
||||
get "junk.cgi?birthyear=1905&press=OK" appended to the path part of the
|
||||
previous URL.
|
||||
|
||||
If the original form was seen on the page "www.hotmail.com/when/birth.html",
|
||||
the second page you'll get will become
|
||||
"www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK".
|
||||
|
||||
Most search engines work this way.
|
||||
|
||||
To make curl do the GET form post for you, just enter the expected created
|
||||
URL:
|
||||
|
||||
curl "www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK"
|
||||
|
||||
4.2 POST
|
||||
|
||||
The GET method makes all input field names get displayed in the URL field of
|
||||
your browser. That's generally a good thing when you want to be able to
|
||||
bookmark that page with your given data, but it is an obvious disadvantage
|
||||
if you entered secret information in one of the fields or if there are a
|
||||
large amount of fields creating a very long and unreadable URL.
|
||||
|
||||
The HTTP protocol then offers the POST method. This way the client sends the
|
||||
data separated from the URL and thus you won't see any of it in the URL
|
||||
address field.
|
||||
|
||||
The form would look very similar to the previous one:
|
||||
|
||||
<form method="POST" action="junk.cgi">
|
||||
<input type=text name="birthyear">
|
||||
<input type=submit name=press value=" OK ">
|
||||
</form>
|
||||
|
||||
And to use curl to post this form with the same data filled in as before, we
|
||||
could do it like:
|
||||
|
||||
curl -d "birthyear=1905&press=%20OK%20" www.hotmail.com/when/junk.cgi
|
||||
|
||||
This kind of POST will use the Content-Type
|
||||
application/x-www-form-urlencoded and is the most widely used POST kind.
|
||||
|
||||
The data you send to the server MUST already be properly encoded, curl will
|
||||
not do that for you. For example, if you want the data to contain a space,
|
||||
you need to replace that space with %20 etc. Failing to comply with this
|
||||
will most likely cause your data to be received wrongly and messed up.
|
||||
|
||||
4.3 File Upload POST
|
||||
|
||||
Back in late 1995 they defined an additional way to post data over HTTP. It
|
||||
is documented in the RFC 1867, why this method sometimes is referred to as
|
||||
RFC1867-posting.
|
||||
|
||||
This method is mainly designed to better support file uploads. A form that
|
||||
allows a user to upload a file could be written like this in HTML:
|
||||
|
||||
<form method="POST" enctype='multipart/form-data' action="upload.cgi">
|
||||
<input type=file name=upload>
|
||||
<input type=submit name=press value="OK">
|
||||
</form>
|
||||
|
||||
This clearly shows that the Content-Type about to be sent is
|
||||
multipart/form-data.
|
||||
|
||||
To post to a form like this with curl, you enter a command line like:
|
||||
|
||||
curl -F upload=@localfilename -F press=OK [URL]
|
||||
|
||||
4.4 Hidden Fields
|
||||
|
||||
A very common way for HTML based application to pass state information
|
||||
between pages is to add hidden fields to the forms. Hidden fields are
|
||||
already filled in, they aren't displayed to the user and they get passed
|
||||
along just as all the other fields.
|
||||
|
||||
A similar example form with one visible field, one hidden field and one
|
||||
submit button could look like:
|
||||
|
||||
<form method="POST" action="foobar.cgi">
|
||||
<input type=text name="birthyear">
|
||||
<input type=hidden name="person" value="daniel">
|
||||
<input type=submit name="press" value="OK">
|
||||
</form>
|
||||
|
||||
To post this with curl, you won't have to think about if the fields are
|
||||
hidden or not. To curl they're all the same:
|
||||
|
||||
curl -d "birthyear=1905&press=OK&person=daniel" [URL]
|
||||
|
||||
4.5 Figure Out What A POST Looks Like
|
||||
|
||||
When you're about fill in a form and send to a server by using curl instead
|
||||
of a browser, you're of course very interested in sending a POST exactly the
|
||||
way your browser does.
|
||||
|
||||
An easy way to get to see this, is to save the HTML page with the form on
|
||||
your local disk, modify the 'method' to a GET, and press the submit button
|
||||
(you could also change the action URL if you want to).
|
||||
|
||||
You will then clearly see the data get appended to the URL, separated with a
|
||||
'?'-letter as GET forms are supposed to.
|
||||
|
||||
5. PUT
|
||||
|
||||
The perhaps best way to upload data to a HTTP server is to use PUT. Then
|
||||
again, this of course requires that someone put a program or script on the
|
||||
server end that knows how to receive a HTTP PUT stream.
|
||||
|
||||
Put a file to a HTTP server with curl:
|
||||
|
||||
curl -T uploadfile www.uploadhttp.com/receive.cgi
|
||||
|
||||
6. Authentication
|
||||
|
||||
Authentication is the ability to tell the server your username and password
|
||||
so that it can verify that you're allowed to do the request you're doing. The
|
||||
Basic authentication used in HTTP (which is the type curl uses by default) is
|
||||
*plain* *text* based, which means it sends username and password only
|
||||
slightly obfuscated, but still fully readable by anyone that sniffs on the
|
||||
network between you and the remote server.
|
||||
|
||||
To tell curl to use a user and password for authentication:
|
||||
|
||||
curl -u name:password www.secrets.com
|
||||
|
||||
The site might require a different authentication method (check the headers
|
||||
returned by the server), and then --ntlm, --digest, --negotiate or even
|
||||
--anyauth might be options that suit you.
|
||||
|
||||
Sometimes your HTTP access is only available through the use of a HTTP
|
||||
proxy. This seems to be especially common at various companies. A HTTP proxy
|
||||
may require its own user and password to allow the client to get through to
|
||||
the Internet. To specify those with curl, run something like:
|
||||
|
||||
curl -U proxyuser:proxypassword curl.haxx.se
|
||||
|
||||
If your proxy requires the authentication to be done using the NTLM method,
|
||||
use --proxy-ntlm, if it requires Digest use --proxy-digest.
|
||||
|
||||
If you use any one these user+password options but leave out the password
|
||||
part, curl will prompt for the password interactively.
|
||||
|
||||
Do note that when a program is run, its parameters might be possible to see
|
||||
when listing the running processes of the system. Thus, other users may be
|
||||
able to watch your passwords if you pass them as plain command line
|
||||
options. There are ways to circumvent this.
|
||||
|
||||
7. Referer
|
||||
|
||||
A HTTP request may include a 'referer' field (yes it is misspelled), which
|
||||
can be used to tell from which URL the client got to this particular
|
||||
resource. Some programs/scripts check the referer field of requests to verify
|
||||
that this wasn't arriving from an external site or an unknown page. While
|
||||
this is a stupid way to check something so easily forged, many scripts still
|
||||
do it. Using curl, you can put anything you want in the referer-field and
|
||||
thus more easily be able to fool the server into serving your request.
|
||||
|
||||
Use curl to set the referer field with:
|
||||
|
||||
curl -e http://curl.haxx.se daniel.haxx.se
|
||||
|
||||
8. User Agent
|
||||
|
||||
Very similar to the referer field, all HTTP requests may set the User-Agent
|
||||
field. It names what user agent (client) that is being used. Many
|
||||
applications use this information to decide how to display pages. Silly web
|
||||
programmers try to make different pages for users of different browsers to
|
||||
make them look the best possible for their particular browsers. They usually
|
||||
also do different kinds of javascript, vbscript etc.
|
||||
|
||||
At times, you will see that getting a page with curl will not return the same
|
||||
page that you see when getting the page with your browser. Then you know it
|
||||
is time to set the User Agent field to fool the server into thinking you're
|
||||
one of those browsers.
|
||||
|
||||
To make curl look like Internet Explorer on a Windows 2000 box:
|
||||
|
||||
curl -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]
|
||||
|
||||
Or why not look like you're using Netscape 4.73 on a Linux (PIII) box:
|
||||
|
||||
curl -A "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" [URL]
|
||||
|
||||
9. Redirects
|
||||
|
||||
When a resource is requested from a server, the reply from the server may
|
||||
include a hint about where the browser should go next to find this page, or a
|
||||
new page keeping newly generated output. The header that tells the browser
|
||||
to redirect is Location:.
|
||||
|
||||
Curl does not follow Location: headers by default, but will simply display
|
||||
such pages in the same manner it display all HTTP replies. It does however
|
||||
feature an option that will make it attempt to follow the Location: pointers.
|
||||
|
||||
To tell curl to follow a Location:
|
||||
|
||||
curl -L www.sitethatredirects.com
|
||||
|
||||
If you use curl to POST to a site that immediately redirects you to another
|
||||
page, you can safely use -L and -d/-F together. Curl will only use POST in
|
||||
the first request, and then revert to GET in the following operations.
|
||||
|
||||
10. Cookies
|
||||
|
||||
The way the web browsers do "client side state control" is by using
|
||||
cookies. Cookies are just names with associated contents. The cookies are
|
||||
sent to the client by the server. The server tells the client for what path
|
||||
and host name it wants the cookie sent back, and it also sends an expiration
|
||||
date and a few more properties.
|
||||
|
||||
When a client communicates with a server with a name and path as previously
|
||||
specified in a received cookie, the client sends back the cookies and their
|
||||
contents to the server, unless of course they are expired.
|
||||
|
||||
Many applications and servers use this method to connect a series of requests
|
||||
into a single logical session. To be able to use curl in such occasions, we
|
||||
must be able to record and send back cookies the way the web application
|
||||
expects them. The same way browsers deal with them.
|
||||
|
||||
The simplest way to send a few cookies to the server when getting a page with
|
||||
curl is to add them on the command line like:
|
||||
|
||||
curl -b "name=Daniel" www.cookiesite.com
|
||||
|
||||
Cookies are sent as common HTTP headers. This is practical as it allows curl
|
||||
to record cookies simply by recording headers. Record cookies with curl by
|
||||
using the -D option like:
|
||||
|
||||
curl -D headers_and_cookies www.cookiesite.com
|
||||
|
||||
(Take note that the -c option described below is a better way to store
|
||||
cookies.)
|
||||
|
||||
Curl has a full blown cookie parsing engine built-in that comes to use if you
|
||||
want to reconnect to a server and use cookies that were stored from a
|
||||
previous connection (or handicrafted manually to fool the server into
|
||||
believing you had a previous connection). To use previously stored cookies,
|
||||
you run curl like:
|
||||
|
||||
curl -b stored_cookies_in_file www.cookiesite.com
|
||||
|
||||
Curl's "cookie engine" gets enabled when you use the -b option. If you only
|
||||
want curl to understand received cookies, use -b with a file that doesn't
|
||||
exist. Example, if you want to let curl understand cookies from a page and
|
||||
follow a location (and thus possibly send back cookies it received), you can
|
||||
invoke it like:
|
||||
|
||||
curl -b nada -L www.cookiesite.com
|
||||
|
||||
Curl has the ability to read and write cookie files that use the same file
|
||||
format that Netscape and Mozilla do. It is a convenient way to share cookies
|
||||
between browsers and automatic scripts. The -b switch automatically detects
|
||||
if a given file is such a cookie file and parses it, and by using the
|
||||
-c/--cookie-jar option you'll make curl write a new cookie file at the end of
|
||||
an operation:
|
||||
|
||||
curl -b cookies.txt -c newcookies.txt www.cookiesite.com
|
||||
|
||||
11. HTTPS
|
||||
|
||||
There are a few ways to do secure HTTP transfers. The by far most common
|
||||
protocol for doing this is what is generally known as HTTPS, HTTP over
|
||||
SSL. SSL encrypts all the data that is sent and received over the network and
|
||||
thus makes it harder for attackers to spy on sensitive information.
|
||||
|
||||
SSL (or TLS as the latest version of the standard is called) offers a
|
||||
truckload of advanced features to allow all those encryptions and key
|
||||
infrastructure mechanisms encrypted HTTP requires.
|
||||
|
||||
Curl supports encrypted fetches thanks to the freely available OpenSSL
|
||||
libraries. To get a page from a HTTPS server, simply run curl like:
|
||||
|
||||
curl https://that.secure.server.com
|
||||
|
||||
11.1 Certificates
|
||||
|
||||
In the HTTPS world, you use certificates to validate that you are the one
|
||||
you you claim to be, as an addition to normal passwords. Curl supports
|
||||
client-side certificates. All certificates are locked with a pass phrase,
|
||||
which you need to enter before the certificate can be used by curl. The pass
|
||||
phrase can be specified on the command line or if not, entered interactively
|
||||
when curl queries for it. Use a certificate with curl on a HTTPS server
|
||||
like:
|
||||
|
||||
curl -E mycert.pem https://that.secure.server.com
|
||||
|
||||
curl also tries to verify that the server is who it claims to be, by
|
||||
verifying the server's certificate against a locally stored CA cert
|
||||
bundle. Failing the verification will cause curl to deny the connection. You
|
||||
must then use -k in case you want to tell curl to ignore that the server
|
||||
can't be verified.
|
||||
|
||||
More about server certificate verification and ca cert bundles can be read
|
||||
in the SSLCERTS document, available online here:
|
||||
|
||||
http://curl.haxx.se/docs/sslcerts.html
|
||||
|
||||
12. Custom Request Elements
|
||||
|
||||
Doing fancy stuff, you may need to add or change elements of a single curl
|
||||
request.
|
||||
|
||||
For example, you can change the POST request to a PROPFIND and send the data
|
||||
as "Content-Type: text/xml" (instead of the default Content-Type) like this:
|
||||
|
||||
curl -d "<xml>" -H "Content-Type: text/xml" -X PROPFIND url.com
|
||||
|
||||
You can delete a default header by providing one without content. Like you
|
||||
can ruin the request by chopping off the Host: header:
|
||||
|
||||
curl -H "Host:" http://mysite.com
|
||||
|
||||
You can add headers the same way. Your server may want a "Destination:"
|
||||
header, and you can add it:
|
||||
|
||||
curl -H "Destination: http://moo.com/nowhere" http://url.com
|
||||
|
||||
13. Debug
|
||||
|
||||
Many times when you run curl on a site, you'll notice that the site doesn't
|
||||
seem to respond the same way to your curl requests as it does to your
|
||||
browser's.
|
||||
|
||||
Then you need to start making your curl requests more similar to your
|
||||
browser's requests:
|
||||
|
||||
* Use the --trace-ascii option to store fully detailed logs of the requests
|
||||
for easier analyzing and better understanding
|
||||
|
||||
* Make sure you check for and use cookies when needed (both reading with -b
|
||||
and writing with -c)
|
||||
|
||||
* Set user-agent to one like a recent popular browser does
|
||||
|
||||
* Set referer like it is set by the browser
|
||||
|
||||
* If you use POST, make sure you send all the fields and in the same order as
|
||||
the browser does it. (See chapter 4.5 above)
|
||||
|
||||
A very good helper to make sure you do this right, is the LiveHTTPHeader tool
|
||||
that lets you view all headers you send and receive with Mozilla/Firefox
|
||||
(even when using HTTPS).
|
||||
|
||||
A more raw approach is to capture the HTTP traffic on the network with tools
|
||||
such as ethereal or tcpdump and check what headers that were sent and
|
||||
received by the browser. (HTTPS makes this technique inefficient.)
|
||||
|
||||
14. References
|
||||
|
||||
RFC 2616 is a must to read if you want in-depth understanding of the HTTP
|
||||
protocol.
|
||||
|
||||
RFC 2396 explains the URL syntax.
|
||||
|
||||
RFC 2109 defines how cookies are supposed to work.
|
||||
|
||||
RFC 1867 defines the HTTP post upload format.
|
||||
|
||||
http://www.openssl.org is the home of the OpenSSL project
|
||||
|
||||
http://curl.haxx.se is the home of the cURL project
|
|
@ -1,67 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
Version Numbers and Releases
|
||||
|
||||
Curl is not only curl. Curl is also libcurl. They're actually individually
|
||||
versioned, but they mostly follow each other rather closely.
|
||||
|
||||
The version numbering is always built up using the same system:
|
||||
|
||||
X.Y[.Z][-preN]
|
||||
|
||||
Where
|
||||
X is main version number
|
||||
Y is release number
|
||||
Z is patch number
|
||||
N is pre-release number
|
||||
|
||||
One of these numbers will get bumped in each new release. The numbers to the
|
||||
right of a bumped number will be reset to zero. If Z is zero, it may not be
|
||||
included in the version number. The pre release number is only included in
|
||||
pre releases (they're never used in public, official, releases).
|
||||
|
||||
The main version number will get bumped when *really* big, world colliding
|
||||
changes are made. The release number is bumped when big changes are
|
||||
performed. The patch number is bumped when the changes are mere bugfixes and
|
||||
only minor feature changes. The pre-release is a counter, to identify which
|
||||
pre-release a certain release is.
|
||||
|
||||
When reaching the end of a pre-release period, the version without the
|
||||
pre-release part will be released as a public release.
|
||||
|
||||
It means that after release 1.2.3, we can release 2.0 if something really big
|
||||
has been made, 1.3 if not that big changes were made or 1.2.4 if mostly bugs
|
||||
were fixed. Before 1.2.4 is released, we might release a 1.2.4-pre1 release
|
||||
for the brave people to try before the actual release.
|
||||
|
||||
Bumping, as in increasing the number with 1, is unconditionally only
|
||||
affecting one of the numbers (except the ones to the right of it, that may be
|
||||
set to zero). 1 becomes 2, 3 becomes 4, 9 becomes 10, 88 becomes 89 and 99
|
||||
becomes 100. So, after 1.2.9 comes 1.2.10. After 3.99.3, 3.100 might come.
|
||||
|
||||
All original curl source release archives are named according to the libcurl
|
||||
version (not according to the curl client version that, as said before, might
|
||||
differ).
|
||||
|
||||
As a service to any application that might want to support new libcurl
|
||||
features while still being able to build with older versions, all releases
|
||||
have the libcurl version stored in the curl/curlver.h file using a static
|
||||
numbering scheme that can be used for comparison. The version number is
|
||||
defined as:
|
||||
|
||||
#define LIBCURL_VERSION_NUM 0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal. All three numbers are always represented using two digits. 1.2
|
||||
would appear as "0x010200" while version 9.11.7 appears as "0x090b07".
|
||||
|
||||
This 6-digit hexadecimal number does not show pre-release number, and it is
|
||||
always a greater number in a more recent release. It makes comparisons with
|
||||
greater than and less than work.
|
||||
|
||||
This number is also available as three separate defines:
|
||||
LIBCURL_VERSION_MAJOR, LIBCURL_VERSION_MINOR and LIBCURL_VERSION_PATCH.
|
|
@ -1,95 +0,0 @@
|
|||
.\" **************************************************************************
|
||||
.\" * _ _ ____ _
|
||||
.\" * Project ___| | | | _ \| |
|
||||
.\" * / __| | | | |_) | |
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
.\" *
|
||||
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
.\" * copies of the Software, and permit persons to whom the Software is
|
||||
.\" * furnished to do so, under the terms of the COPYING file.
|
||||
.\" *
|
||||
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
.\" * KIND, either express or implied.
|
||||
.\" *
|
||||
.\" * $Id: curl-config.1,v 1.14 2006-05-02 22:48:22 bagder Exp $
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH curl-config 1 "25 Jan 2004" "Curl 7.15.4" "curl-config manual"
|
||||
.SH NAME
|
||||
curl-config \- Get information about a libcurl installation
|
||||
.SH SYNOPSIS
|
||||
.B curl-config [options]
|
||||
.SH DESCRIPTION
|
||||
.B curl-config
|
||||
displays information about a previous curl and libcurl installation.
|
||||
.SH OPTIONS
|
||||
.IP "--ca"
|
||||
Displays the built-in path to the CA cert bundle this libcurl uses.
|
||||
.IP "--cc"
|
||||
Displays the compiler used to build libcurl.
|
||||
.IP "--cflags"
|
||||
Set of compiler options (CFLAGS) to use when compiling files that use
|
||||
libcurl. Currently that is only thw include path to the curl include files.
|
||||
.IP "--checkfor [version]"
|
||||
Specify the oldest possible libcurl version string you want, and this
|
||||
script will return 0 if the current installation is new enough or it
|
||||
returns 1 and outputs a text saying that the current version is not new
|
||||
enough. (Added in 7.15.4)
|
||||
.IP "--feature"
|
||||
Lists what particular main features the installed libcurl was built with. At
|
||||
the time of writing, this list may include SSL, KRB4 or IPv6. Do not assume
|
||||
any particular order. The keywords will be separated by newlines. There may be
|
||||
none, one or several keywords in the list.
|
||||
.IP "--help"
|
||||
Displays the available options.
|
||||
.IP "--libs"
|
||||
Shows the complete set of libs and other linker options you will need in order
|
||||
to link your application with libcurl.
|
||||
.IP "--prefix"
|
||||
This is the prefix used when libcurl was installed. Libcurl is then installed
|
||||
in $prefix/lib and its header files are installed in $prefix/include and so
|
||||
on. The prefix is set with "configure --prefix".
|
||||
.IP "--protocols"
|
||||
Lists what particular protocols the installed libcurl was built to support. At
|
||||
the time of writing, this list may include HTTP, HTTPS, FTP, FTPS, FILE,
|
||||
TELNET, LDAP, DICT. Do not assume any particular order. The protocols will
|
||||
be listed using uppercase and are separated by newlines. There may be none,
|
||||
one or several protocols in the list. (Added in 7.13.0)
|
||||
.IP "--version"
|
||||
Outputs version information about the installed libcurl.
|
||||
.IP "--vernum"
|
||||
Outputs version information about the installed libcurl, in numerical mode.
|
||||
This outputs the version number, in hexadecimal, with 8 bits for each part;
|
||||
major, minor, patch. So that libcurl 7.7.4 would appear as 070704 and libcurl
|
||||
12.13.14 would appear as 0c0d0e... Note that the initial zero might be
|
||||
omitted. (This option was broken in the 7.15.0 release.)
|
||||
.SH "EXAMPLES"
|
||||
What linker options do I need when I link with libcurl?
|
||||
|
||||
$ curl-config --libs
|
||||
|
||||
What compiler options do I need when I compile using libcurl functions?
|
||||
|
||||
$ curl-config --cflags
|
||||
|
||||
How do I know if libcurl was built with SSL support?
|
||||
|
||||
$ curl-config --feature | grep SSL
|
||||
|
||||
What's the installed libcurl version?
|
||||
|
||||
$ curl-config --version
|
||||
|
||||
How do I build a single file with a one-line command?
|
||||
|
||||
$ `curl-config --cc --cflags --libs` -o example example.c
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR curl (1)
|
|
@ -1,86 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl-config man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl-config - Get information about a libcurl installation <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">curl-config [options]</span> <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0"><span Class="bold">curl-config</span> displays information about a previous curl and libcurl installation. <a name="OPTIONS"></a><h2 class="nroffsh">OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="--ca"></a><span class="nroffip">--ca</span>
|
||||
<p class="level1">Displays the built-in path to the CA cert bundle this libcurl uses.
|
||||
<p class="level0"><a name="--cc"></a><span class="nroffip">--cc</span>
|
||||
<p class="level1">Displays the compiler used to build libcurl.
|
||||
<p class="level0"><a name="--cflags"></a><span class="nroffip">--cflags</span>
|
||||
<p class="level1">Set of compiler options (CFLAGS) to use when compiling files that use libcurl. Currently that is only thw include path to the curl include files.
|
||||
<p class="level0"><a name="--checkfor"></a><span class="nroffip">--checkfor [version]</span>
|
||||
<p class="level1">Specify the oldest possible libcurl version string you want, and this script will return 0 if the current installation is new enough or it returns 1 and outputs a text saying that the current version is not new enough. (Added in 7.15.4)
|
||||
<p class="level0"><a name="--feature"></a><span class="nroffip">--feature</span>
|
||||
<p class="level1">Lists what particular main features the installed libcurl was built with. At the time of writing, this list may include SSL, KRB4 or IPv6. Do not assume any particular order. The keywords will be separated by newlines. There may be none, one or several keywords in the list.
|
||||
<p class="level0"><a name="--help"></a><span class="nroffip">--help</span>
|
||||
<p class="level1">Displays the available options.
|
||||
<p class="level0"><a name="--libs"></a><span class="nroffip">--libs</span>
|
||||
<p class="level1">Shows the complete set of libs and other linker options you will need in order to link your application with libcurl.
|
||||
<p class="level0"><a name="--prefix"></a><span class="nroffip">--prefix</span>
|
||||
<p class="level1">This is the prefix used when libcurl was installed. Libcurl is then installed in $prefix/lib and its header files are installed in $prefix/include and so on. The prefix is set with "configure --prefix".
|
||||
<p class="level0"><a name="--protocols"></a><span class="nroffip">--protocols</span>
|
||||
<p class="level1">Lists what particular protocols the installed libcurl was built to support. At the time of writing, this list may include HTTP, HTTPS, FTP, FTPS, FILE, TELNET, LDAP, DICT. Do not assume any particular order. The protocols will be listed using uppercase and are separated by newlines. There may be none, one or several protocols in the list. (Added in 7.13.0)
|
||||
<p class="level0"><a name="--version"></a><span class="nroffip">--version</span>
|
||||
<p class="level1">Outputs version information about the installed libcurl.
|
||||
<p class="level0"><a name="--vernum"></a><span class="nroffip">--vernum</span>
|
||||
<p class="level1">Outputs version information about the installed libcurl, in numerical mode. This outputs the version number, in hexadecimal, with 8 bits for each part; major, minor, patch. So that libcurl 7.7.4 would appear as 070704 and libcurl 12.13.14 would appear as 0c0d0e... Note that the initial zero might be omitted. (This option was broken in the 7.15.0 release.) <a name="EXAMPLES"></a><h2 class="nroffsh">EXAMPLES</h2>
|
||||
<p class="level0">What linker options do I need when I link with libcurl?
|
||||
<p class="level0"> $ curl-config --libs
|
||||
<p class="level0">What compiler options do I need when I compile using libcurl functions?
|
||||
<p class="level0"> $ curl-config --cflags
|
||||
<p class="level0">How do I know if libcurl was built with SSL support?
|
||||
<p class="level0"> $ curl-config --feature | grep SSL
|
||||
<p class="level0">What's the installed libcurl version?
|
||||
<p class="level0"> $ curl-config --version
|
||||
<p class="level0">How do I build a single file with a one-line command?
|
||||
<p class="level0"> $ `curl-config --cc --cflags --libs` -o example example.c
|
||||
<p class="level0"><a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><span Class="manpage">curl (1)</span> <p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,721 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl - transfer a URL <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">curl [options]</span> <a class="emphasis" href="#URL">[URL...]</a> <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0"><span Class="bold">curl</span> is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction.
|
||||
<p class="level0">curl offers a busload of useful tricks like proxy support, user authentication, ftp upload, HTTP post, SSL connections, cookies, file transfer resume and more. As you will see below, the amount of features will make your head spin!
|
||||
<p class="level0">curl is powered by libcurl for all transfer-related features. See <span Class="manpage">libcurl (3)</span> for details. <a name="URL"></a><h2 class="nroffsh">URL</h2>
|
||||
<p class="level0">The URL syntax is protocol dependent. You'll find a detailed description in RFC 3986.
|
||||
<p class="level0">You can specify multiple URLs or parts of URLs by writing part sets within braces as in:
|
||||
<p class="level0"> <a href="http://site">http://site</a>.{one,two,three}.com
|
||||
<p class="level0">or you can get sequences of alphanumeric series by using [] as in:
|
||||
<p class="level0"> <a href="ftp://ftp.numericals.com/file">ftp://ftp.numericals.com/file</a>[1-100].txt <a href="ftp://ftp.numericals.com/file">ftp://ftp.numericals.com/file</a>[001-100].txt (with leading zeros) <a href="ftp://ftp.letters.com/file">ftp://ftp.letters.com/file</a>[a-z].txt
|
||||
<p class="level0">No nesting of the sequences is supported at the moment, but you can use several ones next to each other:
|
||||
<p class="level0"> <a href="http://any.org/archive">http://any.org/archive</a>[1996-1999]/vol[1-4]/part{a,b,c}.html
|
||||
<p class="level0">You can specify any amount of URLs on the command line. They will be fetched in a sequential manner in the specified order.
|
||||
<p class="level0">Since curl 7.15.1 you can also specify step counter for the ranges, so that you can get every Nth number or letter:
|
||||
<p class="level0"> <a href="http://www.numericals.com/file">http://www.numericals.com/file</a>[1-100:10].txt <a href="http://www.letters.com/file">http://www.letters.com/file</a>[a-z:2].txt
|
||||
<p class="level0">If you specify URL without protocol:// prefix, curl will attempt to guess what protocol you might want. It will then default to HTTP but try other protocols based on often-used host name prefixes. For example, for host names starting with "ftp." curl will assume you want to speak FTP.
|
||||
<p class="level0">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. <a name="PROGRESS"></a><h2 class="nroffsh">PROGRESS METER</h2>
|
||||
<p class="level0">curl normally displays a progress meter during operations, indicating amount of transfered data, transfer speeds and estimated time left etc.
|
||||
<p class="level0">However, since curl displays data to the terminal by default, if you invoke curl to do an operation and it is about to write data to the terminal, it <span Class="emphasis">disables</span> the progress meter as otherwise it would mess up the output mixing progress meter and response data.
|
||||
<p class="level0">If you want a progress meter for HTTP POST or PUT requests, you need to redirect the response output to a file, using shell redirect (>), -o [file] or similar.
|
||||
<p class="level0">It is not the same case for FTP upload as that operation is not spitting out any response data to the terminal.
|
||||
<p class="level0">If you prefer a progress "bar" instead of the regular meter, <a class="emphasis" href="#-">-#</a> is your friend. <a name="OPTIONS"></a><h2 class="nroffsh">OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="-a--append"></a><span class="nroffip">-a/--append</span>
|
||||
<p class="level1">(FTP) When used in an 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.
|
||||
<p class="level1">If this option is used twice, the second one will disable append mode again.
|
||||
<p class="level0"><a name="-A--user-agent"></a><span class="nroffip">-A/--user-agent <agent string></span>
|
||||
<p class="level1">(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 <a class="emphasis" href="#-H--header">-H/--header</a> option of course.
|
||||
<p class="level1">If this option is set more than once, the last one will be the one that's used.
|
||||
<p class="level0"><a name="--anyauth"></a><span class="nroffip">--anyauth</span>
|
||||
<p class="level1">(HTTP) Tells curl to figure out authentication method by itself, and use the most secure one the remote site claims it supports. This is done by first doing a request and checking the response-headers, thus inducing an extra network round-trip. This is used instead of setting a specific authentication method, which you can do with <a class="emphasis" href="#--basic">--basic</a>, <a class="emphasis" href="#--digest">--digest</a>, <a class="emphasis" href="#--ntlm">--ntlm</a>, and <a class="emphasis" href="#--negotiate">--negotiate</a>.
|
||||
<p class="level1">Note that using --anyauth is not recommended if you do uploads from stdin, since it may require data to be sent twice and then the client must be able to rewind. If the need should arise when uploading from stdin, the upload operation will fail.
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="-b--cookie"></a><span class="nroffip">-b/--cookie <name=data></span>
|
||||
<p class="level1">(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; NAME2=VALUE2".
|
||||
<p class="level1">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 <a class="emphasis" href="#-L--location">-L/--location</a> option. The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format.
|
||||
<p class="level1"><span Class="bold">NOTE</span> that the file specified with <a class="emphasis" href="#-b--cookie">-b/--cookie</a> is only used as input. No cookies will be stored in the file. To store cookies, use the <a class="emphasis" href="#-c--cookie-jar">-c/--cookie-jar</a> option or you could even save the HTTP headers to a file using <a class="emphasis" href="#-D--dump-header">-D/--dump-header</a>!
|
||||
<p class="level1">If this option is set more than once, the last one will be the one that's used.
|
||||
<p class="level0"><a name="-B--use-ascii"></a><span class="nroffip">-B/--use-ascii</span>
|
||||
<p class="level1">Enable ASCII transfer when using FTP or LDAP. 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.
|
||||
<p class="level1">If this option is used twice, the second one will disable ASCII usage.
|
||||
<p class="level0"><a name="--basic"></a><span class="nroffip">--basic</span>
|
||||
<p class="level1">(HTTP) Tells curl to use HTTP Basic authentication. This is the default and this option is usually pointless, unless you use it to override a previously set option that sets a different authentication method (such as <a class="emphasis" href="#--ntlm">--ntlm</a>, <a class="emphasis" href="#--digest">--digest</a> and <a class="emphasis" href="#--negotiate">--negotiate</a>).
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="--ciphers"></a><span class="nroffip">--ciphers <list of ciphers></span>
|
||||
<p class="level1">(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: <span Class="emphasis"><a href="http://www.openssl.org/docs/apps/ciphers.html">http://www.openssl.org/docs/apps/ciphers.html</a></span>
|
||||
<p class="level1">If this option is used several times, the last one will override the others.
|
||||
<p class="level0"><a name="--compressed"></a><span class="nroffip">--compressed</span>
|
||||
<p class="level1">(HTTP) Request a compressed response using one of the algorithms libcurl supports, and return the uncompressed document. If this option is used and the server sends an unsupported encoding, Curl will report an error.
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle it on/off.
|
||||
<p class="level0"><a name="--connect-timeout"></a><span class="nroffip">--connect-timeout <seconds></span>
|
||||
<p class="level1">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 <a class="emphasis" href="#-m--max-time">-m/--max-time</a> option.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-c--cookie-jar"></a><span class="nroffip">-c/--cookie-jar <file name></span>
|
||||
<p class="level1">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.
|
||||
<p class="level1"><span Class="bold">NOTE</span> If the cookie jar can't be created or written to, the whole curl operation won't fail or even report an error clearly. Using -v will get a warning displayed, but that is the only visible feedback you get about this possibly lethal situation.
|
||||
<p class="level1">If this option is used several times, the last specified file name will be used.
|
||||
<p class="level0"><a name="-C--continue-at"></a><span class="nroffip">-C/--continue-at <offset></span>
|
||||
<p class="level1">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 transferred to the destination. If used with uploads, the ftp server command SIZE will not be used by curl.
|
||||
<p class="level1">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.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--create-dirs"></a><span class="nroffip">--create-dirs</span>
|
||||
<p class="level1">When used in conjunction with the -o option, curl will create the necessary local directory hierarchy as needed. This option creates the dirs mentioned with the -o option, nothing else. If the -o file name uses no dir or if the dirs it mentions already exist, no dir will be created.
|
||||
<p class="level1">To create remote directories when using FTP, try <a class="emphasis" href="#--ftp-create-dirs">--ftp-create-dirs</a>.
|
||||
<p class="level0"><a name="--crlf"></a><span class="nroffip">--crlf</span>
|
||||
<p class="level1">(FTP) Convert LF to CRLF in upload. Useful for MVS (OS/390).
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="-d--data"></a><span class="nroffip">-d/--data <data></span>
|
||||
<p class="level1">(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 application/x-www-form-urlencoded. Compare to <a class="emphasis" href="#-F--form">-F/--form</a>. If this option is used more than once on the same command line, the data pieces specified will be merged together with a separating &-letter. Thus, using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'.
|
||||
<p class="level1">If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be url-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with <span Class="emphasis">--data</span> @foobar".
|
||||
<p class="level1">To post data purely binary, you should instead use the <a class="emphasis" href="#--data-binary">--data-binary</a> option.
|
||||
<p class="level1"><a class="emphasis" href="#-d--data">-d/--data</a> is the same as <a class="emphasis" href="#--data-ascii">--data-ascii</a>.
|
||||
<p class="level1">If this option is used several times, the ones following the first will append data.
|
||||
<p class="level0"><a name="--data-ascii"></a><span class="nroffip">--data-ascii <data></span>
|
||||
<p class="level1">(HTTP) This is an alias for the <a class="emphasis" href="#-d--data">-d/--data</a> option.
|
||||
<p class="level1">If this option is used several times, the ones following the first will append data.
|
||||
<p class="level0"><a name="--data-binary"></a><span class="nroffip">--data-binary <data></span>
|
||||
<p class="level1">(HTTP) This posts data in a similar manner as <a class="emphasis" href="#--data-ascii">--data-ascii</a> does, although when using this option the entire context of the posted data is kept as-is. If you want to post a binary file without the strip-newlines feature of the <a class="emphasis" href="#--data-ascii">--data-ascii</a> option, this is for you.
|
||||
<p class="level1">If this option is used several times, the ones following the first will append data.
|
||||
<p class="level0"><a name="--digest"></a><span class="nroffip">--digest</span>
|
||||
<p class="level1">(HTTP) Enables HTTP Digest authentication. This is a authentication that prevents the password from being sent over the wire in clear text. Use this in combination with the normal <a class="emphasis" href="#-u--user">-u/--user</a> option to set user name and password. See also <a class="emphasis" href="#--ntlm">--ntlm</a>, <a class="emphasis" href="#--negotiate">--negotiate</a> and <a class="emphasis" href="#--anyauth">--anyauth</a> for related options.
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="--disable-eprt"></a><span class="nroffip">--disable-eprt</span>
|
||||
<p class="level1">(FTP) Tell curl to disable the use of the EPRT and LPRT commands when doing active FTP transfers. Curl will normally always first attempt to use EPRT, then LPRT before using PORT, but with this option, it will use PORT right away. EPRT and LPRT are extensions to the original FTP protocol, may not work on all servers but enable more functionality in a better way than the traditional PORT command.
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle this on/off.
|
||||
<p class="level0"><a name="--disable-epsv"></a><span class="nroffip">--disable-epsv</span>
|
||||
<p class="level1">(FTP) Tell curl to disable the use of the EPSV command when doing passive FTP transfers. Curl will normally always first attempt to use EPSV before PASV, but with this option, it will not try using EPSV.
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle this on/off.
|
||||
<p class="level0"><a name="-D--dump-header"></a><span class="nroffip">-D/--dump-header <file></span>
|
||||
<p class="level1">Write the protocol headers to the specified file.
|
||||
<p class="level1">This option is handy to use when you want to store the headers that a HTTP site sends to you. Cookies from the headers could then be read in a second curl invoke by using the <a class="emphasis" href="#-b--cookie">-b/--cookie</a> option! The <a class="emphasis" href="#-c--cookie-jar">-c/--cookie-jar</a> option is however a better way to store cookies.
|
||||
<p class="level1">When used on FTP, the ftp server response lines are considered being "headers" and thus are saved there.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-e--referer"></a><span class="nroffip">-e/--referer <URL></span>
|
||||
<p class="level1">(HTTP) Sends the "Referer Page" information to the HTTP server. This can also be set with the <a class="emphasis" href="#-H--header">-H/--header</a> flag of course. When used with <a class="emphasis" href="#-L--location">-L/--location</a> you can append ";auto" to the --referer URL to make curl automatically set the previous URL when it follows a Location: header. The ";auto" string can be used alone, even if you don't set an initial --referer.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--engine"></a><span class="nroffip">--engine <name></span>
|
||||
<p class="level1">Select the OpenSSL crypto engine to use for cipher operations. Use <a class="emphasis" href="#--engine">--engine list</a> to print a list of build-time supported engines. Note that not all (or none) of the engines may be available at run-time.
|
||||
<p class="level0"><a name="--environment"></a><span class="nroffip">--environment</span>
|
||||
<p class="level1">(RISC OS ONLY) Sets a range of environment variables, using the names the -w option supports, to easier allow extraction of useful information after having run curl.
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle this on/off.
|
||||
<p class="level0"><a name="--egd-file"></a><span class="nroffip">--egd-file <file></span>
|
||||
<p class="level1">(SSL) Specify the path name to the Entropy Gathering Daemon socket. The socket is used to seed the random engine for SSL connections. See also the <a class="emphasis" href="#--random-file">--random-file</a> option.
|
||||
<p class="level0"><a name="-E--cert"></a><span class="nroffip">-E/--cert <certificate[:password]></span>
|
||||
<p class="level1">(SSL) Tells curl to use the specified certificate file when getting a file with HTTPS or FTPS. The certificate must be in PEM format. If the optional password isn't specified, it will be queried for on the terminal. Note that this option assumes a "certificate" file that is the private key and the private certificate concatenated! See <span class="emphasis">--certP and <a class="emphasis" href="#--key">--key</a> to specify them independently.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--cert-type"></a><span class="nroffip">--cert-type <type></span>
|
||||
<p class="level1">(SSL) Tells curl what certificate type the provided certificate is in. PEM, DER and ENG are recognized types. If not specified, PEM is assumed.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--cacert"></a><span class="nroffip">--cacert <CA certificate></span>
|
||||
<p class="level1">(SSL) Tells curl to use the specified certificate file to verify the peer. The file may contain multiple CA certificates. The certificate(s) must be in PEM format.
|
||||
<p class="level1">curl recognizes the environment variable named 'CURL_CA_BUNDLE' if that is set, and uses the given path as a path to a CA cert bundle. This option overrides that variable.
|
||||
<p class="level1">The windows version of curl will automatically look for a CA certs file named ´curl-ca-bundle.crt´, either in the same directory as curl.exe, or in the Current Working Directory, or in any folder along your PATH.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--capath"></a><span class="nroffip">--capath <CA certificate directory></span>
|
||||
<p class="level1">(SSL) Tells curl to use the specified certificate directory to verify the peer. The certificates must be in PEM format, and the directory must have been processed using the c_rehash utility supplied with openssl. Using <a class="emphasis" href="#--capath">--capath</a> can allow curl to make SSL-connections much more efficiently than using <a class="emphasis" href="#--cacert">--cacert</a> if the <a class="emphasis" href="#--cacert">--cacert</a> file contains many CA certificates.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-f--fail"></a><span class="nroffip">-f/--fail</span>
|
||||
<p class="level1">(HTTP) Fail silently (no output at all) on server errors. This is mostly done like this to better enable scripts etc to better deal with failed attempts. In normal cases when a HTTP server fails to deliver a document, it returns an HTML document stating so (which often also describes why and more). This flag will prevent curl from outputting that and return error 22.
|
||||
<p class="level1">This method is not fail-safe and there are occasions where non-succesful response codes will slip through, especially when authentication is involved (response codes 401 and 407).
|
||||
<p class="level1">If this option is used twice, the second will again disable silent failure.
|
||||
<p class="level0"><a name="--ftp-account"></a><span class="nroffip">--ftp-account [data]</span>
|
||||
<p class="level1">(FTP) When an FTP server asks for "account data" after user name and password has been provided, this data is sent off using the ACCT command. (Added in 7.13.0)
|
||||
<p class="level1">If this option is used twice, the second will override the previous use.
|
||||
<p class="level0"><a name="--ftp-create-dirs"></a><span class="nroffip">--ftp-create-dirs</span>
|
||||
<p class="level1">(FTP) When an FTP URL/operation uses a path that doesn't currently exist on the server, the standard behavior of curl is to fail. Using this option, curl will instead attempt to create missing directories.
|
||||
<p class="level1">If this option is used twice, the second will again disable directory creation.
|
||||
<p class="level0"><a name="--ftp-method"></a><span class="nroffip">--ftp-method [method]</span>
|
||||
<p class="level1">(FTP) Control what method curl should use to reach a file on a FTP(S) server. The method argument should be one of the following alternatives:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="multicwd"></a><span class="nroffip">multicwd</span>
|
||||
<p class="level2">curl does a single CWD operation for each path part in the given URL. For deep hierarchies this means very many commands. This is how RFC1738 says it should be done. This is the default but the slowest behavior.
|
||||
<p class="level1"><a name="nocwd"></a><span class="nroffip">nocwd</span>
|
||||
<p class="level2">curl does no CWD at all. curl will do SIZE, RETR, STOR etc and give a full path to the server for all these commands. This is the fastest behavior.
|
||||
<p class="level1"><a name="singlecwd"></a><span class="nroffip">singlecwd</span>
|
||||
<p class="level2">curl does one CWD with the full target directory and then operates on the file "normally" (like in the multicwd case). This is somewhat more standards compliant than 'nocwd' but without the full penalty of 'multicwd'.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="--ftp-pasv"></a><span class="nroffip">--ftp-pasv</span>
|
||||
<p class="level1">(FTP) Use PASV when transferring. PASV is the internal default behavior, but using this option can be used to override a previous --ftp-port option. (Added in 7.11.0)
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="--ftp-alternative-to-user"></a><span class="nroffip">--ftp-alternative-to-user <command></span>
|
||||
<p class="level1">(FTP) If authenticating with the USER and PASS commands fails, send this command. When connecting to Tumbleweed's Secure Transport server over FTPS using a client certificate, using "SITE AUTH" will tell the server to retrieve the username from the certificate. (Added in 7.15.5)
|
||||
<p class="level0"><a name="--ftp-skip-pasv-ip"></a><span class="nroffip">--ftp-skip-pasv-ip</span>
|
||||
<p class="level1">(FTP) Tell curl to not use the IP address the server suggests in its response to curl's PASV command when curl connects the data connection. Instead curl will re-use the same IP address it already uses for the control connection. (Added in 7.14.2)
|
||||
<p class="level1">This option has no effect if PORT, EPRT or EPSV is used instead of PASV.
|
||||
<p class="level1">If this option is used twice, the second will again use the server's suggested address.
|
||||
<p class="level0"><a name="--ftp-ssl"></a><span class="nroffip">--ftp-ssl</span>
|
||||
<p class="level1">(FTP) Try to use SSL/TLS for the FTP connection. Reverts to a non-secure connection if the server doesn't support SSL/TLS. See also <a class="emphasis" href="#--ftp-ssl-control">--ftp-ssl-control</a> and <a class="emphasis" href="#--ftp-ssl-reqd">--ftp-ssl-reqd</a> for different levels of encryption required. (Added in 7.11.0)
|
||||
<p class="level1">If this option is used twice, the second will again disable this.
|
||||
<p class="level0"><a name="--ftp-ssl-control"></a><span class="nroffip">--ftp-ssl-control</span>
|
||||
<p class="level1">(FTP) Require SSL/TLS for the ftp login, clear for transfer. Allows secure authentication, but non-encrypted data transfers for efficiency. Fails the transfer if the server doesn't support SSL/TLS. (Added in 7.16.0)
|
||||
<p class="level1">If this option is used twice, the second will again disable this.
|
||||
<p class="level0"><a name="--ftp-ssl-reqd"></a><span class="nroffip">--ftp-ssl-reqd</span>
|
||||
<p class="level1">(FTP) Require SSL/TLS for the FTP connection. Terminates the connection if the server doesn't support SSL/TLS. (Added in 7.15.5)
|
||||
<p class="level1">If this option is used twice, the second will again disable this.
|
||||
<p class="level0"><a name="-F--form"></a><span class="nroffip">-F/--form <name=content></span>
|
||||
<p class="level1">(HTTP) This lets curl emulate a filled in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC1867. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the letter <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.
|
||||
<p class="level1">Example, to send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:
|
||||
<p class="level1"><span Class="bold">curl</span> -F password=@/etc/passwd www.mypasswords.com
|
||||
<p class="level1">To read the file's content from stdin instead of a file, use - where the file name should've been. This goes for both @ and < constructs.
|
||||
<p class="level1">You can also tell curl what Content-Type to use by using 'type=', in a manner similar to:
|
||||
<p class="level1"><span Class="bold">curl</span> -F "web=@index.html;type=text/html" url.com
|
||||
<p class="level1">or
|
||||
<p class="level1"><span Class="bold">curl</span> -F "name=daniel;type=text/foo" url.com
|
||||
<p class="level1">You can also explicitly change the name field of an file upload part by setting filename=, like this:
|
||||
<p class="level1"><span Class="bold">curl</span> -F "file=@localfile;filename=nameinpost" url.com
|
||||
<p class="level1">See further examples and details in the MANUAL.
|
||||
<p class="level1">This option can be used multiple times.
|
||||
<p class="level0"><a name="--form-string"></a><span class="nroffip">--form-string <name=string></span>
|
||||
<p class="level1">(HTTP) Similar to <span Class="emphasis">--form</span> except that the value string for the named parameter is used literally. Leading '@' and '<' characters, and the ';type=' string in the value have no special meaning. Use this in preference to <span Class="emphasis">--form</span> if there's any possibility that the string value may accidentally trigger the '@' or '<' features of <span Class="emphasis">--form</span>.
|
||||
<p class="level0"><a name="-g--globoff"></a><span class="nroffip">-g/--globoff</span>
|
||||
<p class="level1">This option switches off the "URL globbing parser". When you set this option, you can specify URLs that contain the letters {}[] without having them being interpreted by curl itself. Note that these letters are not normal legal URL contents but they should be encoded according to the URI standard.
|
||||
<p class="level0"><a name="-G--get"></a><span class="nroffip">-G/--get</span>
|
||||
<p class="level1">When used, this option will make all data specified with <a class="emphasis" href="#-d--data">-d/--data</a> or <a class="emphasis" href="#--data-binary">--data-binary</a> to be used in a HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
|
||||
<p class="level1">If used in combination with -I, the POST data will instead be appended to the URL with a HEAD request.
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="-h--help"></a><span class="nroffip">-h/--help</span>
|
||||
<p class="level1">Usage help.
|
||||
<p class="level0"><a name="-H--header"></a><span class="nroffip">-H/--header <header></span>
|
||||
<p class="level1">(HTTP) Extra header to use when getting a web page. You may specify any number of extra headers. Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do. You should not replace internally set headers without knowing perfectly well what you're doing. Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H "Host:".
|
||||
<p class="level1">curl will make sure that each header you add/replace get sent with the proper end of line marker, you should thus <span Class="bold">not</span> add that as a part of the header content: do not add newlines or carriage returns they will only mess things up for you.
|
||||
<p class="level1">See also the <a class="emphasis" href="#-A--user-agent">-A/--user-agent</a> and <a class="emphasis" href="#-e--referer">-e/--referer</a> options.
|
||||
<p class="level1">This option can be used multiple times to add/replace/remove multiple headers.
|
||||
<p class="level0"><a name="--ignore-content-length"></a><span class="nroffip">--ignore-content-length</span>
|
||||
<p class="level1">(HTTP) Ignore the Content-Length header. This is particularly useful for servers running Apache 1.x, which will report incorrect Content-Length for files larger than 2 gigabytes.
|
||||
<p class="level0"><a name="-i--include"></a><span class="nroffip">-i/--include</span>
|
||||
<p class="level1">(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...
|
||||
<p class="level1">If this option is used twice, the second will again disable header include.
|
||||
<p class="level0"><a name="--interface"></a><span class="nroffip">--interface <name></span>
|
||||
<p class="level1">Perform an operation using a specified interface. You can enter interface name, IP address or host name. An example could look like:
|
||||
<p class="level1"> curl --interface eth0:1 <a href="http://www.netscape.com/">http://www.netscape.com/</a>
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-I--head"></a><span class="nroffip">-I/--head</span>
|
||||
<p class="level1">(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP or FILE file, curl displays the file size and last modification time only.
|
||||
<p class="level1">If this option is used twice, the second will again disable header only.
|
||||
<p class="level0"><a name="-j--junk-session-cookies"></a><span class="nroffip">-j/--junk-session-cookies</span>
|
||||
<p class="level1">(HTTP) When curl is told to read cookies from a given file, this option will make it discard all "session cookies". This will basically have the same effect as if a new session is started. Typical browsers always discard session cookies when they're closed down.
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle this on/off.
|
||||
<p class="level0"><a name="-k--insecure"></a><span class="nroffip">-k/--insecure</span>
|
||||
<p class="level1">(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered "insecure" to fail unless <a class="emphasis" href="#-k--insecure">-k/--insecure</a> is used.
|
||||
<p class="level1">See this online resource for further details: <span Class="bold"><a href="http://curl.haxx.se/docs/sslcerts.html">http://curl.haxx.se/docs/sslcerts.html</a></span>
|
||||
<p class="level1">If this option is used twice, the second time will again disable it.
|
||||
<p class="level0"><a name="--key"></a><span class="nroffip">--key <key></span>
|
||||
<p class="level1">(SSL) Private key file name. Allows you to provide your private key in this separate file.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--key-type"></a><span class="nroffip">--key-type <type></span>
|
||||
<p class="level1">(SSL) Private key file type. Specify which type your <a class="emphasis" href="#--key">--key</a> provided private key is. DER, PEM and ENG are supported. If not specified, PEM is assumed.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--krb4"></a><span class="nroffip">--krb4 <level></span>
|
||||
<p class="level1">(FTP) Enable kerberos4 authentication and use. The level must be entered and should be one of 'clear', 'safe', 'confidential' or 'private'. Should you use a level that is not one of these, 'private' will instead be used.
|
||||
<p class="level1">This option requires that the library was built with kerberos4 support. This is not very common. Use <a class="emphasis" href="#-V--version">-V/--version</a> to see if your curl supports it.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-K--config"></a><span class="nroffip">-K/--config <config file></span>
|
||||
<p class="level1">Specify which config file to read curl arguments from. The config file is a text file in which command line arguments can be written which then will be used as if they were written on the actual command line. Options and their parameters must be specified on the same config file line. If the parameter is to contain white spaces, the parameter must be enclosed within quotes. If the first column of a config line is a '#' character, the rest of the line will be treated as a comment.
|
||||
<p class="level1">Specify the filename as '-' to make curl read the file from stdin.
|
||||
<p class="level1">Note that to be able to specify a URL in the config file, you need to specify it using the <a class="emphasis" href="#--url">--url</a> option, and not by simply writing the URL on its own line. So, it could look similar to this:
|
||||
<p class="level1">url = "<a href="http://curl.haxx.se/docs/">http://curl.haxx.se/docs/</a>"
|
||||
<p class="level1">This option can be used multiple times.
|
||||
<p class="level1">When curl is invoked, it always (unless <a class="emphasis" href="#-q">-q</a> is used) checks for a default config file and uses it if found. The default config file is checked for in the following places in this order:
|
||||
<p class="level1">1) curl tries to find the "home dir": It first checks for the CURL_HOME and then the HOME environment variables. Failing that, it uses getpwuid() on unix-like systems (which returns the home dir given the current user in your system). On Windows, it then checks for the APPDATA variable, or as a last resort the '%USERPROFILE%Application Data'.
|
||||
<p class="level1">2) On windows, if there is no _curlrc file in the home dir, it checks for one in the same dir the executable curl is placed. On unix-like systems, it will simply try to load .curlrc from the determined home dir.
|
||||
<p class="level0"><a name="--limit-rate"></a><span class="nroffip">--limit-rate <speed></span>
|
||||
<p class="level1">Specify the maximum transfer rate you want curl to use. This feature is useful if you have a limited pipe and you'd like your transfer not use your entire bandwidth.
|
||||
<p class="level1">The given speed is measured in bytes/second, unless a suffix is appended. Appending 'k' or 'K' will count the number as kilobytes, 'm' or M' makes it megabytes while 'g' or 'G' makes it gigabytes. Examples: 200K, 3m and 1G.
|
||||
<p class="level1">If you are also using the <a class="emphasis" href="#-Y--speed-limit">-Y/--speed-limit</a> option, that option will take precedence and might cripple the rate-limiting slightly, to help keeping the speed-limit logic working.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-l--list-only"></a><span class="nroffip">-l/--list-only</span>
|
||||
<p class="level1">(FTP) When listing an FTP directory, this switch forces a name-only view. Especially useful if you want to machine-parse the contents of an FTP directory since the normal directory view doesn't use a standard look or format.
|
||||
<p class="level1">This option causes an FTP NLST command to be sent. Some FTP servers list only files in their response to NLST; they do not include subdirectories and symbolic links.
|
||||
<p class="level1">If this option is used twice, the second will again disable list only.
|
||||
<p class="level0"><a name="--local-port"></a><span class="nroffip">--local-port <num>[-num]</span>
|
||||
<p class="level1">Set a prefered number or range of local port numbers to use for the connection(s). Note that port numbers by nature is a scarce resource that will be busy at times so setting this range to something too narrow might cause unnecessary connection setup failures. (Added in 7.15.2)
|
||||
<p class="level0"><a name="-L--location"></a><span class="nroffip">-L/--location</span>
|
||||
<p class="level1">(HTTP/HTTPS) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code) this option will make curl redo the request on the new place. If used together with <a class="emphasis" href="#-i--include">-i/--include</a> or <a class="emphasis" href="#-I--head">-I/--head</a>, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See also <a class="emphasis" href="#--location-trusted">--location-trusted</a> on how to change this. You can limit the amount of redirects to follow by using the <a class="emphasis" href="#--max-redirs">--max-redirs</a> option.
|
||||
<p class="level1">If this option is used twice, the second will again disable location following.
|
||||
<p class="level0"><a name="--location-trusted"></a><span class="nroffip">--location-trusted</span>
|
||||
<p class="level1">(HTTP/HTTPS) Like <a class="emphasis" href="#-L--location">-L/--location</a>, but will allow sending the name + password to all hosts that the site may redirect to. This may or may not introduce a security breach if the site redirects you do a site to which you'll send your authentication info (which is plaintext in the case of HTTP Basic authentication).
|
||||
<p class="level1">If this option is used twice, the second will again disable location following.
|
||||
<p class="level0"><a name="--max-filesize"></a><span class="nroffip">--max-filesize <bytes></span>
|
||||
<p class="level1">Specify the maximum size (in bytes) of a file to download. If the file requested is larger than this value, the transfer will not start and curl will return with exit code 63.
|
||||
<p class="level1">NOTE: The file size is not always known prior to download, and for such files this option has no effect even if the file transfer ends up being larger than this given limit. This concerns both FTP and HTTP transfers.
|
||||
<p class="level0"><a name="-m--max-time"></a><span class="nroffip">-m/--max-time <seconds></span>
|
||||
<p class="level1">Maximum time in seconds that you allow the whole operation to take. This is useful for preventing your batch jobs from hanging for hours due to slow networks or links going down. See also the <a class="emphasis" href="#--connect-timeout">--connect-timeout</a> option.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-M--manual"></a><span class="nroffip">-M/--manual</span>
|
||||
<p class="level1">Manual. Display the huge help text.
|
||||
<p class="level0"><a name="-n--netrc"></a><span class="nroffip">-n/--netrc</span>
|
||||
<p class="level1">Makes curl scan the <span Class="emphasis">.netrc</span> file in the user's home directory for login name and password. This is typically used for ftp on unix. If used with http, curl will enable user authentication. See <span Class="manpage">netrc(4)</span> or <span Class="manpage">ftp(1)</span> for details on the file format. Curl will not complain if that file hasn't the right permissions (it should not be world nor group readable). The environment variable "HOME" is used to find the home directory.
|
||||
<p class="level1">A quick and very simple example of how to setup a <span Class="emphasis">.netrc</span> to allow curl to ftp to the machine host.domain.com with user name 'myself' and password 'secret' should look similar to:
|
||||
<p class="level1"><span Class="bold">machine host.domain.com login myself password secret</span>
|
||||
<p class="level1">If this option is used twice, the second will again disable netrc usage.
|
||||
<p class="level0"><a name="--netrc-optional"></a><span class="nroffip">--netrc-optional</span>
|
||||
<p class="level1">Very similar to <span Class="emphasis">--netrc</span>, but this option makes the .netrc usage <span Class="bold">optional</span> and not mandatory as the <span Class="emphasis">--netrc</span> does.
|
||||
<p class="level0"><a name="--negotiate"></a><span class="nroffip">--negotiate</span>
|
||||
<p class="level1">(HTTP) Enables GSS-Negotiate authentication. The GSS-Negotiate method was designed by Microsoft and is used in their web applications. It is primarily meant as a support for Kerberos5 authentication but may be also used along with another authentication methods. For more information see IETF draft draft-brezak-spnego-http-04.txt.
|
||||
<p class="level1">This option requires that the library was built with GSSAPI support. This is not very common. Use <a class="emphasis" href="#-V--version">-V/--version</a> to see if your version supports GSS-Negotiate.
|
||||
<p class="level1">When using this option, you must also provide a fake -u/--user option to activate the authentication code properly. Sending a '-u :' is enough as the user name and password from the -u option aren't actually used.
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="-N--no-buffer"></a><span class="nroffip">-N/--no-buffer</span>
|
||||
<p class="level1">Disables the buffering of the output stream. In normal work situations, curl will use a standard buffered output stream that will have the effect that it will output the data in chunks, not necessarily exactly when the data arrives. Using this option will disable that buffering.
|
||||
<p class="level1">If this option is used twice, the second will again switch on buffering.
|
||||
<p class="level0"><a name="--no-sessionid"></a><span class="nroffip">--no-sessionid</span>
|
||||
<p class="level1">(SSL) Disable curl's use of SSL session-ID caching. By default all transfers are done using the cache. Note that while nothing ever should get hurt by attempting to reuse SSL session-IDs, there seem to be broken SSL implementations in the wild that may require you to disable this in order for you to succeed. (Added in 7.16.0)
|
||||
<p class="level1">If this option is used twice, the second will again switch on use of the session cache.
|
||||
<p class="level0"><a name="--ntlm"></a><span class="nroffip">--ntlm</span>
|
||||
<p class="level1">(HTTP) Enables NTLM authentication. The NTLM authentication method was designed by Microsoft and is used by IIS web servers. It is a proprietary protocol, reversed engineered by clever people and implemented in curl based on their efforts. This kind of behavior should not be endorsed, you should encourage everyone who uses NTLM to switch to a public and documented authentication method instead. Such as Digest.
|
||||
<p class="level1">If you want to enable NTLM for your proxy authentication, then use <a class="emphasis" href="#--proxy-ntlm">--proxy-ntlm</a>.
|
||||
<p class="level1">This option requires that the library was built with SSL support. Use <a class="emphasis" href="#-V--version">-V/--version</a> to see if your curl supports NTLM.
|
||||
<p class="level1">If this option is used several times, the following occurrences make no difference.
|
||||
<p class="level0"><a name="-o--output"></a><span class="nroffip">-o/--output <file></span>
|
||||
<p class="level1">Write output to <file> instead of stdout. If you are using {} or [] to fetch multiple documents, you can use '#' followed by a number in the <file> specifier. That variable will be replaced with the current string for the URL being fetched. Like in:
|
||||
<p class="level1"> curl http://{one,two}.site.com -o "file_#1.txt"
|
||||
<p class="level1">or use several variables like:
|
||||
<p class="level1"> curl http://{site,host}.host[1-5].com -o "#1_#2"
|
||||
<p class="level1">You may use this option as many times as you have number of URLs.
|
||||
<p class="level1">See also the <a class="emphasis" href="#--create-dirs">--create-dirs</a> option to create the local directories dynamically.
|
||||
<p class="level0"><a name="-O--remote-name"></a><span class="nroffip">-O/--remote-name</span>
|
||||
<p class="level1">Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)
|
||||
<p class="level1">The remote file name to use for saving is extracted from the given URL, nothing else.
|
||||
<p class="level1">You may use this option as many times as you have number of URLs.
|
||||
<p class="level0"><a name="--pass"></a><span class="nroffip">--pass <phrase></span>
|
||||
<p class="level1">(SSL) Pass phrase for the private key
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--proxy-anyauth"></a><span class="nroffip">--proxy-anyauth</span>
|
||||
<p class="level1">Tells curl to pick a suitable authentication method when communicating with the given proxy. This will cause an extra request/response round-trip. (Added in 7.13.2)
|
||||
<p class="level1">If this option is used twice, the second will again disable the proxy use-any authentication.
|
||||
<p class="level0"><a name="--proxy-basic"></a><span class="nroffip">--proxy-basic</span>
|
||||
<p class="level1">Tells curl to use HTTP Basic authentication when communicating with the given proxy. Use <a class="emphasis" href="#--basic">--basic</a> for enabling HTTP Basic with a remote host. Basic is the default authentication method curl uses with proxies.
|
||||
<p class="level1">If this option is used twice, the second will again disable proxy HTTP Basic authentication.
|
||||
<p class="level0"><a name="--proxy-digest"></a><span class="nroffip">--proxy-digest</span>
|
||||
<p class="level1">Tells curl to use HTTP Digest authentication when communicating with the given proxy. Use <a class="emphasis" href="#--digest">--digest</a> for enabling HTTP Digest with a remote host.
|
||||
<p class="level1">If this option is used twice, the second will again disable proxy HTTP Digest.
|
||||
<p class="level0"><a name="--proxy-ntlm"></a><span class="nroffip">--proxy-ntlm</span>
|
||||
<p class="level1">Tells curl to use HTTP NTLM authentication when communicating with the given proxy. Use <a class="emphasis" href="#--ntlm">--ntlm</a> for enabling NTLM with a remote host.
|
||||
<p class="level1">If this option is used twice, the second will again disable proxy HTTP NTLM.
|
||||
<p class="level0"><a name="-p--proxytunnel"></a><span class="nroffip">-p/--proxytunnel</span>
|
||||
<p class="level1">When an HTTP proxy is used (<a class="emphasis" href="#-x--proxy">-x/--proxy</a>), this option will cause non-HTTP protocols to attempt to tunnel through the proxy instead of merely using it to do HTTP-like operations. The tunnel approach is made with the HTTP proxy CONNECT request and requires that the proxy allows direct connect to the remote port number curl wants to tunnel through to.
|
||||
<p class="level1">If this option is used twice, the second will again disable proxy tunnel.
|
||||
<p class="level0"><a name="-P--ftp-port"></a><span class="nroffip">-P/--ftp-port <address></span>
|
||||
<p class="level1">(FTP) Reverses the initiator/listener roles when connecting with ftp. This switch makes Curl use the PORT command instead of PASV. In practice, PORT tells the server to connect to the client's specified address and port, while PASV asks the server for an ip address and port to connect to. <address> should be one of:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="interface"></a><span class="nroffip">interface</span>
|
||||
<p class="level2">i.e "eth0" to specify which interface's IP address you want to use (Unix only)
|
||||
<p class="level1"><a name="IP"></a><span class="nroffip">IP address</span>
|
||||
<p class="level2">i.e "192.168.10.1" to specify exact IP number
|
||||
<p class="level1"><a name="host"></a><span class="nroffip">host name</span>
|
||||
<p class="level2">i.e "my.host.domain" to specify machine
|
||||
<p class="level1"><a name="-"></a><span class="nroffip">-</span>
|
||||
<p class="level2">make curl pick the same IP address that is already used for the control connection
|
||||
<p class="level1">
|
||||
<p class="level1">If this option is used several times, the last one will be used. Disable the use of PORT with <a class="emphasis" href="#--ftp-pasv">--ftp-pasv</a>. Disable the attempt to use the EPRT command instead of PORT by using <a class="emphasis" href="#--disable-eprt">--disable-eprt</a>. EPRT is really PORT++.
|
||||
<p class="level0"><a name="-q"></a><span class="nroffip">-q</span>
|
||||
<p class="level1">If used as the first parameter on the command line, the <span Class="emphasis">curlrc</span> config file will not be read and used. See the <a class="emphasis" href="#-K--config">-K/--config</a> for details on the default config file search path.
|
||||
<p class="level0"><a name="-Q--quote"></a><span class="nroffip">-Q/--quote <command></span>
|
||||
<p class="level1">(FTP) Send an arbitrary command to the remote FTP server. Quote commands are sent BEFORE the transfer is taking place (just after the initial PWD command to be exact). To make commands take place after a successful transfer, prefix them with a dash '-'. To make commands get sent after libcurl has changed working directory, just before the transfer command(s), prefix the command with '+'. You may specify any amount of commands. If the server returns failure for one of the commands, the entire operation will be aborted. You must send syntactically correct FTP commands as RFC959 defines.
|
||||
<p class="level1">This option can be used multiple times.
|
||||
<p class="level0"><a name="--random-file"></a><span class="nroffip">--random-file <file></span>
|
||||
<p class="level1">(SSL) Specify the path name to file containing what will be considered as random data. The data is used to seed the random engine for SSL connections. See also the <a class="emphasis" href="#--egd-file">--egd-file</a> option.
|
||||
<p class="level0"><a name="-r--range"></a><span class="nroffip">-r/--range <range></span>
|
||||
<p class="level1">(HTTP/FTP) Retrieve a byte range (i.e a partial document) from a HTTP/1.1 or FTP server. Ranges can be specified in a number of ways.
|
||||
<p class="level2">
|
||||
<p class="level2"><span Class="bold">0-499</span> specifies the first 500 bytes
|
||||
<p class="level2"><span Class="bold">500-999</span> specifies the second 500 bytes
|
||||
<p class="level2"><span Class="bold">-500</span> specifies the last 500 bytes
|
||||
<p class="level2"><span Class="bold">9500-</span> specifies the bytes from offset 9500 and forward
|
||||
<p class="level2"><span Class="bold">0-0,-1</span> specifies the first and last byte only(*)(H)
|
||||
<p class="level2"><span Class="bold">500-700,600-799</span> specifies 300 bytes from offset 500(H)
|
||||
<p class="level2"><span Class="bold">100-199,500-599</span> specifies two separate 100 bytes ranges(*)(H)
|
||||
<p class="level1">
|
||||
<p class="level1">(*) = NOTE that this will cause the server to reply with a multipart response!
|
||||
<p class="level1">You should also be aware that many HTTP/1.1 servers do not have this feature enabled, so that when you attempt to get a range, you'll instead get the whole document.
|
||||
<p class="level1">FTP range downloads only support the simple syntax 'start-stop' (optionally with one of the numbers omitted). It depends on the non-RFC command SIZE.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-R--remote-time"></a><span class="nroffip">-R/--remote-time</span>
|
||||
<p class="level1">When used, this will make libcurl attempt to figure out the timestamp of the remote file, and if that is available make the local file get that same timestamp.
|
||||
<p class="level1">If this option is used twice, the second time disables this again.
|
||||
<p class="level0"><a name="--retry"></a><span class="nroffip">--retry <num></span>
|
||||
<p class="level1">If a transient error is returned when curl tries to perform a transfer, it will retry this number of times before giving up. Setting the number to 0 makes curl do no retries (which is the default). Transient error means either: a timeout, an FTP 5xx response code or an HTTP 5xx response code.
|
||||
<p class="level1">When curl is about to retry a transfer, it will first wait one second and then for all forthcoming retries it will double the waiting time until it reaches 10 minutes which then will be the delay between the rest of the retries. By using <a class="emphasis" href="#--retry-delay">--retry-delay</a> you disable this exponential backoff algorithm. See also <a class="emphasis" href="#--retry-max-time">--retry-max-time</a> to limit the total time allowed for retries. (Added in 7.12.3)
|
||||
<p class="level1">If this option is used multiple times, the last occurrence decide the amount.
|
||||
<p class="level0"><a name="--retry-delay"></a><span class="nroffip">--retry-delay <seconds></span>
|
||||
<p class="level1">Make curl sleep this amount of time between each retry when a transfer has failed with a transient error (it changes the default backoff time algorithm between retries). This option is only interesting if <a class="emphasis" href="#--retry">--retry</a> is also used. Setting this delay to zero will make curl use the default backoff time. (Added in 7.12.3)
|
||||
<p class="level1">If this option is used multiple times, the last occurrence decide the amount.
|
||||
<p class="level0"><a name="--retry-max-time"></a><span class="nroffip">--retry-max-time <seconds></span>
|
||||
<p class="level1">The retry timer is reset before the first transfer attempt. Retries will be done as usual (see <a class="emphasis" href="#--retry">--retry</a>) as long as the timer hasn't reached this given limit. Notice that if the timer hasn't reached the limit, the request will be made and while performing, it may take longer than this given time period. To limit a single request´s maximum time, use <a class="emphasis" href="#-m--max-time">-m/--max-time</a>. Set this option to zero to not timeout retries. (Added in 7.12.3)
|
||||
<p class="level1">If this option is used multiple times, the last occurrence decide the amount.
|
||||
<p class="level0"><a name="-s--silent"></a><span class="nroffip">-s/--silent</span>
|
||||
<p class="level1">Silent mode. Don't show progress meter or error messages. Makes Curl mute.
|
||||
<p class="level1">If this option is used twice, the second will again disable silent mode.
|
||||
<p class="level0"><a name="-S--show-error"></a><span class="nroffip">-S/--show-error</span>
|
||||
<p class="level1">When used with -s it makes curl show error message if it fails.
|
||||
<p class="level1">If this option is used twice, the second will again disable show error.
|
||||
<p class="level0"><a name="--socks4"></a><span class="nroffip">--socks4 <host[:port]></span>
|
||||
<p class="level1">Use the specified SOCKS4 proxy. If the port number is not specified, it is assumed at port 1080. (Added in 7.15.2)
|
||||
<p class="level1">This option overrides any previous use of <a class="emphasis" href="#-x--proxy">-x/--proxy</a>, as they are mutually exclusive.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--socks5"></a><span class="nroffip">--socks5 <host[:port]></span>
|
||||
<p class="level1">Use the specified SOCKS5 proxy. If the port number is not specified, it is assumed at port 1080. (Added in 7.11.1)
|
||||
<p class="level1">This option overrides any previous use of <a class="emphasis" href="#-x--proxy">-x/--proxy</a>, as they are mutually exclusive.
|
||||
<p class="level1">If this option is used several times, the last one will be used. (This option was previously wrongly documented and used as --socks without the number appended.)
|
||||
<p class="level0"><a name="--stderr"></a><span class="nroffip">--stderr <file></span>
|
||||
<p class="level1">Redirect all writes to stderr to the specified file instead. If the file name is a plain '-', it is instead written to stdout. This option has no point when you're using a shell with decent redirecting capabilities.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--tcp-nodelay"></a><span class="nroffip">--tcp-nodelay</span>
|
||||
<p class="level1">Turn on the TCP_NODELAY option. See the <span Class="emphasis">curl_easy_setopt(3)</span> man page for details about this option. (Added in 7.11.2)
|
||||
<p class="level1">If this option is used several times, each occurrence toggles this on/off.
|
||||
<p class="level0"><a name="-t--telnet-option"></a><span class="nroffip">-t/--telnet-option <OPT=val></span>
|
||||
<p class="level1">Pass options to the telnet protocol. Supported options are:
|
||||
<p class="level1">TTYPE=<term> Sets the terminal type.
|
||||
<p class="level1">XDISPLOC=<X display> Sets the X display location.
|
||||
<p class="level1">NEW_ENV=<var,val> Sets an environment variable.
|
||||
<p class="level0"><a name="-T--upload-file"></a><span class="nroffip">-T/--upload-file <file></span>
|
||||
<p class="level1">This transfers the specified local file to the remote URL. If there is no file part in the specified URL, Curl will append the local file name. NOTE that you must use a trailing / on the last directory to really prove to Curl that there is no file name or curl will think that your last directory name is the remote file name to use. That will most likely cause the upload operation to fail. If this is used on a http(s) server, the PUT command will be used.
|
||||
<p class="level1">Use the file name "-" (a single dash) to use stdin instead of a given file.
|
||||
<p class="level1">You can specify one -T for each URL on the command line. Each -T + URL pair specifies what to upload and to where. curl also supports "globbing" of the -T argument, meaning that you can upload multiple files to a single URL by using the same URL globbing style supported in the URL, like this:
|
||||
<p class="level1">curl -T "{file1,file2}" <a href="http://www.uploadtothissite.com">http://www.uploadtothissite.com</a>
|
||||
<p class="level1">or even
|
||||
<p class="level1">curl -T "img[1-1000].png" <a href="ftp://ftp.picturemania.com/upload/">ftp://ftp.picturemania.com/upload/</a>
|
||||
<p class="level0"><a name="--trace"></a><span class="nroffip">--trace <file></span>
|
||||
<p class="level1">Enables a full trace dump of all incoming and outgoing data, including descriptive information, to the given output file. Use "-" as filename to have the output sent to stdout.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--trace-ascii"></a><span class="nroffip">--trace-ascii <file></span>
|
||||
<p class="level1">Enables a full trace dump of all incoming and outgoing data, including descriptive information, to the given output file. Use "-" as filename to have the output sent to stdout.
|
||||
<p class="level1">This is very similar to <a class="emphasis" href="#--trace">--trace</a>, but leaves out the hex part and only shows the ASCII part of the dump. It makes smaller output that might be easier to read for untrained humans.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--trace-time"></a><span class="nroffip">--trace-time</span>
|
||||
<p class="level1">Prepends a time stamp to each trace or verbose line that curl displays. (Added in 7.14.0)
|
||||
<p class="level1">If this option is used several times, each occurrence will toggle it on/off.
|
||||
<p class="level0"><a name="-u--user"></a><span class="nroffip">-u/--user <user:password></span>
|
||||
<p class="level1">Specify user and password to use for server authentication. Overrides <a class="emphasis" href="#-n--netrc">-n/--netrc</a> and <a class="emphasis" href="#--netrc-optional">--netrc-optional</a>.
|
||||
<p class="level1">If you use an SSPI-enabled curl binary and do NTLM autentication, you can force curl to pick up the user name and password from your environment by simply specifying a single colon with this option: "-u :".
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-U--proxy-user"></a><span class="nroffip">-U/--proxy-user <user:password></span>
|
||||
<p class="level1">Specify user and password to use for proxy authentication.
|
||||
<p class="level1">If you use an SSPI-enabled curl binary and do NTLM autentication, you can force curl to pick up the user name and password from your environment by simply specifying a single colon with this option: "-U :".
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--url"></a><span class="nroffip">--url <URL></span>
|
||||
<p class="level1">Specify a URL to fetch. This option is mostly handy when you want to specify URL(s) in a config file.
|
||||
<p class="level1">This option may be used any number of times. To control where this URL is written, use the <a class="emphasis" href="#-o--output">-o/--output</a> or the <a class="emphasis" href="#-O--remote-name">-O/--remote-name</a> options.
|
||||
<p class="level0"><a name="-v--verbose"></a><span class="nroffip">-v/--verbose</span>
|
||||
<p class="level1">Makes the fetching more verbose/talkative. Mostly usable for debugging. Lines starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases and lines starting with '*' means additional info provided by curl.
|
||||
<p class="level1">Note that if you only want HTTP headers in the output, <a class="emphasis" href="#-i--include">-i/--include</a> might be option you're looking for.
|
||||
<p class="level1">If you think this option still doesn't give you enough details, consider using <a class="emphasis" href="#--trace">--trace</a> or <a class="emphasis" href="#--trace-ascii">--trace-ascii</a> instead.
|
||||
<p class="level1">If this option is used twice, the second will again disable verbose.
|
||||
<p class="level0"><a name="-V--version"></a><span class="nroffip">-V/--version</span>
|
||||
<p class="level1">Displays information about curl and the libcurl version it uses.
|
||||
<p class="level1">The first line includes the full version of curl, libcurl and other 3rd party libraries linked with the executable.
|
||||
<p class="level1">The second line (starts with "Protocols:") shows all protocols that libcurl reports to support.
|
||||
<p class="level1">The third line (starts with "Features:") shows specific features libcurl reports to offer. Available features include:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="IPv6"></a><span class="nroffip">IPv6</span>
|
||||
<p class="level2">You can use IPv6 with this.
|
||||
<p class="level1"><a name="krb4"></a><span class="nroffip">krb4</span>
|
||||
<p class="level2">Krb4 for ftp is supported.
|
||||
<p class="level1"><a name="SSL"></a><span class="nroffip">SSL</span>
|
||||
<p class="level2">HTTPS and FTPS are supported.
|
||||
<p class="level1"><a name="libz"></a><span class="nroffip">libz</span>
|
||||
<p class="level2">Automatic decompression of compressed files over HTTP is supported.
|
||||
<p class="level1"><a name="NTLM"></a><span class="nroffip">NTLM</span>
|
||||
<p class="level2">NTLM authentication is supported.
|
||||
<p class="level1"><a name="GSS-Negotiate"></a><span class="nroffip">GSS-Negotiate</span>
|
||||
<p class="level2">Negotiate authentication is supported.
|
||||
<p class="level1"><a name="Debug"></a><span class="nroffip">Debug</span>
|
||||
<p class="level2">This curl uses a libcurl built with Debug. This enables more error-tracking and memory debugging etc. For curl-developers only!
|
||||
<p class="level1"><a name="AsynchDNS"></a><span class="nroffip">AsynchDNS</span>
|
||||
<p class="level2">This curl uses asynchronous name resolves.
|
||||
<p class="level1"><a name="SPNEGO"></a><span class="nroffip">SPNEGO</span>
|
||||
<p class="level2">SPNEGO Negotiate authentication is supported.
|
||||
<p class="level1"><a name="Largefile"></a><span class="nroffip">Largefile</span>
|
||||
<p class="level2">This curl supports transfers of large files, files larger than 2GB.
|
||||
<p class="level1"><a name="IDN"></a><span class="nroffip">IDN</span>
|
||||
<p class="level2">This curl supports IDN - international domain names.
|
||||
<p class="level1"><a name="SSPI"></a><span class="nroffip">SSPI</span>
|
||||
<p class="level2">SSPI is supported. If you use NTLM and set a blank user name, curl will authenticate with your current user and password.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="-w--write-out"></a><span class="nroffip">-w/--write-out <format></span>
|
||||
<p class="level1">Defines what to display on stdout after a completed and successful operation. The format is a string that may contain plain text mixed with any number of variables. The string can be specified as "string", to get read from a particular file you specify it "@filename" and to tell curl to read the format from stdin you write "@-".
|
||||
<p class="level1">The variables present in the output format will be substituted by the value or text that curl thinks fit, as described below. All variables are specified like %{variable_name} and to output a normal % you just write them like %%. You can output a newline by using n, a carriage return with r and a tab space with t.
|
||||
<p class="level1"><span Class="bold">NOTE:</span> The %-letter is a special letter in the win32-environment, where all occurrences of % must be doubled when using this option.
|
||||
<p class="level1">Available variables are at this point:
|
||||
<p class="level2">
|
||||
<p class="level2"><span Class="bold">url_effective</span> The URL that was fetched last. This is mostly meaningful if you've told curl to follow location: headers.
|
||||
<p class="level2"><span Class="bold">http_code</span> The numerical code that was found in the last retrieved HTTP(S) page.
|
||||
<p class="level2"><span Class="bold">http_connect</span> The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)
|
||||
<p class="level2"><span Class="bold">time_total</span> The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution.
|
||||
<p class="level2"><span Class="bold">time_namelookup</span> The time, in seconds, it took from the start until the name resolving was completed.
|
||||
<p class="level2"><span Class="bold">time_connect</span> The time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
|
||||
<p class="level2"><span Class="bold">time_pretransfer</span> 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.
|
||||
<p class="level2"><span Class="bold">time_redirect</span> The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)
|
||||
<p class="level2"><span Class="bold">time_starttransfer</span> The time, in seconds, it took from the start until the first byte is just about to be transferred. This includes time_pretransfer and also the time the server needs to calculate the result.
|
||||
<p class="level2"><span Class="bold">size_download</span> The total amount of bytes that were downloaded.
|
||||
<p class="level2"><span Class="bold">size_upload</span> The total amount of bytes that were uploaded.
|
||||
<p class="level2"><span Class="bold">size_header</span> The total amount of bytes of the downloaded headers.
|
||||
<p class="level2"><span Class="bold">size_request</span> The total amount of bytes that were sent in the HTTP request.
|
||||
<p class="level2"><span Class="bold">speed_download</span> The average download speed that curl measured for the complete download.
|
||||
<p class="level2"><span Class="bold">speed_upload</span> The average upload speed that curl measured for the complete upload.
|
||||
<p class="level2"><span Class="bold">content_type</span> The Content-Type of the requested document, if there was any.
|
||||
<p class="level2"><span Class="bold">num_connects</span> Number of new connects made in the recent transfer. (Added in 7.12.3)
|
||||
<p class="level2"><span Class="bold">num_redirects</span> Number of redirects that were followed in the request. (Added in 7.12.3)
|
||||
<p class="level2"><span Class="bold">ftp_entry_path</span> The initial path libcurl ended up in when logging on to the remote FTP server. (Added in 7.15.4)
|
||||
<p class="level1">
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-x--proxy"></a><span class="nroffip">-x/--proxy <proxyhost[:port]></span>
|
||||
<p class="level1">Use specified HTTP proxy. If the port number is not specified, it is assumed at port 1080.
|
||||
<p class="level1">This option overrides existing environment variables that sets proxy to use. If there's an environment variable setting a proxy, you can set proxy to "" to override it.
|
||||
<p class="level1"><span Class="bold">Note</span> that all operations that are performed over a HTTP proxy will transparently be converted to HTTP. It means that certain protocol specific operations might not be available. This is not the case if you can tunnel through the proxy, as done with the <a class="emphasis" href="#-p--proxytunnel">-p/--proxytunnel</a> option.
|
||||
<p class="level1">Starting with 7.14.1, the proxy host can be specified the exact same way as the proxy environment variables, include protocol prefix (http://) and embedded user + password.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-X--request"></a><span class="nroffip">-X/--request <command></span>
|
||||
<p class="level1">(HTTP) Specifies a custom request method to use when communicating with the HTTP server. The specified request will be used instead of the method otherwise used (which defaults to GET). Read the HTTP 1.1 specification for details and explanations.
|
||||
<p class="level1">(FTP) Specifies a custom FTP command to use instead of LIST when doing file lists with ftp.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-y--speed-time"></a><span class="nroffip">-y/--speed-time <time></span>
|
||||
<p class="level1">If a download is slower than speed-limit bytes per second during a speed-time period, the download gets aborted. If speed-time is used, the default speed-limit will be 1 unless set with -y.
|
||||
<p class="level1">This option controls transfers and thus will not affect slow connects etc. If this is a concern for you, try the <a class="emphasis" href="#--connect-timeout">--connect-timeout</a> option.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-Y--speed-limit"></a><span class="nroffip">-Y/--speed-limit <speed></span>
|
||||
<p class="level1">If a download is slower than this given speed, in bytes per second, for speed-time seconds it gets aborted. speed-time is set with -Y and is 30 if not set.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-z--time-cond"></a><span class="nroffip">-z/--time-cond <date expression></span>
|
||||
<p class="level1">(HTTP/FTP) Request a file that has been modified later than the given time and date, or one that has been modified before that time. The date expression can be all sorts of date strings or if it doesn't match any internal ones, it tries to get the time from a given file name instead! See the <span Class="emphasis">curl_getdate(3)</span> man pages for date expression details.
|
||||
<p class="level1">Start the date expression with a dash (-) to make it request for a document that is older than the given date/time, default is a document that is newer than the specified date/time.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="--max-redirs"></a><span class="nroffip">--max-redirs <num></span>
|
||||
<p class="level1">Set maximum number of redirection-followings allowed. If <a class="emphasis" href="#-L--location">-L/--location</a> is used, this option can be used to prevent curl from following redirections "in absurdum". By default, the limit is set to 50 redirections. Set this option to -1 to make it limitless.
|
||||
<p class="level1">If this option is used several times, the last one will be used.
|
||||
<p class="level0"><a name="-0--http10"></a><span class="nroffip">-0/--http1.0</span>
|
||||
<p class="level1">(HTTP) Forces curl to issue its requests using HTTP 1.0 instead of using its internally preferred: HTTP 1.1.
|
||||
<p class="level0"><a name="-1--tlsv1"></a><span class="nroffip">-1/--tlsv1</span>
|
||||
<p class="level1">(SSL) Forces curl to use TSL version 1 when negotiating with a remote TLS server.
|
||||
<p class="level0"><a name="-2--sslv2"></a><span class="nroffip">-2/--sslv2</span>
|
||||
<p class="level1">(SSL) Forces curl to use SSL version 2 when negotiating with a remote SSL server.
|
||||
<p class="level0"><a name="-3--sslv3"></a><span class="nroffip">-3/--sslv3</span>
|
||||
<p class="level1">(SSL) Forces curl to use SSL version 3 when negotiating with a remote SSL server.
|
||||
<p class="level0"><a name="-4--ipv4"></a><span class="nroffip">-4/--ipv4</span>
|
||||
<p class="level1">If libcurl is capable of resolving an address to multiple IP versions (which it is if it is ipv6-capable), this option tells libcurl to resolve names to IPv4 addresses only.
|
||||
<p class="level0"><a name="-6--ipv6"></a><span class="nroffip">-6/--ipv6</span>
|
||||
<p class="level1">If libcurl is capable of resolving an address to multiple IP versions (which it is if it is ipv6-capable), this option tells libcurl to resolve names to IPv6 addresses only.
|
||||
<p class="level0"><a name="---progress-bar"></a><span class="nroffip">-#/--progress-bar</span>
|
||||
<p class="level1">Make curl display progress information as a progress bar instead of the default statistics.
|
||||
<p class="level1">If this option is used twice, the second will again disable the progress bar. <a name="FILES"></a><h2 class="nroffsh">FILES</h2>
|
||||
<p class="level0"><span Class="emphasis">~/.curlrc</span>
|
||||
<p class="level1">Default config file, see <a class="emphasis" href="#-K--config">-K/--config</a> for details.
|
||||
<p class="level1"><a name="ENVIRONMENT"></a><h2 class="nroffsh">ENVIRONMENT</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="httpproxy"></a><span class="nroffip">http_proxy [protocol://]<host>[:port]</span>
|
||||
<p class="level1">Sets proxy server to use for HTTP.
|
||||
<p class="level0"><a name="HTTPSPROXY"></a><span class="nroffip">HTTPS_PROXY [protocol://]<host>[:port]</span>
|
||||
<p class="level1">Sets proxy server to use for HTTPS.
|
||||
<p class="level0"><a name="FTPPROXY"></a><span class="nroffip">FTP_PROXY [protocol://]<host>[:port]</span>
|
||||
<p class="level1">Sets proxy server to use for FTP.
|
||||
<p class="level0"><a name="ALLPROXY"></a><span class="nroffip">ALL_PROXY [protocol://]<host>[:port]</span>
|
||||
<p class="level1">Sets proxy server to use if no protocol-specific proxy is set.
|
||||
<p class="level0"><a name="NOPROXY"></a><span class="nroffip">NO_PROXY <comma-separated list of hosts></span>
|
||||
<p class="level1">list of host names that shouldn't go through any proxy. If set to a asterisk '*' only, it matches all hosts. <a name="EXIT"></a><h2 class="nroffsh">EXIT CODES</h2>
|
||||
<p class="level0">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:
|
||||
<p class="level0"><a name="1"></a><span class="nroffip">1</span>
|
||||
<p class="level1">Unsupported protocol. This build of curl has no support for this protocol.
|
||||
<p class="level0"><a name="2"></a><span class="nroffip">2</span>
|
||||
<p class="level1">Failed to initialize.
|
||||
<p class="level0"><a name="3"></a><span class="nroffip">3</span>
|
||||
<p class="level1">URL malformat. The syntax was not correct.
|
||||
<p class="level0"><a name="4"></a><span class="nroffip">4</span>
|
||||
<p class="level1">URL user malformatted. The user-part of the URL syntax was not correct.
|
||||
<p class="level0"><a name="5"></a><span class="nroffip">5</span>
|
||||
<p class="level1">Couldn't resolve proxy. The given proxy host could not be resolved.
|
||||
<p class="level0"><a name="6"></a><span class="nroffip">6</span>
|
||||
<p class="level1">Couldn't resolve host. The given remote host was not resolved.
|
||||
<p class="level0"><a name="7"></a><span class="nroffip">7</span>
|
||||
<p class="level1">Failed to connect to host.
|
||||
<p class="level0"><a name="8"></a><span class="nroffip">8</span>
|
||||
<p class="level1">FTP weird server reply. The server sent data curl couldn't parse.
|
||||
<p class="level0"><a name="9"></a><span class="nroffip">9</span>
|
||||
<p class="level1">FTP access denied. The server denied login or denied access to the particular resource or directory you wanted to reach. Most often you tried to change to a directory that doesn't exist on the server.
|
||||
<p class="level0"><a name="10"></a><span class="nroffip">10</span>
|
||||
<p class="level1">FTP user/password incorrect. Either one or both were not accepted by the server.
|
||||
<p class="level0"><a name="11"></a><span class="nroffip">11</span>
|
||||
<p class="level1">FTP weird PASS reply. Curl couldn't parse the reply sent to the PASS request.
|
||||
<p class="level0"><a name="12"></a><span class="nroffip">12</span>
|
||||
<p class="level1">FTP weird USER reply. Curl couldn't parse the reply sent to the USER request.
|
||||
<p class="level0"><a name="13"></a><span class="nroffip">13</span>
|
||||
<p class="level1">FTP weird PASV reply, Curl couldn't parse the reply sent to the PASV request.
|
||||
<p class="level0"><a name="14"></a><span class="nroffip">14</span>
|
||||
<p class="level1">FTP weird 227 format. Curl couldn't parse the 227-line the server sent.
|
||||
<p class="level0"><a name="15"></a><span class="nroffip">15</span>
|
||||
<p class="level1">FTP can't get host. Couldn't resolve the host IP we got in the 227-line.
|
||||
<p class="level0"><a name="16"></a><span class="nroffip">16</span>
|
||||
<p class="level1">FTP can't reconnect. Couldn't connect to the host we got in the 227-line.
|
||||
<p class="level0"><a name="17"></a><span class="nroffip">17</span>
|
||||
<p class="level1">FTP couldn't set binary. Couldn't change transfer method to binary.
|
||||
<p class="level0"><a name="18"></a><span class="nroffip">18</span>
|
||||
<p class="level1">Partial file. Only a part of the file was transferred.
|
||||
<p class="level0"><a name="19"></a><span class="nroffip">19</span>
|
||||
<p class="level1">FTP couldn't download/access the given file, the RETR (or similar) command failed.
|
||||
<p class="level0"><a name="20"></a><span class="nroffip">20</span>
|
||||
<p class="level1">FTP write error. The transfer was reported bad by the server.
|
||||
<p class="level0"><a name="21"></a><span class="nroffip">21</span>
|
||||
<p class="level1">FTP quote error. A quote command returned error from the server.
|
||||
<p class="level0"><a name="22"></a><span class="nroffip">22</span>
|
||||
<p class="level1">HTTP page not retrieved. The requested url was not found or returned another error with the HTTP error code being 400 or above. This return code only appears if <a class="emphasis" href="#-f--fail">-f/--fail</a> is used.
|
||||
<p class="level0"><a name="23"></a><span class="nroffip">23</span>
|
||||
<p class="level1">Write error. Curl couldn't write data to a local filesystem or similar.
|
||||
<p class="level0"><a name="24"></a><span class="nroffip">24</span>
|
||||
<p class="level1">Malformed user. User name badly specified.
|
||||
<p class="level0"><a name="25"></a><span class="nroffip">25</span>
|
||||
<p class="level1">FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading.
|
||||
<p class="level0"><a name="26"></a><span class="nroffip">26</span>
|
||||
<p class="level1">Read error. Various reading problems.
|
||||
<p class="level0"><a name="27"></a><span class="nroffip">27</span>
|
||||
<p class="level1">Out of memory. A memory allocation request failed.
|
||||
<p class="level0"><a name="28"></a><span class="nroffip">28</span>
|
||||
<p class="level1">Operation timeout. The specified time-out period was reached according to the conditions.
|
||||
<p class="level0"><a name="29"></a><span class="nroffip">29</span>
|
||||
<p class="level1">FTP couldn't set ASCII. The server returned an unknown reply.
|
||||
<p class="level0"><a name="30"></a><span class="nroffip">30</span>
|
||||
<p class="level1">FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT command, try doing a transfer using PASV instead!
|
||||
<p class="level0"><a name="31"></a><span class="nroffip">31</span>
|
||||
<p class="level1">FTP couldn't use REST. The REST command failed. This command is used for resumed FTP transfers.
|
||||
<p class="level0"><a name="32"></a><span class="nroffip">32</span>
|
||||
<p class="level1">FTP couldn't use SIZE. The SIZE command failed. The command is an extension to the original FTP spec RFC 959.
|
||||
<p class="level0"><a name="33"></a><span class="nroffip">33</span>
|
||||
<p class="level1">HTTP range error. The range "command" didn't work.
|
||||
<p class="level0"><a name="34"></a><span class="nroffip">34</span>
|
||||
<p class="level1">HTTP post error. Internal post-request generation error.
|
||||
<p class="level0"><a name="35"></a><span class="nroffip">35</span>
|
||||
<p class="level1">SSL connect error. The SSL handshaking failed.
|
||||
<p class="level0"><a name="36"></a><span class="nroffip">36</span>
|
||||
<p class="level1">FTP bad download resume. Couldn't continue an earlier aborted download.
|
||||
<p class="level0"><a name="37"></a><span class="nroffip">37</span>
|
||||
<p class="level1">FILE couldn't read file. Failed to open the file. Permissions?
|
||||
<p class="level0"><a name="38"></a><span class="nroffip">38</span>
|
||||
<p class="level1">LDAP cannot bind. LDAP bind operation failed.
|
||||
<p class="level0"><a name="39"></a><span class="nroffip">39</span>
|
||||
<p class="level1">LDAP search failed.
|
||||
<p class="level0"><a name="40"></a><span class="nroffip">40</span>
|
||||
<p class="level1">Library not found. The LDAP library was not found.
|
||||
<p class="level0"><a name="41"></a><span class="nroffip">41</span>
|
||||
<p class="level1">Function not found. A required LDAP function was not found.
|
||||
<p class="level0"><a name="42"></a><span class="nroffip">42</span>
|
||||
<p class="level1">Aborted by callback. An application told curl to abort the operation.
|
||||
<p class="level0"><a name="43"></a><span class="nroffip">43</span>
|
||||
<p class="level1">Internal error. A function was called with a bad parameter.
|
||||
<p class="level0"><a name="44"></a><span class="nroffip">44</span>
|
||||
<p class="level1">Internal error. A function was called in a bad order.
|
||||
<p class="level0"><a name="45"></a><span class="nroffip">45</span>
|
||||
<p class="level1">Interface error. A specified outgoing interface could not be used.
|
||||
<p class="level0"><a name="46"></a><span class="nroffip">46</span>
|
||||
<p class="level1">Bad password entered. An error was signaled when the password was entered.
|
||||
<p class="level0"><a name="47"></a><span class="nroffip">47</span>
|
||||
<p class="level1">Too many redirects. When following redirects, curl hit the maximum amount.
|
||||
<p class="level0"><a name="48"></a><span class="nroffip">48</span>
|
||||
<p class="level1">Unknown TELNET option specified.
|
||||
<p class="level0"><a name="49"></a><span class="nroffip">49</span>
|
||||
<p class="level1">Malformed telnet option.
|
||||
<p class="level0"><a name="51"></a><span class="nroffip">51</span>
|
||||
<p class="level1">The remote peer's SSL certificate wasn't ok
|
||||
<p class="level0"><a name="52"></a><span class="nroffip">52</span>
|
||||
<p class="level1">The server didn't reply anything, which here is considered an error.
|
||||
<p class="level0"><a name="53"></a><span class="nroffip">53</span>
|
||||
<p class="level1">SSL crypto engine not found
|
||||
<p class="level0"><a name="54"></a><span class="nroffip">54</span>
|
||||
<p class="level1">Cannot set SSL crypto engine as default
|
||||
<p class="level0"><a name="55"></a><span class="nroffip">55</span>
|
||||
<p class="level1">Failed sending network data
|
||||
<p class="level0"><a name="56"></a><span class="nroffip">56</span>
|
||||
<p class="level1">Failure in receiving network data
|
||||
<p class="level0"><a name="57"></a><span class="nroffip">57</span>
|
||||
<p class="level1">Share is in use (internal error)
|
||||
<p class="level0"><a name="58"></a><span class="nroffip">58</span>
|
||||
<p class="level1">Problem with the local certificate
|
||||
<p class="level0"><a name="59"></a><span class="nroffip">59</span>
|
||||
<p class="level1">Couldn't use specified SSL cipher
|
||||
<p class="level0"><a name="60"></a><span class="nroffip">60</span>
|
||||
<p class="level1">Problem with the CA cert (path? permission?)
|
||||
<p class="level0"><a name="61"></a><span class="nroffip">61</span>
|
||||
<p class="level1">Unrecognized transfer encoding
|
||||
<p class="level0"><a name="62"></a><span class="nroffip">62</span>
|
||||
<p class="level1">Invalid LDAP URL
|
||||
<p class="level0"><a name="63"></a><span class="nroffip">63</span>
|
||||
<p class="level1">Maximum file size exceeded
|
||||
<p class="level0"><a name="64"></a><span class="nroffip">64</span>
|
||||
<p class="level1">Requested FTP SSL level failed
|
||||
<p class="level0"><a name="65"></a><span class="nroffip">65</span>
|
||||
<p class="level1">Sending the data requires a rewind that failed
|
||||
<p class="level0"><a name="66"></a><span class="nroffip">66</span>
|
||||
<p class="level1">Failed to initialise SSL Engine
|
||||
<p class="level0"><a name="67"></a><span class="nroffip">67</span>
|
||||
<p class="level1">User, password or similar was not accepted and curl failed to login
|
||||
<p class="level0"><a name="68"></a><span class="nroffip">68</span>
|
||||
<p class="level1">File not found on TFTP server
|
||||
<p class="level0"><a name="69"></a><span class="nroffip">69</span>
|
||||
<p class="level1">Permission problem on TFTP server
|
||||
<p class="level0"><a name="70"></a><span class="nroffip">70</span>
|
||||
<p class="level1">Out of disk space on TFTP server
|
||||
<p class="level0"><a name="71"></a><span class="nroffip">71</span>
|
||||
<p class="level1">Illegal TFTP operation
|
||||
<p class="level0"><a name="72"></a><span class="nroffip">72</span>
|
||||
<p class="level1">Unknown TFTP transfer ID
|
||||
<p class="level0"><a name="73"></a><span class="nroffip">73</span>
|
||||
<p class="level1">File already exists (TFTP)
|
||||
<p class="level0"><a name="74"></a><span class="nroffip">74</span>
|
||||
<p class="level1">No such user (TFTP)
|
||||
<p class="level0"><a name="75"></a><span class="nroffip">75</span>
|
||||
<p class="level1">Character conversion failed
|
||||
<p class="level0"><a name="76"></a><span class="nroffip">76</span>
|
||||
<p class="level1">Character conversion functions required
|
||||
<p class="level0"><a name="XX"></a><span class="nroffip">XX</span>
|
||||
<p class="level1">There will appear more error codes here in future releases. The existing ones are meant to never change. <a name="AUTHORS"></a><h2 class="nroffsh">AUTHORS / CONTRIBUTORS</h2>
|
||||
<p class="level0">Daniel Stenberg is the main author, but the whole list of contributors is found in the separate THANKS file. <a name="WWW"></a><h2 class="nroffsh">WWW</h2>
|
||||
<p class="level0"><a href="http://curl.haxx.se">http://curl.haxx.se</a> <a name="FTP"></a><h2 class="nroffsh">FTP</h2>
|
||||
<p class="level0"><a href="ftp://ftp.sunet.se/pub/www/utilities/curl/">ftp://ftp.sunet.se/pub/www/utilities/curl/</a> <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><span Class="manpage">ftp (1)</span> <span Class="manpage">wget (1)</span>
|
||||
<p class="level0"><p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,166 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: 10-at-a-time.c,v 1.2 2006-10-13 14:01:19 bagder Exp $
|
||||
*
|
||||
* Example application source code using the multi interface to download many
|
||||
* files, but with a capped maximum amount of simultaneous transfers.
|
||||
*
|
||||
* Written by Michael Wallner
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curl/multi.h>
|
||||
|
||||
static const char *urls[] = {
|
||||
"http://www.microsoft.com",
|
||||
"http://www.opensource.org",
|
||||
"http://www.google.com",
|
||||
"http://www.yahoo.com",
|
||||
"http://www.ibm.com",
|
||||
"http://www.mysql.com",
|
||||
"http://www.oracle.com",
|
||||
"http://www.ripe.net",
|
||||
"http://www.iana.org",
|
||||
"http://www.amazon.com",
|
||||
"http://www.netcraft.com",
|
||||
"http://www.heise.de",
|
||||
"http://www.chip.de",
|
||||
"http://www.ca.com",
|
||||
"http://www.cnet.com",
|
||||
"http://www.news.com",
|
||||
"http://www.cnn.com",
|
||||
"http://www.wikipedia.org",
|
||||
"http://www.dell.com",
|
||||
"http://www.hp.com",
|
||||
"http://www.cert.org",
|
||||
"http://www.mit.edu",
|
||||
"http://www.nist.gov",
|
||||
"http://www.ebay.com",
|
||||
"http://www.playstation.com",
|
||||
"http://www.uefa.com",
|
||||
"http://www.ieee.org",
|
||||
"http://www.apple.com",
|
||||
"http://www.sony.com",
|
||||
"http://www.symantec.com",
|
||||
"http://www.zdnet.com",
|
||||
"http://www.fujitsu.com",
|
||||
"http://www.supermicro.com",
|
||||
"http://www.hotmail.com",
|
||||
"http://www.ecma.com",
|
||||
"http://www.bbc.co.uk",
|
||||
"http://news.google.com",
|
||||
"http://www.foxnews.com",
|
||||
"http://www.msn.com",
|
||||
"http://www.wired.com",
|
||||
"http://www.sky.com",
|
||||
"http://www.usatoday.com",
|
||||
"http://www.cbs.com",
|
||||
"http://www.nbc.com",
|
||||
"http://slashdot.org",
|
||||
"http://www.bloglines.com",
|
||||
"http://www.techweb.com",
|
||||
"http://www.newslink.org",
|
||||
"http://www.un.org",
|
||||
};
|
||||
|
||||
#define MAX 10 /* number of simultaneous transfers */
|
||||
#define CNT sizeof(urls)/sizeof(char*) /* total number of transfers to do */
|
||||
|
||||
static int cb(char *d, size_t n, size_t l, void *p)
|
||||
{
|
||||
/* take care of the data here, ignored in this example */
|
||||
(void)d;
|
||||
(void)p;
|
||||
return n*l;
|
||||
}
|
||||
|
||||
static void init(CURLM *cm, int i)
|
||||
{
|
||||
CURL *eh = curl_easy_init();
|
||||
|
||||
curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, cb);
|
||||
curl_easy_setopt(eh, CURLOPT_HEADER, 0);
|
||||
curl_easy_setopt(eh, CURLOPT_URL, urls[i]);
|
||||
curl_easy_setopt(eh, CURLOPT_PRIVATE, urls[i]);
|
||||
curl_easy_setopt(eh, CURLOPT_VERBOSE, 0);
|
||||
|
||||
curl_multi_add_handle(cm, eh);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURLM *cm;
|
||||
CURLMsg *msg;
|
||||
long L;
|
||||
unsigned int C=0;
|
||||
int M, Q, U = -1;
|
||||
fd_set R, W, E;
|
||||
struct timeval T;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
cm = curl_multi_init();
|
||||
|
||||
for (C = 0; C < MAX; ++C) {
|
||||
init(cm, C);
|
||||
}
|
||||
|
||||
while (U) {
|
||||
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U));
|
||||
|
||||
if (U) {
|
||||
FD_ZERO(&R);
|
||||
FD_ZERO(&W);
|
||||
FD_ZERO(&E);
|
||||
|
||||
if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
|
||||
fprintf(stderr, "E: curl_multi_fdset\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* In a real-world program you OF COURSE check the return that maxfd is
|
||||
bigger than -1 so that the call to select() below makes sense! */
|
||||
|
||||
if (curl_multi_timeout(cm, &L)) {
|
||||
fprintf(stderr, "E: curl_multi_timeout\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
T.tv_sec = L/1000;
|
||||
T.tv_usec = (L%1000)*1000;
|
||||
|
||||
if (0 > select(M+1, &R, &W, &E, &T)) {
|
||||
fprintf(stderr, "E: select\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
while ((msg = curl_multi_info_read(cm, &Q))) {
|
||||
if (msg->msg == CURLMSG_DONE) {
|
||||
char *url;
|
||||
CURL *e = msg->easy_handle;
|
||||
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url);
|
||||
fprintf(stderr, "R: %d - %s <%s>\n",
|
||||
msg->data.result, curl_easy_strerror(msg->data.result), url);
|
||||
curl_multi_remove_handle(cm, e);
|
||||
curl_easy_cleanup(e);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg);
|
||||
}
|
||||
if (C < CNT) {
|
||||
init(cm, C++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(cm);
|
||||
curl_global_cleanup();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#
|
||||
# $Id: Makefile.am,v 1.42 2006-10-10 19:46:57 bagder Exp $
|
||||
#
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
EXTRA_DIST = README curlgtk.c sepheaders.c simple.c postit2.c \
|
||||
persistant.c ftpget.c Makefile.example multithread.c getinmemory.c \
|
||||
ftpupload.c httpput.c simplessl.c ftpgetresp.c http-post.c \
|
||||
post-callback.c multi-app.c multi-double.c multi-single.c \
|
||||
multi-post.c fopen.c simplepost.c makefile.dj curlx.c https.c \
|
||||
multi-debugcallback.c fileupload.c getinfo.c ftp3rdparty.c debug.c \
|
||||
anyauthput.c htmltitle.cc htmltidy.c opensslthreadlock.c \
|
||||
cookie_interface.c cacertinmem.c synctime.c sampleconv.c ftpuploadresume.c \
|
||||
10-at-a-time.c hiperfifo.c ghiper.c
|
||||
|
||||
all:
|
||||
@echo "done"
|
|
@ -1,42 +0,0 @@
|
|||
#############################################################################
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# $Id: Makefile.example,v 1.3 2002/08/14 23:01:14 bagder Exp $
|
||||
#
|
||||
|
||||
# What to call the final executable
|
||||
TARGET = example
|
||||
|
||||
# Which object files that the executable consists of
|
||||
OBJS= ftpget.o
|
||||
|
||||
# What compiler to use
|
||||
CC = gcc
|
||||
|
||||
# Compiler flags, -g for debug, -c to make an object file
|
||||
CFLAGS = -c -g
|
||||
|
||||
# This should point to a directory that holds libcurl, if it isn't
|
||||
# in the system's standard lib dir
|
||||
# We also set a -L to include the directory where we have the openssl
|
||||
# libraries
|
||||
LDFLAGS = -L/home/dast/lib -L/usr/local/ssl/lib
|
||||
|
||||
# We need -lcurl for the curl stuff
|
||||
# We need -lsocket and -lnsl when on Solaris
|
||||
# We need -lssl and -lcrypto when using libcurl with SSL support
|
||||
# We need -ldl for dlopen() if that is in libdl
|
||||
# We need -lpthread for the pthread example
|
||||
LIBS = -lcurl -lsocket -lnsl -lssl -lcrypto -dl
|
||||
|
||||
# Link the target with all objects and libraries
|
||||
$(TARGET) : $(OBJS)
|
||||
$(CC) -o $(TARGET) $(OBJS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
# Compile the source files into object files
|
||||
ftpget.o : ftpget.c
|
||||
$(CC) $(CFLAGS) $<
|
|
@ -1,76 +0,0 @@
|
|||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
| (__| |_| | _ <| |___
|
||||
\___|\___/|_| \_\_____|
|
||||
|
||||
This directory is for libcurl programming examples. They are meant to show
|
||||
some simple steps on how you can build your own application to take full
|
||||
advantage of libcurl.
|
||||
|
||||
If you end up with other small but still useful example sources, please mail
|
||||
them for submission in future packages and on the web site.
|
||||
|
||||
BUILDING
|
||||
|
||||
The Makefile.example is an example makefile that could be used to build these
|
||||
examples. Just edit the file according to your system and requirements first.
|
||||
|
||||
Most examples should build fine using a command line like this:
|
||||
|
||||
$ `curl-config --cc --cflags --libs` -o example example.c
|
||||
|
||||
Some compilers don't like having the arguments in this order but instead
|
||||
want you do reorganize them like:
|
||||
|
||||
$ `curl-config --cc` -o example example.c `curl-config --cflags --libs`
|
||||
|
||||
*PLEASE* do not use the curl.haxx.se site as a test target for your libcurl
|
||||
applications/experiments. Even if some of the examples use that site as a URL
|
||||
at some places, it doesn't mean that the URLs work or that we expect you to
|
||||
actually torture our web site with your tests! Thanks.
|
||||
|
||||
EXAMPLES
|
||||
|
||||
anyauthput.c - HTTP PUT using "any" authentication method
|
||||
cacertinmem.c - Use a built-in PEM certificate to retrieve a https page
|
||||
cookie_interface.c - shows usage of simple cookie interface
|
||||
curlgtk.c - download using a GTK progress bar
|
||||
curlx.c - getting file info from the remote cert data
|
||||
debug.c - showing how to use the debug callback
|
||||
fileupload.c - uploading to a file:// URL
|
||||
fopen.c - fopen() layer that supports opening URLs and files
|
||||
ftp3rdparty.c - FTP 3rd party transfer
|
||||
ftpget.c - simple getting a file from FTP
|
||||
ftpgetresp.c - get the response strings from the FTP server
|
||||
ftpupload.c - upload a file to an FTP server
|
||||
ftpuploadresume.c - resume an upload to an FTP server
|
||||
getinfo.c - get the Content-Type from the recent transfer
|
||||
getinmemory.c - download a file to memory only
|
||||
ghiper.c - curl_multi_socket() using code with glib-2
|
||||
hiperfifo.c - downloads all URLs written to the fifo, using
|
||||
curl_multi_socket() and libevent
|
||||
htmltitle.cc - download a HTML file and extract the <title> tag from a HTML
|
||||
page using libxml
|
||||
http-post.c - HTTP POST
|
||||
httpput.c - HTTP PUT a local file
|
||||
https.c - simple HTTPS transfer
|
||||
multi-app.c - a multi-interface app
|
||||
multi-debugcallback.c - a multi-interface app using the debug callback
|
||||
multi-double.c - a multi-interface app doing two simultaneous transfers
|
||||
multi-post.c - a multi-interface app doing a multipart formpost
|
||||
multi-single.c - a multi-interface app getting a single file
|
||||
multithread.c - an example using multi-treading transfering multiple files
|
||||
opensslthreadlock.c - show how to do locking when using OpenSSL multi-threaded
|
||||
persistant.c - request two URLs with a persistant connection
|
||||
post-callback.c - send a HTTP POST using a callback
|
||||
postit2.c - send a HTTP multipart formpost
|
||||
sampleconv.c - showing how a program on a non-ASCII platform would invoke
|
||||
callbacks to do its own codeset conversions instead of using
|
||||
the built-in iconv functions in libcurl
|
||||
sepheaders.c - download headers to a separate file
|
||||
simple.c - the most simple download a URL source
|
||||
simplepost.c - HTTP POST
|
||||
simplessl.c - HTTPS example with certificates many options set
|
||||
synctime.c - Sync local time by extracing date from remote HTTP servers
|
||||
10-at-a-time.c - Download many files simultaneously, 10 at a time.
|
|
@ -1,135 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: anyauthput.c,v 1.1 2004/11/24 16:11:35 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x070c03
|
||||
#error "upgrade your libcurl to no less than 7.12.3"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This example shows a HTTP PUT operation with authentiction using "any"
|
||||
* type. It PUTs a file given as a command line argument to the URL also given
|
||||
* on the command line.
|
||||
*
|
||||
* Since libcurl 7.12.3, using "any" auth and POST/PUT requires a set ioctl
|
||||
* function.
|
||||
*
|
||||
* This example also uses its own read callback.
|
||||
*/
|
||||
|
||||
/* ioctl callback function */
|
||||
static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
|
||||
{
|
||||
int fd = (int)userp;
|
||||
|
||||
(void)handle; /* not used in here */
|
||||
|
||||
switch(cmd) {
|
||||
case CURLIOCMD_RESTARTREAD:
|
||||
/* mr libcurl kindly asks as to rewind the read data stream to start */
|
||||
if(-1 == lseek(fd, 0, SEEK_SET))
|
||||
/* couldn't rewind */
|
||||
return CURLIOE_FAILRESTART;
|
||||
|
||||
break;
|
||||
|
||||
default: /* ignore unknown commands */
|
||||
return CURLIOE_UNKNOWNCMD;
|
||||
}
|
||||
return CURLIOE_OK; /* success! */
|
||||
}
|
||||
|
||||
/* read callback function, fread() look alike */
|
||||
size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
size_t retcode;
|
||||
|
||||
int fd = (int)stream;
|
||||
|
||||
retcode = read(fd, ptr, size * nmemb);
|
||||
|
||||
fprintf(stderr, "*** We read %d bytes from file\n", retcode);
|
||||
|
||||
return retcode;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
int hd ;
|
||||
struct stat file_info;
|
||||
|
||||
char *file;
|
||||
char *url;
|
||||
|
||||
if(argc < 3)
|
||||
return 1;
|
||||
|
||||
file= argv[1];
|
||||
url = argv[2];
|
||||
|
||||
/* get the file size of the local file */
|
||||
hd = open(file, O_RDONLY) ;
|
||||
fstat(hd, &file_info);
|
||||
|
||||
/* In windows, this will init the winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, hd);
|
||||
|
||||
/* set the ioctl function */
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl);
|
||||
|
||||
/* pass the file descriptor to the ioctl callback as well */
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, hd);
|
||||
|
||||
/* enable "uploading" (which means PUT when doing HTTP) */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
||||
|
||||
/* specify target URL, and note that this URL should also include a file
|
||||
name, not only a directory (as you can do with GTP uploads) */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, url);
|
||||
|
||||
/* and give the size of the upload, this supports large file sizes
|
||||
on systems that have general support for it */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_info.st_size);
|
||||
|
||||
/* tell libcurl we can use "any" auth, which lets the lib pick one, but it
|
||||
also costs one extra round-trip and possibly sending of all the PUT
|
||||
data twice!!! */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||
|
||||
/* set user name and password for the authentication */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
close(hd); /* close the local file */
|
||||
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: cacertinmem.c,v 1.1 2005/08/24 17:07:27 bagder Exp $
|
||||
*
|
||||
* Example using a "in core" PEM certificate to retrieve a https page.
|
||||
* Written by Theo Borm
|
||||
*/
|
||||
|
||||
/* on a netBSD system with OPENSSL& LIBCURL installed from
|
||||
* pkgsrc (using default paths) this program can be compiled using:
|
||||
* gcc -I/usr/pkg/include -L/usr/pkg/lib -lcurl -Wl,-R/usr/pkg/lib -lssl
|
||||
* -lcrypto -lz -o curlcacerttest curlcacerttest.c
|
||||
* on other operating systems you may want to change paths to headers
|
||||
* and libraries
|
||||
*/
|
||||
#include <openssl/ssl.h>
|
||||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
size_t writefunction( void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
fwrite(ptr,size,nmemb,stream);
|
||||
return(nmemb*size);
|
||||
}
|
||||
|
||||
static CURLcode sslctx_function(CURL * curl, void * sslctx, void * parm)
|
||||
{
|
||||
X509_STORE * store;
|
||||
X509 * cert=NULL;
|
||||
BIO * bio;
|
||||
char * mypem = /* www.cacert.org */
|
||||
"-----BEGIN CERTIFICATE-----\n"\
|
||||
"MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\n"\
|
||||
"IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\n"\
|
||||
"IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\n"\
|
||||
"Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\n"\
|
||||
"BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi\n"\
|
||||
"MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ\n"\
|
||||
"ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC\n"\
|
||||
"CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ\n"\
|
||||
"8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6\n"\
|
||||
"zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y\n"\
|
||||
"fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7\n"\
|
||||
"w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc\n"\
|
||||
"G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k\n"\
|
||||
"epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q\n"\
|
||||
"laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ\n"\
|
||||
"QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU\n"\
|
||||
"fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826\n"\
|
||||
"YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w\n"\
|
||||
"ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY\n"\
|
||||
"gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe\n"\
|
||||
"MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0\n"\
|
||||
"IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy\n"\
|
||||
"dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw\n"\
|
||||
"czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0\n"\
|
||||
"dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl\n"\
|
||||
"aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC\n"\
|
||||
"AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg\n"\
|
||||
"b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB\n"\
|
||||
"ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc\n"\
|
||||
"nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg\n"\
|
||||
"18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c\n"\
|
||||
"gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl\n"\
|
||||
"Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY\n"\
|
||||
"sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T\n"\
|
||||
"SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF\n"\
|
||||
"CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum\n"\
|
||||
"GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\n"\
|
||||
"zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\n"\
|
||||
"omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n"\
|
||||
"-----END CERTIFICATE-----\n";
|
||||
/* get a BIO */
|
||||
bio=BIO_new_mem_buf(mypem, -1);
|
||||
/* use it to read the PEM formatted certificate from memory into an X509
|
||||
* structure that SSL can use
|
||||
*/
|
||||
PEM_read_bio_X509(bio, &cert, 0, NULL);
|
||||
if (cert == NULL)
|
||||
printf("PEM_read_bio_X509 failed...\n");
|
||||
|
||||
/* get a pointer to the X509 certificate store (which may be empty!) */
|
||||
store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
|
||||
|
||||
/* add our certificate to this store */
|
||||
if (X509_STORE_add_cert(store, cert)==0)
|
||||
printf("error adding certificate\n");
|
||||
|
||||
/* all set to go */
|
||||
return CURLE_OK ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL * ch;
|
||||
CURLcode rv;
|
||||
|
||||
rv=curl_global_init(CURL_GLOBAL_ALL);
|
||||
ch=curl_easy_init();
|
||||
rv=curl_easy_setopt(ch,CURLOPT_VERBOSE, 0);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_HEADER, 0);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_NOPROGRESS, 1);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_NOSIGNAL, 1);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_WRITEFUNCTION, *writefunction);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_WRITEDATA, stdout);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_HEADERFUNCTION, *writefunction);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_WRITEHEADER, stderr);
|
||||
rv=curl_easy_setopt(ch,CURLOPT_SSLCERTTYPE,"PEM");
|
||||
rv=curl_easy_setopt(ch,CURLOPT_SSL_VERIFYPEER,1);
|
||||
rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.cacert.org/");
|
||||
|
||||
/* first try: retrieve page without cacerts' certificate -> will fail
|
||||
*/
|
||||
rv=curl_easy_perform(ch);
|
||||
if (rv==CURLE_OK)
|
||||
printf("*** transfer succeeded ***\n");
|
||||
else
|
||||
printf("*** transfer failed ***\n");
|
||||
|
||||
/* second try: retrieve page using cacerts' certificate -> will succeed
|
||||
* load the certificate by installing a function doing the nescessary
|
||||
* "modifications" to the SSL CONTEXT just before link init
|
||||
*/
|
||||
rv=curl_easy_setopt(ch,CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
|
||||
rv=curl_easy_perform(ch);
|
||||
if (rv==CURLE_OK)
|
||||
printf("*** transfer succeeded ***\n");
|
||||
else
|
||||
printf("*** transfer failed ***\n");
|
||||
|
||||
curl_easy_cleanup(ch);
|
||||
curl_global_cleanup();
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* This example shows usage of simple cookie interface.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
static void
|
||||
print_cookies(CURL *curl)
|
||||
{
|
||||
CURLcode res;
|
||||
struct curl_slist *cookies;
|
||||
struct curl_slist *nc;
|
||||
int i;
|
||||
|
||||
printf("Cookies, curl knows:\n");
|
||||
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
|
||||
if (res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl curl_easy_getinfo failed: %s\n", curl_easy_strerror(res));
|
||||
exit(1);
|
||||
}
|
||||
nc = cookies, i = 1;
|
||||
while (nc) {
|
||||
printf("[%d]: %s\n", i, nc->data);
|
||||
nc = nc->next;
|
||||
i++;
|
||||
}
|
||||
if (i == 1) {
|
||||
printf("(none)\n");
|
||||
}
|
||||
curl_slist_free_all(cookies);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
char nline[256];
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com/"); /* google.com sets "PREF" cookie */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* just to start the cookie engine */
|
||||
res = curl_easy_perform(curl);
|
||||
if (res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_cookies(curl);
|
||||
|
||||
printf("Erasing curl's knowledge of cookies!\n");
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIELIST, "ALL");
|
||||
|
||||
print_cookies(curl);
|
||||
|
||||
printf("-----------------------------------------------\n"
|
||||
"Setting a cookie \"PREF\" via cookie interface:\n");
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
/* Netscape format cookie */
|
||||
snprintf(nline, 256, "%s\t%s\t%s\t%s\t%u\t%s\t%s",
|
||||
".google.com", "TRUE", "/", "FALSE", time(NULL) + 31337, "PREF", "hello google, i like you very much!");
|
||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||
if (res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* HTTP-header style cookie */
|
||||
snprintf(nline, 256,
|
||||
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
|
||||
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
|
||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||
if (res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", curl_easy_strerror(res));
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_cookies(curl);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if (res != CURLE_OK) {
|
||||
fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Curl init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: curlgtk.c,v 1.5 2004/11/22 13:43:52 bagder Exp $
|
||||
*/
|
||||
/* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
|
||||
/* an attempt to use the curl library in concert with a gtk-threaded application */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h> /* new for v7 */
|
||||
#include <curl/easy.h> /* new for v7 */
|
||||
|
||||
GtkWidget *Bar;
|
||||
|
||||
size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
return fwrite(ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
return fread(ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
int my_progress_func(GtkWidget *Bar,
|
||||
double t, /* dltotal */
|
||||
double d, /* dlnow */
|
||||
double ultotal,
|
||||
double ulnow)
|
||||
{
|
||||
/* printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/
|
||||
gdk_threads_enter();
|
||||
gtk_progress_set_value(GTK_PROGRESS(Bar), d*100.0/t);
|
||||
gdk_threads_leave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *my_thread(void *ptr)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *outfile;
|
||||
gchar *url = ptr;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl)
|
||||
{
|
||||
outfile = fopen("test.curl", "w");
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
fclose(outfile);
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GtkWidget *Window, *Frame, *Frame2;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
/* Init thread */
|
||||
g_thread_init(NULL);
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
Frame = gtk_frame_new(NULL);
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add(GTK_CONTAINER(Window), Frame);
|
||||
Frame2 = gtk_frame_new(NULL);
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN);
|
||||
gtk_container_add(GTK_CONTAINER(Frame), Frame2);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5);
|
||||
adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
|
||||
Bar = gtk_progress_bar_new_with_adjustment(adj);
|
||||
gtk_container_add(GTK_CONTAINER(Frame2), Bar);
|
||||
gtk_widget_show_all(Window);
|
||||
|
||||
if (!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0)
|
||||
g_warning("can't create the thread");
|
||||
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,513 +0,0 @@
|
|||
/*
|
||||
curlx.c Authors: Peter Sylvester, Jean-Paul Merlin
|
||||
|
||||
This is a little program to demonstrate the usage of
|
||||
|
||||
- an ssl initialisation callback setting a user key and trustbases
|
||||
coming from a pkcs12 file
|
||||
- using an ssl application callback to find a URI in the
|
||||
certificate presented during ssl session establishment.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The OpenEvidence Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, the following disclaimer,
|
||||
* and the original OpenSSL and SSLeay Licences below.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions, the following disclaimer
|
||||
* and the original OpenSSL and SSLeay Licences below in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgments:
|
||||
* "This product includes software developed by the Openevidence Project
|
||||
* for use in the OpenEvidence Toolkit. (http://www.openevidence.org/)"
|
||||
* This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com)."
|
||||
*
|
||||
* 4. The names "OpenEvidence Toolkit" and "OpenEvidence Project" must not be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openevidence-core@openevidence.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenEvidence"
|
||||
* nor may "OpenEvidence" appear in their names without prior written
|
||||
* permission of the OpenEvidence Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgments:
|
||||
* "This product includes software developed by the OpenEvidence Project
|
||||
* for use in the OpenEvidence Toolkit (http://www.openevidence.org/)
|
||||
* This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com)."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenEvidence PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenEvidence PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <curl/curl.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/x509_vfy.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
static char *curlx_usage[]={
|
||||
"usage: curlx args\n",
|
||||
" -p12 arg - tia file ",
|
||||
" -envpass arg - environement variable which content the tia private key password",
|
||||
" -out arg - output file (response)- default stdout",
|
||||
" -in arg - input file (request)- default stdin",
|
||||
" -connect arg - URL of the server for the connection ex: www.openevidenve.org",
|
||||
" -mimetype arg - MIME type for data in ex : application/timestamp-query or application/dvcs -default application/timestamp-query",
|
||||
" -acceptmime arg - MIME type acceptable for the response ex : application/timestamp-response or application/dvcs -default none",
|
||||
" -accesstype arg - an Object identifier in an AIA/SIA method, e.g. AD_DVCS or ad_timestamping",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
./curlx -p12 psy.p12 -envpass XX -in request -verbose -accesstype AD_DVCS
|
||||
-mimetype application/dvcs -acceptmime application/dvcs -out response
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* We use this ZERO_NULL to avoid picky compiler warnings,
|
||||
* when assigning a NULL pointer to a function pointer var.
|
||||
*/
|
||||
|
||||
#define ZERO_NULL 0
|
||||
|
||||
/* This is a context that we pass to all callbacks */
|
||||
|
||||
typedef struct sslctxparm_st {
|
||||
unsigned char * p12file ;
|
||||
const char * pst ;
|
||||
PKCS12 * p12 ;
|
||||
EVP_PKEY * pkey ;
|
||||
X509 * usercert ;
|
||||
STACK_OF(X509) * ca ;
|
||||
CURL * curl;
|
||||
BIO * errorbio;
|
||||
int accesstype ;
|
||||
int verbose;
|
||||
|
||||
} sslctxparm;
|
||||
|
||||
/* some helper function. */
|
||||
|
||||
static char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5)
|
||||
{
|
||||
char *tmp;
|
||||
if(!ia5 || !ia5->length)
|
||||
return NULL;
|
||||
tmp = OPENSSL_malloc(ia5->length + 1);
|
||||
memcpy(tmp, ia5->data, ia5->length);
|
||||
tmp[ia5->length] = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* A conveniance routine to get an access URI. */
|
||||
|
||||
static unsigned char *my_get_ext(X509 * cert, const int type, int extensiontype) {
|
||||
|
||||
int i;
|
||||
STACK_OF(ACCESS_DESCRIPTION) * accessinfo ;
|
||||
accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL) ;
|
||||
|
||||
if (!sk_ACCESS_DESCRIPTION_num(accessinfo))
|
||||
return NULL;
|
||||
for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) {
|
||||
ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i);
|
||||
if (OBJ_obj2nid(ad->method) == type) {
|
||||
if (ad->location->type == GEN_URI) {
|
||||
return i2s_ASN1_IA5STRING(ad->location->d.ia5);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is an application verification call back, it does not
|
||||
perform any addition verification but tries to find a URL
|
||||
in the presented certificat. If found, this will become
|
||||
the URL to be used in the POST.
|
||||
*/
|
||||
|
||||
static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
|
||||
{
|
||||
sslctxparm * p = (sslctxparm *) arg;
|
||||
int ok;
|
||||
|
||||
if (p->verbose > 2)
|
||||
BIO_printf(p->errorbio,"entering ssl_app_verify_callback\n");
|
||||
|
||||
if ((ok= X509_verify_cert(ctx)) && ctx->cert) {
|
||||
unsigned char * accessinfo ;
|
||||
if (p->verbose > 1)
|
||||
X509_print_ex(p->errorbio,ctx->cert,0,0);
|
||||
|
||||
if (accessinfo = my_get_ext(ctx->cert,p->accesstype ,NID_sinfo_access)) {
|
||||
if (p->verbose)
|
||||
BIO_printf(p->errorbio,"Setting URL from SIA to: %s\n", accessinfo);
|
||||
|
||||
curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
|
||||
}
|
||||
else if (accessinfo = my_get_ext(ctx->cert,p->accesstype,
|
||||
NID_info_access)) {
|
||||
if (p->verbose)
|
||||
BIO_printf(p->errorbio,"Setting URL from AIA to: %s\n", accessinfo);
|
||||
|
||||
curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
|
||||
}
|
||||
}
|
||||
if (p->verbose > 2)
|
||||
BIO_printf(p->errorbio,"leaving ssl_app_verify_callback with %d\n", ok);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
|
||||
/* This is an example of an curl SSL initialisation call back. The callback sets:
|
||||
- a private key and certificate
|
||||
- a trusted ca certificate
|
||||
- a preferred cipherlist
|
||||
- an application verification callback (the function above)
|
||||
*/
|
||||
|
||||
static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) {
|
||||
|
||||
sslctxparm * p = (sslctxparm *) parm;
|
||||
SSL_CTX * ctx = (SSL_CTX *) sslctx ;
|
||||
|
||||
if (!SSL_CTX_use_certificate(ctx,p->usercert)) {
|
||||
BIO_printf(p->errorbio, "SSL_CTX_use_certificate problem\n"); goto err;
|
||||
}
|
||||
if (!SSL_CTX_use_PrivateKey(ctx,p->pkey)) {
|
||||
BIO_printf(p->errorbio, "SSL_CTX_use_PrivateKey\n"); goto err;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_check_private_key(ctx)) {
|
||||
BIO_printf(p->errorbio, "SSL_CTX_check_private_key\n"); goto err;
|
||||
}
|
||||
|
||||
SSL_CTX_set_quiet_shutdown(ctx,1);
|
||||
SSL_CTX_set_cipher_list(ctx,"RC4-MD5");
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
|
||||
|
||||
X509_STORE_add_cert(ctx->cert_store,sk_X509_value(p->ca,
|
||||
sk_X509_num(p->ca)-1));
|
||||
|
||||
SSL_CTX_set_verify_depth(ctx,2);
|
||||
|
||||
SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,ZERO_NULL);
|
||||
|
||||
SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm);
|
||||
|
||||
|
||||
return CURLE_OK ;
|
||||
err:
|
||||
ERR_print_errors(p->errorbio);
|
||||
return CURLE_SSL_CERTPROBLEM;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
BIO* in=NULL;
|
||||
BIO* out=NULL;
|
||||
|
||||
char * outfile = NULL;
|
||||
char * infile = NULL ;
|
||||
|
||||
int tabLength=100;
|
||||
char *binaryptr;
|
||||
char* mimetype;
|
||||
char* mimetypeaccept=NULL;
|
||||
char* contenttype;
|
||||
char** pp;
|
||||
unsigned char* hostporturl = NULL;
|
||||
binaryptr=(char*)malloc(tabLength);
|
||||
BIO * p12bio ;
|
||||
char **args = argv + 1;
|
||||
unsigned char * serverurl;
|
||||
sslctxparm p;
|
||||
char *response;
|
||||
p.verbose = 0;
|
||||
|
||||
CURLcode res;
|
||||
struct curl_slist * headers=NULL;
|
||||
|
||||
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
/* we need some more for the P12 decoding */
|
||||
|
||||
OpenSSL_add_all_ciphers();
|
||||
OpenSSL_add_all_digests();
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
|
||||
int badarg=0;
|
||||
|
||||
while (*args && *args[0] == '-') {
|
||||
if (!strcmp (*args, "-in")) {
|
||||
if (args[1]) {
|
||||
infile=*(++args);
|
||||
} else badarg=1;
|
||||
} else if (!strcmp (*args, "-out")) {
|
||||
if (args[1]) {
|
||||
outfile=*(++args);
|
||||
} else badarg=1;
|
||||
} else if (!strcmp (*args, "-p12")) {
|
||||
if (args[1]) {
|
||||
p.p12file = *(++args);
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-envpass") == 0) {
|
||||
if (args[1]) {
|
||||
p.pst = getenv(*(++args));
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-connect") == 0) {
|
||||
if (args[1]) {
|
||||
hostporturl = *(++args);
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-mimetype") == 0) {
|
||||
if (args[1]) {
|
||||
mimetype = *(++args);
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-acceptmime") == 0) {
|
||||
if (args[1]) {
|
||||
mimetypeaccept = *(++args);
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-accesstype") == 0) {
|
||||
if (args[1]) {
|
||||
if ((p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args,0))) == 0) badarg=1;
|
||||
} else badarg=1;
|
||||
} else if (strcmp(*args,"-verbose") == 0) {
|
||||
p.verbose++;
|
||||
} else badarg=1;
|
||||
args++;
|
||||
}
|
||||
|
||||
if (mimetype==NULL || mimetypeaccept == NULL) badarg = 1;
|
||||
|
||||
if (badarg) {
|
||||
for (pp=curlx_usage; (*pp != NULL); pp++)
|
||||
BIO_printf(p.errorbio,"%s\n",*pp);
|
||||
BIO_printf(p.errorbio,"\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* set input */
|
||||
|
||||
if ((in=BIO_new(BIO_s_file())) == NULL) {
|
||||
BIO_printf(p.errorbio, "Error setting input bio\n");
|
||||
goto err;
|
||||
} else if (infile == NULL)
|
||||
BIO_set_fp(in,stdin,BIO_NOCLOSE|BIO_FP_TEXT);
|
||||
else if (BIO_read_filename(in,infile) <= 0) {
|
||||
BIO_printf(p.errorbio, "Error opening input file %s\n", infile);
|
||||
BIO_free(in);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* set output */
|
||||
|
||||
if ((out=BIO_new(BIO_s_file())) == NULL) {
|
||||
BIO_printf(p.errorbio, "Error setting output bio.\n");
|
||||
goto err;
|
||||
} else if (outfile == NULL)
|
||||
BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
|
||||
else if (BIO_write_filename(out,outfile) <= 0) {
|
||||
BIO_printf(p.errorbio, "Error opening output file %s\n", outfile);
|
||||
BIO_free(out);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
||||
|
||||
if (!(p.curl = curl_easy_init())) {
|
||||
BIO_printf(p.errorbio, "Cannot init curl lib\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!(p12bio = BIO_new_file(p.p12file , "rb"))) {
|
||||
BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file); goto err;
|
||||
}
|
||||
if (!(p.p12 = d2i_PKCS12_bio (p12bio, NULL))) {
|
||||
BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file); goto err;
|
||||
}
|
||||
|
||||
p.ca= NULL;
|
||||
if (!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) {
|
||||
BIO_printf(p.errorbio,"Invalid P12 structure in %s\n", p.p12file); goto err;
|
||||
}
|
||||
|
||||
if (sk_X509_num(p.ca) <= 0) {
|
||||
BIO_printf(p.errorbio,"No trustworthy CA given.%s\n", p.p12file); goto err;
|
||||
}
|
||||
|
||||
if (p.verbose > 1)
|
||||
X509_print_ex(p.errorbio,p.usercert,0,0);
|
||||
|
||||
/* determine URL to go */
|
||||
|
||||
if (hostporturl) {
|
||||
serverurl=(char*) malloc(9+strlen(hostporturl));
|
||||
sprintf(serverurl,"https://%s",hostporturl);
|
||||
}
|
||||
else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
|
||||
if (!(serverurl = my_get_ext(p.usercert,p.accesstype,NID_info_access))) {
|
||||
BIO_printf(p.errorbio,"no service URL in user cert "
|
||||
"cherching in others certificats\n");
|
||||
int j=0;
|
||||
int find=0;
|
||||
for (j=0;j<sk_X509_num(p.ca);j++) {
|
||||
if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
|
||||
NID_info_access)))
|
||||
break;
|
||||
if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
|
||||
NID_sinfo_access)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!serverurl) {
|
||||
BIO_printf(p.errorbio, "no service URL in certificats,"
|
||||
" check '-accesstype (AD_DVCS | ad_timestamping)'"
|
||||
" or use '-connect'\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (p.verbose)
|
||||
BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl);
|
||||
|
||||
curl_easy_setopt(p.curl, CURLOPT_URL, serverurl);
|
||||
|
||||
/* Now specify the POST binary data */
|
||||
|
||||
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr);
|
||||
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE,tabLength);
|
||||
|
||||
/* pass our list of custom made headers */
|
||||
|
||||
contenttype=(char*) malloc(15+strlen(mimetype));
|
||||
sprintf(contenttype,"Content-type: %s",mimetype);
|
||||
headers = curl_slist_append(headers,contenttype);
|
||||
curl_easy_setopt(p.curl, CURLOPT_HTTPHEADER, headers);
|
||||
|
||||
if (p.verbose)
|
||||
BIO_printf(p.errorbio, "Service URL: <%s>\n", serverurl);
|
||||
|
||||
{
|
||||
FILE *outfp;
|
||||
BIO_get_fp(out,&outfp);
|
||||
curl_easy_setopt(p.curl, CURLOPT_FILE,outfp);
|
||||
}
|
||||
|
||||
res = curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ;
|
||||
|
||||
if (res != CURLE_OK)
|
||||
BIO_printf(p.errorbio,"%d %s=%d %d\n", __LINE__, "CURLOPT_SSL_CTX_FUNCTION",CURLOPT_SSL_CTX_FUNCTION,res);
|
||||
|
||||
curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p);
|
||||
|
||||
{
|
||||
int lu; int i=0;
|
||||
while ((lu = BIO_read (in,&binaryptr[i],tabLength-i)) >0 ) {
|
||||
i+=lu;
|
||||
if (i== tabLength) {
|
||||
tabLength+=100;
|
||||
binaryptr=(char*)realloc(binaryptr,tabLength); /* should be more careful */
|
||||
}
|
||||
}
|
||||
tabLength = i;
|
||||
}
|
||||
/* Now specify the POST binary data */
|
||||
|
||||
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDS, binaryptr);
|
||||
curl_easy_setopt(p.curl, CURLOPT_POSTFIELDSIZE,tabLength);
|
||||
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
|
||||
BIO_printf(p.errorbio,"%d %s %d\n", __LINE__, "curl_easy_perform",
|
||||
res = curl_easy_perform(p.curl));
|
||||
{
|
||||
int result =curl_easy_getinfo(p.curl,CURLINFO_CONTENT_TYPE,&response);
|
||||
if( mimetypeaccept && p.verbose)
|
||||
if(!strcmp(mimetypeaccept,response))
|
||||
BIO_printf(p.errorbio,"the response has a correct mimetype : %s\n",
|
||||
response);
|
||||
else
|
||||
BIO_printf(p.errorbio,"the reponse doesn\'t has an acceptable "
|
||||
"mime type, it is %s instead of %s\n",
|
||||
response,mimetypeaccept);
|
||||
}
|
||||
|
||||
/*** code d'erreur si accept mime ***, egalement code return HTTP != 200 ***/
|
||||
|
||||
/* free the header list*/
|
||||
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(p.curl);
|
||||
|
||||
BIO_free(in);
|
||||
BIO_free(out);
|
||||
return (EXIT_SUCCESS);
|
||||
|
||||
err: BIO_printf(p.errorbio,"error");
|
||||
exit(1);
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: debug.c,v 1.2 2006-10-20 21:26:10 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
struct data {
|
||||
char trace_ascii; /* 1 or 0 */
|
||||
};
|
||||
|
||||
static
|
||||
void dump(const char *text,
|
||||
FILE *stream, unsigned char *ptr, size_t size,
|
||||
char nohex)
|
||||
{
|
||||
size_t i;
|
||||
size_t c;
|
||||
|
||||
unsigned int width=0x10;
|
||||
|
||||
if(nohex)
|
||||
/* without the hex output, we can fit more on screen */
|
||||
width = 0x40;
|
||||
|
||||
fprintf(stream, "%s, %zd bytes (0x%zx)\n", text, size, size);
|
||||
|
||||
for(i=0; i<size; i+= width) {
|
||||
|
||||
fprintf(stream, "%04zx: ", i);
|
||||
|
||||
if(!nohex) {
|
||||
/* hex not disabled, show it */
|
||||
for(c = 0; c < width; c++)
|
||||
if(i+c < size)
|
||||
fprintf(stream, "%02x ", ptr[i+c]);
|
||||
else
|
||||
fputs(" ", stream);
|
||||
}
|
||||
|
||||
for(c = 0; (c < width) && (i+c < size); c++) {
|
||||
/* check for 0D0A; if found, skip past and start a new line of output */
|
||||
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
|
||||
i+=(c+2-width);
|
||||
break;
|
||||
}
|
||||
fprintf(stream, "%c",
|
||||
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
|
||||
/* check again for 0D0A, to avoid an extra \n if it's at width */
|
||||
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
|
||||
i+=(c+3-width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fputc('\n', stream); /* newline */
|
||||
}
|
||||
fflush(stream);
|
||||
}
|
||||
|
||||
static
|
||||
int my_trace(CURL *handle, curl_infotype type,
|
||||
unsigned char *data, size_t size,
|
||||
void *userp)
|
||||
{
|
||||
struct data *config = (struct data *)userp;
|
||||
const char *text;
|
||||
(void)handle; /* prevent compiler warning */
|
||||
|
||||
switch (type) {
|
||||
case CURLINFO_TEXT:
|
||||
fprintf(stderr, "== Info: %s", data);
|
||||
default: /* in case a new one is introduced to shock us */
|
||||
return 0;
|
||||
|
||||
case CURLINFO_HEADER_OUT:
|
||||
text = "=> Send header";
|
||||
break;
|
||||
case CURLINFO_DATA_OUT:
|
||||
text = "=> Send data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_OUT:
|
||||
text = "=> Send SSL data";
|
||||
break;
|
||||
case CURLINFO_HEADER_IN:
|
||||
text = "<= Recv header";
|
||||
break;
|
||||
case CURLINFO_DATA_IN:
|
||||
text = "<= Recv data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_IN:
|
||||
text = "<= Recv SSL data";
|
||||
break;
|
||||
}
|
||||
|
||||
dump(text, stderr, data, size, config->trace_ascii);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
struct data config;
|
||||
|
||||
config.trace_ascii = 1; /* enable ascii tracing */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
||||
|
||||
/* the DEBUGFUNCTION has no effect until we enable VERBOSE */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: fileupload.c,v 1.2 2004/10/16 13:17:15 giva Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
curl_off_t size;
|
||||
struct stat file_info;
|
||||
double speed_upload, total_time;
|
||||
FILE *fd;
|
||||
|
||||
fd = fopen("debugit", "rb"); /* open file to upload */
|
||||
if(!fd) {
|
||||
|
||||
return 1; /* can't continue */
|
||||
}
|
||||
|
||||
stat("debugit", &file_info); /* to get the file size */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* upload to this place */
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"file:///home/dast/src/curl/debug/new");
|
||||
|
||||
/* tell it to "upload" to the URL */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
||||
|
||||
/* set where to read from (on Windows you need to use READFUNCTION too) */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, fd);
|
||||
|
||||
/* and give the size of the upload (optional) */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
(curl_off_t)file_info.st_size);
|
||||
|
||||
/* enable verbose for easier tracing */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* now extract transfer info */
|
||||
curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload);
|
||||
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time);
|
||||
|
||||
fprintf(stderr, "Speed: %.3f bytes/sec during %.3f seconds\n",
|
||||
speed_upload, total_time);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,564 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This example source code introduces a c library buffered I/O interface to
|
||||
* URL reads it supports fopen(), fread(), fgets(), feof(), fclose(),
|
||||
* rewind(). Supported functions have identical prototypes to their normal c
|
||||
* lib namesakes and are preceaded by url_ .
|
||||
*
|
||||
* Using this code you can replace your program's fopen() with url_fopen()
|
||||
* and fread() with url_fread() and it become possible to read remote streams
|
||||
* instead of (only) local files. Local files (ie those that can be directly
|
||||
* fopened) will drop back to using the underlying clib implementations
|
||||
*
|
||||
* See the main() function at the bottom that shows an app that retrives from a
|
||||
* specified url using fgets() and fread() and saves as two output files.
|
||||
*
|
||||
* Coyright (c)2003 Simtec Electronics
|
||||
*
|
||||
* Re-implemented by Vincent Sanders <vince@kyllikki.org> with extensive
|
||||
* reference to original curl example code
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This example requires libcurl 7.9.7 or later.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
enum fcurl_type_e { CFTYPE_NONE=0, CFTYPE_FILE=1, CFTYPE_CURL=2 };
|
||||
|
||||
struct fcurl_data
|
||||
{
|
||||
enum fcurl_type_e type; /* type of handle */
|
||||
union {
|
||||
CURL *curl;
|
||||
FILE *file;
|
||||
} handle; /* handle */
|
||||
|
||||
char *buffer; /* buffer to store cached data*/
|
||||
int buffer_len; /* currently allocated buffers length */
|
||||
int buffer_pos; /* end of data in buffer*/
|
||||
int still_running; /* Is background url fetch still in progress */
|
||||
};
|
||||
|
||||
typedef struct fcurl_data URL_FILE;
|
||||
|
||||
/* exported functions */
|
||||
URL_FILE *url_fopen(char *url,const char *operation);
|
||||
int url_fclose(URL_FILE *file);
|
||||
int url_feof(URL_FILE *file);
|
||||
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
|
||||
char * url_fgets(char *ptr, int size, URL_FILE *file);
|
||||
void url_rewind(URL_FILE *file);
|
||||
|
||||
/* we use a global one for convenience */
|
||||
CURLM *multi_handle;
|
||||
|
||||
/* curl calls this routine to get more data */
|
||||
static size_t
|
||||
write_callback(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
void *userp)
|
||||
{
|
||||
char *newbuff;
|
||||
int rembuff;
|
||||
|
||||
URL_FILE *url = (URL_FILE *)userp;
|
||||
size *= nitems;
|
||||
|
||||
rembuff=url->buffer_len - url->buffer_pos;//remaining space in buffer
|
||||
|
||||
if(size > rembuff)
|
||||
{
|
||||
//not enuf space in buffer
|
||||
newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
|
||||
if(newbuff==NULL)
|
||||
{
|
||||
fprintf(stderr,"callback buffer grow failed\n");
|
||||
size=rembuff;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* realloc suceeded increase buffer size*/
|
||||
url->buffer_len+=size - rembuff;
|
||||
url->buffer=newbuff;
|
||||
|
||||
/*printf("Callback buffer grown to %d bytes\n",url->buffer_len);*/
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&url->buffer[url->buffer_pos], buffer, size);
|
||||
url->buffer_pos += size;
|
||||
|
||||
/*fprintf(stderr, "callback %d size bytes\n", size);*/
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/* use to attempt to fill the read buffer up to requested number of bytes */
|
||||
static int
|
||||
fill_buffer(URL_FILE *file,int want,int waittime)
|
||||
{
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
struct timeval timeout;
|
||||
int rc;
|
||||
|
||||
/* only attempt to fill buffer if transactions still running and buffer
|
||||
* doesnt exceed required size already
|
||||
*/
|
||||
if((!file->still_running) || (file->buffer_pos > want))
|
||||
return 0;
|
||||
|
||||
/* attempt to fill buffer */
|
||||
do
|
||||
{
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to fail on */
|
||||
timeout.tv_sec = 60; /* 1 minute */
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1
|
||||
so that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
/* note we *could* be more efficient and not wait for
|
||||
* CURLM_CALL_MULTI_PERFORM to clear here and check it on re-entry
|
||||
* but that gets messy */
|
||||
while(curl_multi_perform(multi_handle, &file->still_running) ==
|
||||
CURLM_CALL_MULTI_PERFORM);
|
||||
|
||||
break;
|
||||
}
|
||||
} while(file->still_running && (file->buffer_pos < want));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* use to remove want bytes from the front of a files buffer */
|
||||
static int
|
||||
use_buffer(URL_FILE *file,int want)
|
||||
{
|
||||
/* sort out buffer */
|
||||
if((file->buffer_pos - want) <=0)
|
||||
{
|
||||
/* ditch buffer - write will recreate */
|
||||
if(file->buffer)
|
||||
free(file->buffer);
|
||||
|
||||
file->buffer=NULL;
|
||||
file->buffer_pos=0;
|
||||
file->buffer_len=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* move rest down make it available for later */
|
||||
memmove(file->buffer,
|
||||
&file->buffer[want],
|
||||
(file->buffer_pos - want));
|
||||
|
||||
file->buffer_pos -= want;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
URL_FILE *
|
||||
url_fopen(char *url,const char *operation)
|
||||
{
|
||||
/* this code could check for URLs or types in the 'url' and
|
||||
basicly use the real fopen() for standard files */
|
||||
|
||||
URL_FILE *file;
|
||||
(void)operation;
|
||||
|
||||
file = (URL_FILE *)malloc(sizeof(URL_FILE));
|
||||
if(!file)
|
||||
return NULL;
|
||||
|
||||
memset(file, 0, sizeof(URL_FILE));
|
||||
|
||||
if((file->handle.file=fopen(url,operation)))
|
||||
{
|
||||
file->type = CFTYPE_FILE; /* marked as URL */
|
||||
}
|
||||
else
|
||||
{
|
||||
file->type = CFTYPE_CURL; /* marked as URL */
|
||||
file->handle.curl = curl_easy_init();
|
||||
|
||||
curl_easy_setopt(file->handle.curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEDATA, file);
|
||||
curl_easy_setopt(file->handle.curl, CURLOPT_VERBOSE, FALSE);
|
||||
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
|
||||
if(!multi_handle)
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
curl_multi_add_handle(multi_handle, file->handle.curl);
|
||||
|
||||
/* lets start the fetch */
|
||||
while(curl_multi_perform(multi_handle, &file->still_running) ==
|
||||
CURLM_CALL_MULTI_PERFORM );
|
||||
|
||||
if((file->buffer_pos == 0) && (!file->still_running))
|
||||
{
|
||||
/* if still_running is 0 now, we should return NULL */
|
||||
|
||||
/* make sure the easy handle is not in the multi handle anymore */
|
||||
curl_multi_remove_handle(multi_handle, file->handle.curl);
|
||||
|
||||
/* cleanup */
|
||||
curl_easy_cleanup(file->handle.curl);
|
||||
|
||||
free(file);
|
||||
|
||||
file = NULL;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
int
|
||||
url_fclose(URL_FILE *file)
|
||||
{
|
||||
int ret=0;/* default is good return */
|
||||
|
||||
switch(file->type)
|
||||
{
|
||||
case CFTYPE_FILE:
|
||||
ret=fclose(file->handle.file); /* passthrough */
|
||||
break;
|
||||
|
||||
case CFTYPE_CURL:
|
||||
/* make sure the easy handle is not in the multi handle anymore */
|
||||
curl_multi_remove_handle(multi_handle, file->handle.curl);
|
||||
|
||||
/* cleanup */
|
||||
curl_easy_cleanup(file->handle.curl);
|
||||
break;
|
||||
|
||||
default: /* unknown or supported type - oh dear */
|
||||
ret=EOF;
|
||||
errno=EBADF;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(file->buffer)
|
||||
free(file->buffer);/* free any allocated buffer space */
|
||||
|
||||
free(file);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
url_feof(URL_FILE *file)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
switch(file->type)
|
||||
{
|
||||
case CFTYPE_FILE:
|
||||
ret=feof(file->handle.file);
|
||||
break;
|
||||
|
||||
case CFTYPE_CURL:
|
||||
if((file->buffer_pos == 0) && (!file->still_running))
|
||||
ret = 1;
|
||||
break;
|
||||
default: /* unknown or supported type - oh dear */
|
||||
ret=-1;
|
||||
errno=EBADF;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file)
|
||||
{
|
||||
size_t want;
|
||||
|
||||
switch(file->type)
|
||||
{
|
||||
case CFTYPE_FILE:
|
||||
want=fread(ptr,size,nmemb,file->handle.file);
|
||||
break;
|
||||
|
||||
case CFTYPE_CURL:
|
||||
want = nmemb * size;
|
||||
|
||||
fill_buffer(file,want,1);
|
||||
|
||||
/* check if theres data in the buffer - if not fill_buffer()
|
||||
* either errored or EOF */
|
||||
if(!file->buffer_pos)
|
||||
return 0;
|
||||
|
||||
/* ensure only available data is considered */
|
||||
if(file->buffer_pos < want)
|
||||
want = file->buffer_pos;
|
||||
|
||||
/* xfer data to caller */
|
||||
memcpy(ptr, file->buffer, want);
|
||||
|
||||
use_buffer(file,want);
|
||||
|
||||
want = want / size; /* number of items - nb correct op - checked
|
||||
* with glibc code*/
|
||||
|
||||
/*printf("(fread) return %d bytes %d left\n", want,file->buffer_pos);*/
|
||||
break;
|
||||
|
||||
default: /* unknown or supported type - oh dear */
|
||||
want=0;
|
||||
errno=EBADF;
|
||||
break;
|
||||
|
||||
}
|
||||
return want;
|
||||
}
|
||||
|
||||
char *
|
||||
url_fgets(char *ptr, int size, URL_FILE *file)
|
||||
{
|
||||
int want = size - 1;/* always need to leave room for zero termination */
|
||||
int loop;
|
||||
|
||||
switch(file->type)
|
||||
{
|
||||
case CFTYPE_FILE:
|
||||
ptr = fgets(ptr,size,file->handle.file);
|
||||
break;
|
||||
|
||||
case CFTYPE_CURL:
|
||||
fill_buffer(file,want,1);
|
||||
|
||||
/* check if theres data in the buffer - if not fill either errored or
|
||||
* EOF */
|
||||
if(!file->buffer_pos)
|
||||
return NULL;
|
||||
|
||||
/* ensure only available data is considered */
|
||||
if(file->buffer_pos < want)
|
||||
want = file->buffer_pos;
|
||||
|
||||
/*buffer contains data */
|
||||
/* look for newline or eof */
|
||||
for(loop=0;loop < want;loop++)
|
||||
{
|
||||
if(file->buffer[loop] == '\n')
|
||||
{
|
||||
want=loop+1;/* include newline */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* xfer data to caller */
|
||||
memcpy(ptr, file->buffer, want);
|
||||
ptr[want]=0;/* allways null terminate */
|
||||
|
||||
use_buffer(file,want);
|
||||
|
||||
/*printf("(fgets) return %d bytes %d left\n", want,file->buffer_pos);*/
|
||||
break;
|
||||
|
||||
default: /* unknown or supported type - oh dear */
|
||||
ptr=NULL;
|
||||
errno=EBADF;
|
||||
break;
|
||||
}
|
||||
|
||||
return ptr;/*success */
|
||||
}
|
||||
|
||||
void
|
||||
url_rewind(URL_FILE *file)
|
||||
{
|
||||
switch(file->type)
|
||||
{
|
||||
case CFTYPE_FILE:
|
||||
rewind(file->handle.file); /* passthrough */
|
||||
break;
|
||||
|
||||
case CFTYPE_CURL:
|
||||
/* halt transaction */
|
||||
curl_multi_remove_handle(multi_handle, file->handle.curl);
|
||||
|
||||
/* restart */
|
||||
curl_multi_add_handle(multi_handle, file->handle.curl);
|
||||
|
||||
/* ditch buffer - write will recreate - resets stream pos*/
|
||||
if(file->buffer)
|
||||
free(file->buffer);
|
||||
|
||||
file->buffer=NULL;
|
||||
file->buffer_pos=0;
|
||||
file->buffer_len=0;
|
||||
|
||||
break;
|
||||
|
||||
default: /* unknown or supported type - oh dear */
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Small main program to retrive from a url using fgets and fread saving the
|
||||
* output to two test files (note the fgets method will corrupt binary files if
|
||||
* they contain 0 chars */
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
URL_FILE *handle;
|
||||
FILE *outf;
|
||||
|
||||
int nread;
|
||||
char buffer[256];
|
||||
char *url;
|
||||
|
||||
if(argc < 2)
|
||||
{
|
||||
url="http://192.168.7.3/testfile";/* default to testurl */
|
||||
}
|
||||
else
|
||||
{
|
||||
url=argv[1];/* use passed url */
|
||||
}
|
||||
|
||||
/* copy from url line by line with fgets */
|
||||
outf=fopen("fgets.test","w+");
|
||||
if(!outf)
|
||||
{
|
||||
perror("couldnt open fgets output file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
handle = url_fopen(url, "r");
|
||||
if(!handle)
|
||||
{
|
||||
printf("couldn't url_fopen()\n");
|
||||
fclose(outf);
|
||||
return 2;
|
||||
}
|
||||
|
||||
while(!url_feof(handle))
|
||||
{
|
||||
url_fgets(buffer,sizeof(buffer),handle);
|
||||
fwrite(buffer,1,strlen(buffer),outf);
|
||||
}
|
||||
|
||||
url_fclose(handle);
|
||||
|
||||
fclose(outf);
|
||||
|
||||
|
||||
/* Copy from url with fread */
|
||||
outf=fopen("fread.test","w+");
|
||||
if(!outf)
|
||||
{
|
||||
perror("couldnt open fread output file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
handle = url_fopen("testfile", "r");
|
||||
if(!handle) {
|
||||
printf("couldn't url_fopen()\n");
|
||||
fclose(outf);
|
||||
return 2;
|
||||
}
|
||||
|
||||
do {
|
||||
nread = url_fread(buffer, 1,sizeof(buffer), handle);
|
||||
fwrite(buffer,1,nread,outf);
|
||||
} while(nread);
|
||||
|
||||
url_fclose(handle);
|
||||
|
||||
fclose(outf);
|
||||
|
||||
|
||||
/* Test rewind */
|
||||
outf=fopen("rewind.test","w+");
|
||||
if(!outf)
|
||||
{
|
||||
perror("couldnt open fread output file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
handle = url_fopen("testfile", "r");
|
||||
if(!handle) {
|
||||
printf("couldn't url_fopen()\n");
|
||||
fclose(outf);
|
||||
return 2;
|
||||
}
|
||||
|
||||
nread = url_fread(buffer, 1,sizeof(buffer), handle);
|
||||
fwrite(buffer,1,nread,outf);
|
||||
url_rewind(handle);
|
||||
|
||||
buffer[0]='\n';
|
||||
fwrite(buffer,1,1,outf);
|
||||
|
||||
nread = url_fread(buffer, 1,sizeof(buffer), handle);
|
||||
fwrite(buffer,1,nread,outf);
|
||||
|
||||
|
||||
url_fclose(handle);
|
||||
|
||||
fclose(outf);
|
||||
|
||||
|
||||
return 0;/* all done */
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ftp3rdparty.c,v 1.2 2005/01/21 09:32:33 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
/*
|
||||
* This is an example showing how to transfer a file between two remote hosts.
|
||||
* 7.13.0 or later required.
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
char source_url[] = "ftp://remotehost.com/path/to/source";
|
||||
char target_url[] = "ftp://aotherserver.com/path/to/dest";
|
||||
|
||||
char sourceUserPass[] = "user:pass";
|
||||
char targetUserPass[] = "user:pass";
|
||||
char url[100];
|
||||
|
||||
struct curl_slist *source_pre_cmd = NULL;
|
||||
struct curl_slist *target_pre_cmd = NULL;
|
||||
struct curl_slist *source_post_cmd = NULL;
|
||||
struct curl_slist *target_post_cmd = NULL;
|
||||
char cmd[] = "PWD"; /* just to test */
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
/* The ordinary URL is the target when speaking 3rd party transfers */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, target_url);
|
||||
|
||||
/* Set a source URL */
|
||||
curl_easy_setopt(curl, CURLOPT_SOURCE_URL, source_url);
|
||||
|
||||
/* Set target user and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, targetUserPass);
|
||||
|
||||
/* Set source user and password */
|
||||
curl_easy_setopt(curl, CURLOPT_SOURCE_USERPWD, sourceUserPass);
|
||||
|
||||
#if 0
|
||||
/* FTPPORT enables PORT on the target side, instead of PASV. */
|
||||
curl_easy_setopt(curl, CURLOPT_FTPPORT, ""); /* optional */
|
||||
#endif
|
||||
|
||||
/* build a list of commands to pass to libcurl */
|
||||
source_pre_cmd = curl_slist_append(source_pre_cmd, cmd);
|
||||
/* Set a proxy pre-quote command */
|
||||
curl_easy_setopt(curl, CURLOPT_SOURCE_PREQUOTE, source_pre_cmd);
|
||||
|
||||
/* build a list of commands to pass to libcurl */
|
||||
target_pre_cmd = curl_slist_append(target_pre_cmd, cmd);
|
||||
/* Set a pre-quote command */
|
||||
curl_easy_setopt(curl, CURLOPT_PREQUOTE, target_pre_cmd);
|
||||
|
||||
/* build a list of commands to pass to libcurl */
|
||||
source_post_cmd = curl_slist_append(source_post_cmd, cmd);
|
||||
/* Set a proxy post-quote command */
|
||||
curl_easy_setopt(curl, CURLOPT_SOURCE_POSTQUOTE, source_post_cmd);
|
||||
|
||||
/* build a list of commands to pass to libcurl */
|
||||
target_post_cmd = curl_slist_append(target_post_cmd, cmd);
|
||||
/* Set a post-quote command */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, target_post_cmd);
|
||||
|
||||
/* Switch on full protocol/debug output */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* clean up the FTP commands list */
|
||||
curl_slist_free_all(source_pre_cmd);
|
||||
curl_slist_free_all(target_pre_cmd);
|
||||
curl_slist_free_all(source_post_cmd);
|
||||
curl_slist_free_all(target_post_cmd);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != res) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", res);
|
||||
}
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ftpget.c,v 1.4 2004/08/23 14:22:52 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
/*
|
||||
* This is an example showing how to get a single file from an FTP server.
|
||||
* It delays the actual destination file creation until the first write
|
||||
* callback so that it won't create an empty file in case the remote file
|
||||
* doesn't exist or something else fails.
|
||||
*/
|
||||
|
||||
struct FtpFile {
|
||||
char *filename;
|
||||
FILE *stream;
|
||||
};
|
||||
|
||||
int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
struct FtpFile *out=(struct FtpFile *)stream;
|
||||
if(out && !out->stream) {
|
||||
/* open file for writing */
|
||||
out->stream=fopen(out->filename, "wb");
|
||||
if(!out->stream)
|
||||
return -1; /* failure, can't open file to write */
|
||||
}
|
||||
return fwrite(buffer, size, nmemb, out->stream);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
struct FtpFile ftpfile={
|
||||
"curl.tar.gz", /* name to store the file as if succesful */
|
||||
NULL
|
||||
};
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/*
|
||||
* Get curl 7.9.2 from sunet.se's FTP site. curl 7.9.2 is most likely not
|
||||
* present there by the time you read this, so you'd better replace the
|
||||
* URL with one that works!
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"ftp://ftp.sunet.se/pub/www/utilities/curl/curl-7.9.2.tar.gz");
|
||||
/* Define our callback to get called when there's data to be written */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
|
||||
/* Set a pointer to our struct to pass to the callback */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
|
||||
|
||||
/* Switch on full protocol/debug output */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != res) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", res);
|
||||
}
|
||||
}
|
||||
|
||||
if(ftpfile.stream)
|
||||
fclose(ftpfile.stream); /* close the local file */
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ftpgetresp.c,v 1.2 2003/12/08 14:13:19 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
/*
|
||||
* Similar to ftpget.c but this also stores the received response-lines
|
||||
* in a separate file using our own callback!
|
||||
*
|
||||
* This functionality was introduced in libcurl 7.9.3.
|
||||
*/
|
||||
|
||||
size_t
|
||||
write_response(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
FILE *writehere = (FILE *)data;
|
||||
return fwrite(ptr, size, nmemb, writehere);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *ftpfile;
|
||||
FILE *respfile;
|
||||
|
||||
/* local file name to store the file as */
|
||||
ftpfile = fopen("ftp-list", "wb"); /* b is binary, needed on win32 */
|
||||
|
||||
/* local file name to store the FTP server's response lines in */
|
||||
respfile = fopen("ftp-responses", "wb"); /* b is binary, needed on win32 */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Get a file listing from sunet */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.sunet.se/");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ftpfile);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_response);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, respfile);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
fclose(ftpfile); /* close the local file */
|
||||
fclose(respfile); /* close the response file */
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ftpupload.c,v 1.7 2005/01/20 14:24:56 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/*
|
||||
* This example shows an FTP upload, with a rename of the file just after
|
||||
* a successful upload.
|
||||
*
|
||||
* Example based on source code provided by Erick Nuwendam. Thanks!
|
||||
*/
|
||||
|
||||
#define LOCAL_FILE "/tmp/uploadthis.txt"
|
||||
#define UPLOAD_FILE_AS "while-uploading.txt"
|
||||
#define REMOTE_URL "ftp://localhost/" UPLOAD_FILE_AS
|
||||
#define RENAME_FILE_TO "renamed-and-fine.txt"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *ftpfile;
|
||||
FILE * hd_src ;
|
||||
int hd ;
|
||||
struct stat file_info;
|
||||
|
||||
struct curl_slist *headerlist=NULL;
|
||||
char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
|
||||
char buf_2 [] = "RNTO " RENAME_FILE_TO;
|
||||
|
||||
/* get the file size of the local file */
|
||||
hd = open(LOCAL_FILE, O_RDONLY) ;
|
||||
fstat(hd, &file_info);
|
||||
close(hd) ;
|
||||
|
||||
/* get a FILE * of the same file, could also be made with
|
||||
fdopen() from the previous descriptor, but hey this is just
|
||||
an example! */
|
||||
hd_src = fopen(LOCAL_FILE, "rb");
|
||||
|
||||
/* In windows, this will init the winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* build a list of commands to pass to libcurl */
|
||||
headerlist = curl_slist_append(headerlist, buf_1);
|
||||
headerlist = curl_slist_append(headerlist, buf_2);
|
||||
|
||||
/* enable uploading */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
|
||||
|
||||
/* pass in that last of FTP commands to run after the transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
|
||||
|
||||
/* now specify which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
/* NOTE: if you want this example to work on Windows with libcurl as a
|
||||
DLL, you MUST also provide a read callback with
|
||||
CURLOPT_READFUNCTION. Failing to do so will give you a crash since a
|
||||
DLL may not use the variable's memory when passed in to it from an app
|
||||
like this. */
|
||||
|
||||
/* Set the size of the file to upload (optional). If you give a *_LARGE
|
||||
option you MUST make sure that the type of the passed-in argument is a
|
||||
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
|
||||
make sure that to pass in a type 'long' argument. */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
(curl_off_t)file_info.st_size);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* clean up the FTP commands list */
|
||||
curl_slist_free_all (headerlist);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
fclose(hd_src); /* close the local file */
|
||||
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ftpuploadresume.c,v 1.1 2006-05-11 22:24:44 bagder Exp $
|
||||
*
|
||||
* Upload to FTP, resuming failed transfers
|
||||
*
|
||||
* Compile for MinGW like this:
|
||||
* gcc -Wall -pedantic -std=c99 ftpuploadwithresume.c -o ftpuploadresume.exe
|
||||
* -lcurl -lmsvcr70
|
||||
*
|
||||
* Written by Philip Bock
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
||||
/* The MinGW headers are missing a few Win32 function definitions,
|
||||
you shouldn't need this if you use VC++ */
|
||||
int __cdecl _snscanf(const char * input, size_t length, const char * format, ...);
|
||||
|
||||
|
||||
/* parse headers for Content-Length */
|
||||
size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void *stream) {
|
||||
int r;
|
||||
long len = 0;
|
||||
|
||||
/* _snscanf() is Win32 specific */
|
||||
r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len);
|
||||
|
||||
if (r) /* Microsoft: we don't read the specs */
|
||||
*((long *) stream) = len;
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
/* discard downloaded data */
|
||||
size_t discardfunc(void *ptr, size_t size, size_t nmemb, void *stream) {
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
/* read data to upload */
|
||||
size_t readfunc(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
FILE *f = stream;
|
||||
size_t n;
|
||||
|
||||
if (ferror(f))
|
||||
return CURL_READFUNC_ABORT;
|
||||
|
||||
n = fread(ptr, size, nmemb, f) * size;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
|
||||
long timeout, long tries)
|
||||
{
|
||||
FILE *f;
|
||||
long uploaded_len = 0;
|
||||
CURLcode r = CURLE_GOT_NOTHING;
|
||||
int c;
|
||||
|
||||
f = fopen(localpath, "rb");
|
||||
if (f == NULL) {
|
||||
perror(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, TRUE);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
|
||||
|
||||
if (timeout)
|
||||
curl_easy_setopt(curlhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, timeout);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_HEADERFUNCTION, getcontentlengthfunc);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_HEADERDATA, &uploaded_len);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, discardfunc);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
|
||||
curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, TRUE);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, TRUE);
|
||||
|
||||
for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
|
||||
/* are we resuming? */
|
||||
if (c) { /* yes */
|
||||
/* determine the length of the file already written */
|
||||
|
||||
/*
|
||||
* With NOBODY and NOHEADER, libcurl will issue a SIZE
|
||||
* command, but the only way to retrieve the result is
|
||||
* to parse the returned Content-Length header. Thus,
|
||||
* getcontentlengthfunc(). We need discardfunc() above
|
||||
* because HEADER will dump the headers to stdout
|
||||
* without it.
|
||||
*/
|
||||
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, TRUE);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_HEADER, TRUE);
|
||||
|
||||
r = curl_easy_perform(curlhandle);
|
||||
if (r != CURLE_OK)
|
||||
continue;
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, FALSE);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_HEADER, FALSE);
|
||||
|
||||
fseek(f, uploaded_len, SEEK_SET);
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, TRUE);
|
||||
}
|
||||
else { /* no */
|
||||
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, FALSE);
|
||||
}
|
||||
|
||||
r = curl_easy_perform(curlhandle);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
if (r == CURLE_OK)
|
||||
return 1;
|
||||
else {
|
||||
fprintf(stderr, "%s\n", curl_easy_strerror(r));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int c, char **argv) {
|
||||
CURL *curlhandle = NULL;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curlhandle = curl_easy_init();
|
||||
|
||||
upload(curlhandle, "ftp://user:pass@host/path/file", "C:\\file", 0, 3);
|
||||
|
||||
curl_easy_cleanup(curlhandle);
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: getinfo.c,v 1.2 2004/11/22 16:24:46 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_init.html */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTURL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_perform.html */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == res) {
|
||||
char *ct;
|
||||
/* ask for the content-type */
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */
|
||||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
|
||||
|
||||
if((CURLE_OK == res) && ct)
|
||||
printf("We received Content-Type: %s\n", ct);
|
||||
}
|
||||
|
||||
/* always cleanup */
|
||||
/* http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: getinmemory.c,v 1.10 2005/10/10 20:58:18 bagder Exp $
|
||||
*
|
||||
* Example source code to show how the callback function can be used to
|
||||
* download data into a chunk of memory instead of storing it in a file.
|
||||
*
|
||||
* This exact source code has not been verified to work.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
struct MemoryStruct {
|
||||
char *memory;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
void *myrealloc(void *ptr, size_t size)
|
||||
{
|
||||
/* There might be a realloc() out there that doesn't like reallocing
|
||||
NULL pointers, so we take care of it here */
|
||||
if(ptr)
|
||||
return realloc(ptr, size);
|
||||
else
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
size_t
|
||||
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
||||
|
||||
mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
|
||||
if (mem->memory) {
|
||||
memcpy(&(mem->memory[mem->size]), ptr, realsize);
|
||||
mem->size += realsize;
|
||||
mem->memory[mem->size] = 0;
|
||||
}
|
||||
return realsize;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl_handle;
|
||||
|
||||
struct MemoryStruct chunk;
|
||||
|
||||
chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
|
||||
chunk.size = 0; /* no data at this point */
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* init the curl session */
|
||||
curl_handle = curl_easy_init();
|
||||
|
||||
/* specify URL to get */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://cool.haxx.se/");
|
||||
|
||||
/* send all data to this function */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
|
||||
/* we pass our 'chunk' struct to the callback function */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
|
||||
|
||||
/* some servers don't like requests that are made without a user-agent
|
||||
field, so we provide one */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
||||
|
||||
/* get it! */
|
||||
curl_easy_perform(curl_handle);
|
||||
|
||||
/* cleanup curl stuff */
|
||||
curl_easy_cleanup(curl_handle);
|
||||
|
||||
/*
|
||||
* Now, our chunk.memory points to a memory block that is chunk.size
|
||||
* bytes big and contains the remote file.
|
||||
*
|
||||
* Do something nice with it!
|
||||
*
|
||||
* You should be aware of the fact that at this point we might have an
|
||||
* allocated data block, and nothing has yet deallocated that data. So when
|
||||
* you're done with it, you should free() it as a nice application.
|
||||
*/
|
||||
|
||||
if(chunk.memory)
|
||||
free(chunk.memory);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,461 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: ghiper.c,v 1.3 2006-10-12 21:26:50 bagder Exp $
|
||||
*
|
||||
* Example application source code using the multi socket interface to
|
||||
* download many files at once.
|
||||
*
|
||||
* Written by Jeff Pohlmeyer
|
||||
|
||||
Requires glib-2.x and a (POSIX?) system that has mkfifo().
|
||||
|
||||
This is an adaptation of libcurl's "hipev.c" and libevent's "event-test.c"
|
||||
sample programs, adapted to use glib's g_io_channel in place of libevent.
|
||||
|
||||
When running, the program creates the named pipe "hiper.fifo"
|
||||
|
||||
Whenever there is input into the fifo, the program reads the input as a list
|
||||
of URL's and creates some new easy handles to fetch each URL via the
|
||||
curl_multi "hiper" API.
|
||||
|
||||
|
||||
Thus, you can try a single URL:
|
||||
% echo http://www.yahoo.com > hiper.fifo
|
||||
|
||||
Or a whole bunch of them:
|
||||
% cat my-url-list > hiper.fifo
|
||||
|
||||
The fifo buffer is handled almost instantly, so you can even add more URL's
|
||||
while the previous requests are still being downloaded.
|
||||
|
||||
This is purely a demo app, all retrieved data is simply discarded by the write
|
||||
callback.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
||||
#define MSG_OUT g_print /* Change to "g_error" to write to stderr */
|
||||
#define SHOW_VERBOSE 0 /* Set to non-zero for libcurl messages */
|
||||
#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */
|
||||
|
||||
|
||||
|
||||
/* Global information, common to all connections */
|
||||
typedef struct _GlobalInfo {
|
||||
CURLM *multi;
|
||||
guint timer_event;
|
||||
int prev_running;
|
||||
int still_running;
|
||||
int requested; /* count: curl_easy_init() */
|
||||
int completed; /* count: curl_easy_cleanup() */
|
||||
} GlobalInfo;
|
||||
|
||||
|
||||
|
||||
/* Information associated with a specific easy handle */
|
||||
typedef struct _ConnInfo {
|
||||
CURL *easy;
|
||||
char *url;
|
||||
GlobalInfo *global;
|
||||
char error[CURL_ERROR_SIZE];
|
||||
} ConnInfo;
|
||||
|
||||
|
||||
/* Information associated with a specific socket */
|
||||
typedef struct _SockInfo {
|
||||
curl_socket_t sockfd;
|
||||
CURL *easy;
|
||||
int action;
|
||||
long timeout;
|
||||
GIOChannel *ch;
|
||||
guint ev;
|
||||
GlobalInfo *global;
|
||||
} SockInfo;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Die if we get a bad CURLMcode somewhere */
|
||||
static void mcode_or_die(char *where, CURLMcode code) {
|
||||
if ( CURLM_OK != code ) {
|
||||
char *s;
|
||||
switch (code) {
|
||||
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
|
||||
case CURLM_OK: s="CURLM_OK"; break;
|
||||
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
|
||||
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
|
||||
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
|
||||
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
|
||||
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break;
|
||||
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
|
||||
case CURLM_LAST: s="CURLM_LAST"; break;
|
||||
default: s="CURLM_unknown";
|
||||
}
|
||||
MSG_OUT("ERROR: %s returns %s\n", where, s);
|
||||
exit(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Check for completed transfers, and remove their easy handles */
|
||||
static void check_run_count(GlobalInfo *g)
|
||||
{
|
||||
if (g->prev_running > g->still_running) {
|
||||
char *eff_url=NULL;
|
||||
CURLMsg *msg;
|
||||
int msgs_left;
|
||||
ConnInfo *conn=NULL;
|
||||
CURL*easy;
|
||||
CURLcode res;
|
||||
|
||||
MSG_OUT("REMAINING: %d\n", g->still_running);
|
||||
/*
|
||||
I am still uncertain whether it is safe to remove an easy handle
|
||||
from inside the curl_multi_info_read loop, so here I will search
|
||||
for completed transfers in the inner "while" loop, and then remove
|
||||
them in the outer "do-while" loop...
|
||||
*/
|
||||
do {
|
||||
easy=NULL;
|
||||
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
|
||||
if (msg->msg == CURLMSG_DONE) {
|
||||
easy=msg->easy_handle;
|
||||
res=msg->data.result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (easy) {
|
||||
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
|
||||
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
|
||||
MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
|
||||
curl_multi_remove_handle(g->multi, easy);
|
||||
g_free(conn->url);
|
||||
curl_easy_cleanup(easy);
|
||||
g_free(conn);
|
||||
g->completed++;
|
||||
}
|
||||
} while ( easy );
|
||||
MSG_OUT("Requested: %d Completed:%d\n", g->requested, g->completed);
|
||||
}
|
||||
g->prev_running = g->still_running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Called by glib when our timeout expires */
|
||||
static gboolean timer_cb(gpointer data)
|
||||
{
|
||||
GlobalInfo *g = (GlobalInfo *)data;
|
||||
CURLMcode rc;
|
||||
|
||||
do {
|
||||
rc = curl_multi_socket(g->multi, CURL_SOCKET_TIMEOUT, &g->still_running);
|
||||
} while (rc == CURLM_CALL_MULTI_PERFORM);
|
||||
mcode_or_die("timer_cb: curl_multi_socket", rc);
|
||||
check_run_count(g);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Update the event timer after curl_multi library calls */
|
||||
static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp)
|
||||
{
|
||||
struct timeval timeout;
|
||||
GlobalInfo *g=(GlobalInfo *)userp;
|
||||
timeout.tv_sec = timeout_ms/1000;
|
||||
timeout.tv_usec = (timeout_ms%1000)*1000;
|
||||
|
||||
MSG_OUT("*** update_timeout_cb %ld => %ld:%ld ***\n",
|
||||
timeout_ms, timeout.tv_sec, timeout.tv_usec);
|
||||
|
||||
g->timer_event = g_timeout_add(timeout_ms, timer_cb, g);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Called by glib when we get action on a multi socket */
|
||||
static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
|
||||
{
|
||||
GlobalInfo *g = (GlobalInfo*) data;
|
||||
CURLMcode rc;
|
||||
int fd=g_io_channel_unix_get_fd(ch);
|
||||
do {
|
||||
rc = curl_multi_socket(g->multi, fd, &g->still_running);
|
||||
} while (rc == CURLM_CALL_MULTI_PERFORM);
|
||||
mcode_or_die("event_cb: curl_multi_socket", rc);
|
||||
check_run_count(g);
|
||||
if(g->still_running) {
|
||||
return TRUE;
|
||||
} else {
|
||||
MSG_OUT("last transfer done, kill timeout\n");
|
||||
if (g->timer_event) { g_source_remove(g->timer_event); }
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Clean up the SockInfo structure */
|
||||
static void remsock(SockInfo *f)
|
||||
{
|
||||
if (!f) { return; }
|
||||
if (f->ev) { g_source_remove(f->ev); }
|
||||
g_free(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Assign information to a SockInfo structure */
|
||||
static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
|
||||
{
|
||||
GIOCondition kind =
|
||||
(act&CURL_POLL_IN?G_IO_IN:0)|(act&CURL_POLL_OUT?G_IO_OUT:0);
|
||||
|
||||
f->sockfd = s;
|
||||
f->action = act;
|
||||
f->easy = e;
|
||||
if (f->ev) { g_source_remove(f->ev); }
|
||||
f->ev=g_io_add_watch(f->ch, kind, event_cb,g);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize a new SockInfo structure */
|
||||
static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
|
||||
{
|
||||
SockInfo *fdp = g_malloc0(sizeof(SockInfo));
|
||||
|
||||
fdp->global = g;
|
||||
fdp->ch=g_io_channel_unix_new(s);
|
||||
setsock(fdp, s, easy, action, g);
|
||||
curl_multi_assign(g->multi, s, fdp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CURLMOPT_SOCKETFUNCTION */
|
||||
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
||||
{
|
||||
GlobalInfo *g = (GlobalInfo*) cbp;
|
||||
SockInfo *fdp = (SockInfo*) sockp;
|
||||
char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||
if (what == CURL_POLL_REMOVE) {
|
||||
MSG_OUT("\n");
|
||||
remsock(fdp);
|
||||
} else {
|
||||
if (!fdp) {
|
||||
MSG_OUT("Adding data: %s%s\n",
|
||||
what&CURL_POLL_IN?"READ":"",
|
||||
what&CURL_POLL_OUT?"WRITE":"" );
|
||||
addsock(s, e, what, g);
|
||||
}
|
||||
else {
|
||||
MSG_OUT(
|
||||
"Changing action from %d to %d\n", fdp->action, what);
|
||||
setsock(fdp, s, e, what, g);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CURLOPT_WRITEFUNCTION */
|
||||
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
ConnInfo *conn = (ConnInfo*) data;
|
||||
(void)ptr;
|
||||
(void)conn;
|
||||
return realsize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CURLOPT_PROGRESSFUNCTION */
|
||||
static int prog_cb (void *p, double dltotal, double dlnow, double ult, double uln)
|
||||
{
|
||||
ConnInfo *conn = (ConnInfo *)p;
|
||||
MSG_OUT("Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Create a new easy handle, and add it to the global curl_multi */
|
||||
static void new_conn(char *url, GlobalInfo *g )
|
||||
{
|
||||
ConnInfo *conn;
|
||||
CURLMcode rc;
|
||||
|
||||
conn = g_malloc0(sizeof(ConnInfo));
|
||||
|
||||
conn->error[0]='\0';
|
||||
|
||||
conn->easy = curl_easy_init();
|
||||
if (!conn->easy) {
|
||||
MSG_OUT("curl_easy_init() failed, exiting!\n");
|
||||
exit(2);
|
||||
}
|
||||
conn->global = g;
|
||||
conn->url = g_strdup(url);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, &conn);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, SHOW_VERBOSE);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_NOPROGRESS, SHOW_PROGRESS?0:1);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSFUNCTION, prog_cb);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_LIMIT, 1);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_TIME, 30);
|
||||
|
||||
MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
|
||||
rc =curl_multi_add_handle(g->multi, conn->easy);
|
||||
mcode_or_die("new_conn: curl_multi_add_handle", rc);
|
||||
g->requested++;
|
||||
do {
|
||||
rc = curl_multi_socket_all(g->multi, &g->still_running);
|
||||
} while (CURLM_CALL_MULTI_PERFORM == rc);
|
||||
mcode_or_die("new_conn: curl_multi_socket_all", rc);
|
||||
check_run_count(g);
|
||||
}
|
||||
|
||||
|
||||
/* This gets called by glib whenever data is received from the fifo */
|
||||
static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data)
|
||||
{
|
||||
#define BUF_SIZE 1024
|
||||
gsize len, tp;
|
||||
gchar *buf, *tmp, *all=NULL;
|
||||
GIOStatus rv;
|
||||
|
||||
do {
|
||||
GError *err=NULL;
|
||||
rv = g_io_channel_read_line (ch,&buf,&len,&tp,&err);
|
||||
if ( buf ) {
|
||||
if (tp) { buf[tp]='\0'; }
|
||||
new_conn(buf,(GlobalInfo*)data);
|
||||
g_free(buf);
|
||||
} else {
|
||||
buf = g_malloc(BUF_SIZE+1);
|
||||
while (TRUE) {
|
||||
buf[BUF_SIZE]='\0';
|
||||
g_io_channel_read_chars(ch,buf,BUF_SIZE,&len,&err);
|
||||
if (len) {
|
||||
buf[len]='\0';
|
||||
if (all) {
|
||||
tmp=all;
|
||||
all=g_strdup_printf("%s%s", tmp, buf);
|
||||
g_free(tmp);
|
||||
} else {
|
||||
all = g_strdup(buf);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (all) {
|
||||
new_conn(all,(GlobalInfo*)data);
|
||||
g_free(all);
|
||||
}
|
||||
g_free(buf);
|
||||
}
|
||||
if ( err ) {
|
||||
g_error("fifo_cb: %s", err->message);
|
||||
g_free(err);
|
||||
break;
|
||||
}
|
||||
} while ( (len) && (rv == G_IO_STATUS_NORMAL) );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int init_fifo(void)
|
||||
{
|
||||
struct stat st;
|
||||
char *fifo = "hiper.fifo";
|
||||
int socket;
|
||||
|
||||
if (lstat (fifo, &st) == 0) {
|
||||
if ((st.st_mode & S_IFMT) == S_IFREG) {
|
||||
errno = EEXIST;
|
||||
perror("lstat");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
unlink (fifo);
|
||||
if (mkfifo (fifo, 0600) == -1) {
|
||||
perror("mkfifo");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
socket = open (fifo, O_RDWR | O_NONBLOCK, 0);
|
||||
|
||||
if (socket == -1) {
|
||||
perror("open");
|
||||
exit (1);
|
||||
}
|
||||
MSG_OUT("Now, pipe some URL's into > %s\n", fifo);
|
||||
|
||||
return socket;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GlobalInfo *g;
|
||||
CURLMcode rc;
|
||||
GMainLoop*gmain;
|
||||
int fd;
|
||||
GIOChannel* ch;
|
||||
g=g_malloc0(sizeof(GlobalInfo));
|
||||
|
||||
fd=init_fifo();
|
||||
ch=g_io_channel_unix_new(fd);
|
||||
g_io_add_watch(ch,G_IO_IN,fifo_cb,g);
|
||||
gmain=g_main_loop_new(NULL,FALSE);
|
||||
g->multi = curl_multi_init();
|
||||
curl_multi_setopt(g->multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
|
||||
curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g);
|
||||
curl_multi_setopt(g->multi, CURLMOPT_TIMERFUNCTION, update_timeout_cb);
|
||||
curl_multi_setopt(g->multi, CURLMOPT_TIMERDATA, g);
|
||||
do {
|
||||
rc = curl_multi_socket_all(g->multi, &g->still_running);
|
||||
} while (CURLM_CALL_MULTI_PERFORM == rc);
|
||||
g_main_loop_run(gmain);
|
||||
curl_multi_cleanup(g->multi);
|
||||
return 0;
|
||||
}
|
|
@ -1,416 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: hiperfifo.c,v 1.2 2006-10-08 22:19:25 bagder Exp $
|
||||
*
|
||||
* Example application source code using the multi socket interface to
|
||||
* download many files at once.
|
||||
*
|
||||
* Written by Jeff Pohlmeyer
|
||||
|
||||
Requires libevent and a (POSIX?) system that has mkfifo().
|
||||
|
||||
This is an adaptation of libcurl's "hipev.c" and libevent's "event-test.c"
|
||||
sample programs.
|
||||
|
||||
When running, the program creates the named pipe "hiper.fifo"
|
||||
|
||||
Whenever there is input into the fifo, the program reads the input as a list
|
||||
of URL's and creates some new easy handles to fetch each URL via the
|
||||
curl_multi "hiper" API.
|
||||
|
||||
|
||||
Thus, you can try a single URL:
|
||||
% echo http://www.yahoo.com > hiper.fifo
|
||||
|
||||
Or a whole bunch of them:
|
||||
% cat my-url-list > hiper.fifo
|
||||
|
||||
The fifo buffer is handled almost instantly, so you can even add more URL's
|
||||
while the previous requests are still being downloaded.
|
||||
|
||||
Note:
|
||||
For the sake of simplicity, URL length is limited to 1023 char's !
|
||||
|
||||
This is purely a demo app, all retrieved data is simply discarded by the write
|
||||
callback.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/poll.h>
|
||||
#include <curl/curl.h>
|
||||
#include <event.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */
|
||||
|
||||
|
||||
/* Global information, common to all connections */
|
||||
typedef struct _GlobalInfo {
|
||||
struct event fifo_event;
|
||||
struct event timer_event;
|
||||
CURLM *multi;
|
||||
int prev_running;
|
||||
int still_running;
|
||||
FILE* input;
|
||||
} GlobalInfo;
|
||||
|
||||
|
||||
/* Information associated with a specific easy handle */
|
||||
typedef struct _ConnInfo {
|
||||
CURL *easy;
|
||||
char *url;
|
||||
GlobalInfo *global;
|
||||
char error[CURL_ERROR_SIZE];
|
||||
} ConnInfo;
|
||||
|
||||
|
||||
/* Information associated with a specific socket */
|
||||
typedef struct _SockInfo {
|
||||
curl_socket_t sockfd;
|
||||
CURL *easy;
|
||||
int action;
|
||||
long timeout;
|
||||
struct event ev;
|
||||
int evset;
|
||||
GlobalInfo *global;
|
||||
} SockInfo;
|
||||
|
||||
|
||||
|
||||
/* Update the event timer after curl_multi library calls */
|
||||
static void update_timeout(GlobalInfo *g)
|
||||
{
|
||||
long timeout_ms;
|
||||
struct timeval timeout;
|
||||
|
||||
curl_multi_timeout(g->multi, &timeout_ms);
|
||||
if(timeout_ms < 0)
|
||||
return;
|
||||
|
||||
timeout.tv_sec = timeout_ms/1000;
|
||||
timeout.tv_usec = (timeout_ms%1000)*1000;
|
||||
evtimer_add(&g->timer_event, &timeout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Die if we get a bad CURLMcode somewhere */
|
||||
void mcode_or_die(char *where, CURLMcode code) {
|
||||
if ( CURLM_OK != code ) {
|
||||
char *s;
|
||||
switch (code) {
|
||||
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
|
||||
case CURLM_OK: s="CURLM_OK"; break;
|
||||
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
|
||||
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
|
||||
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
|
||||
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
|
||||
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break;
|
||||
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
|
||||
case CURLM_LAST: s="CURLM_LAST"; break;
|
||||
default: s="CURLM_unknown";
|
||||
}
|
||||
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
|
||||
exit(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Check for completed transfers, and remove their easy handles */
|
||||
static void check_run_count(GlobalInfo *g)
|
||||
{
|
||||
if (g->prev_running > g->still_running) {
|
||||
char *eff_url=NULL;
|
||||
CURLMsg *msg;
|
||||
int msgs_left;
|
||||
ConnInfo *conn=NULL;
|
||||
CURL*easy;
|
||||
CURLcode res;
|
||||
|
||||
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
|
||||
/*
|
||||
I am still uncertain whether it is safe to remove an easy handle
|
||||
from inside the curl_multi_info_read loop, so here I will search
|
||||
for completed transfers in the inner "while" loop, and then remove
|
||||
them in the outer "do-while" loop...
|
||||
*/
|
||||
do {
|
||||
easy=NULL;
|
||||
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
|
||||
if (msg->msg == CURLMSG_DONE) {
|
||||
easy=msg->easy_handle;
|
||||
res=msg->data.result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (easy) {
|
||||
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
|
||||
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
|
||||
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
|
||||
curl_multi_remove_handle(g->multi, easy);
|
||||
free(conn->url);
|
||||
curl_easy_cleanup(easy);
|
||||
free(conn);
|
||||
}
|
||||
} while ( easy );
|
||||
}
|
||||
g->prev_running = g->still_running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by libevent when we get action on a multi socket */
|
||||
static void event_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
GlobalInfo *g = (GlobalInfo*) userp;
|
||||
CURLMcode rc;
|
||||
|
||||
do {
|
||||
rc = curl_multi_socket(g->multi, fd, &g->still_running);
|
||||
} while (rc == CURLM_CALL_MULTI_PERFORM);
|
||||
mcode_or_die("event_cb: curl_multi_socket", rc);
|
||||
check_run_count(g);
|
||||
if(g->still_running) {
|
||||
update_timeout(g);
|
||||
} else {
|
||||
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
|
||||
if (evtimer_pending(&g->timer_event, NULL)) {
|
||||
evtimer_del(&g->timer_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by libevent when our timeout expires */
|
||||
static void timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
(void)fd;
|
||||
(void)kind;
|
||||
GlobalInfo *g = (GlobalInfo *)userp;
|
||||
CURLMcode rc;
|
||||
|
||||
do {
|
||||
rc = curl_multi_socket(g->multi, CURL_SOCKET_TIMEOUT, &g->still_running);
|
||||
} while (rc == CURLM_CALL_MULTI_PERFORM);
|
||||
mcode_or_die("timer_cb: curl_multi_socket", rc);
|
||||
check_run_count(g);
|
||||
if ( g->still_running ) { update_timeout(g); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Clean up the SockInfo structure */
|
||||
static void remsock(SockInfo *f)
|
||||
{
|
||||
if (!f) { return; }
|
||||
if (f->evset) { event_del(&f->ev); }
|
||||
free(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Assign information to a SockInfo structure */
|
||||
static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
|
||||
{
|
||||
int kind =
|
||||
(act&CURL_POLL_IN?EV_READ:0)|(act&CURL_POLL_OUT?EV_WRITE:0)|EV_PERSIST;
|
||||
|
||||
f->sockfd = s;
|
||||
f->action = act;
|
||||
f->easy = e;
|
||||
if (f->evset) { event_del(&f->ev); }
|
||||
event_set( &f->ev, f->sockfd, kind, event_cb, g);
|
||||
f->evset=1;
|
||||
event_add(&f->ev, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize a new SockInfo structure */
|
||||
static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g) {
|
||||
SockInfo *fdp = calloc(sizeof(SockInfo), 1);
|
||||
|
||||
fdp->global = g;
|
||||
setsock(fdp, s, easy, action, g);
|
||||
curl_multi_assign(g->multi, s, fdp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CURLMOPT_SOCKETFUNCTION */
|
||||
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
||||
{
|
||||
GlobalInfo *g = (GlobalInfo*) cbp;
|
||||
SockInfo *fdp = (SockInfo*) sockp;
|
||||
char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
fprintf(MSG_OUT,
|
||||
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||
if (what == CURL_POLL_REMOVE) {
|
||||
fprintf(MSG_OUT, "\n");
|
||||
remsock(fdp);
|
||||
} else {
|
||||
if (!fdp) {
|
||||
fprintf(MSG_OUT, "Adding data: %s%s\n",
|
||||
what&CURL_POLL_IN?"READ":"",
|
||||
what&CURL_POLL_OUT?"WRITE":"" );
|
||||
addsock(s, e, what, g);
|
||||
}
|
||||
else {
|
||||
fprintf(MSG_OUT,
|
||||
"Changing action from %d to %d\n", fdp->action, what);
|
||||
setsock(fdp, s, e, what, g);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CURLOPT_WRITEFUNCTION */
|
||||
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
ConnInfo *conn = (ConnInfo*) data;
|
||||
(void)ptr;
|
||||
(void)conn;
|
||||
return realsize;
|
||||
}
|
||||
|
||||
|
||||
/* CURLOPT_PROGRESSFUNCTION */
|
||||
int prog_cb (void *p, double dltotal, double dlnow, double ult, double uln)
|
||||
{
|
||||
ConnInfo *conn = (ConnInfo *)p;
|
||||
fprintf(MSG_OUT, "Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Create a new easy handle, and add it to the global curl_multi */
|
||||
void new_conn(char *url, GlobalInfo *g ) {
|
||||
ConnInfo *conn;
|
||||
CURLMcode rc;
|
||||
|
||||
conn = calloc(1, sizeof(ConnInfo));
|
||||
memset(conn, 0, sizeof(ConnInfo));
|
||||
conn->error[0]='\0';
|
||||
|
||||
conn->easy = curl_easy_init();
|
||||
if (!conn->easy) {
|
||||
fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n");
|
||||
exit(2);
|
||||
}
|
||||
conn->global = g;
|
||||
conn->url = strdup(url);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, &conn);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, 0);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSFUNCTION, prog_cb);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
|
||||
fprintf(MSG_OUT,
|
||||
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
|
||||
rc =curl_multi_add_handle(g->multi, conn->easy);
|
||||
mcode_or_die("new_conn: curl_multi_add_handle", rc);
|
||||
do {
|
||||
rc = curl_multi_socket_all(g->multi, &g->still_running);
|
||||
} while (CURLM_CALL_MULTI_PERFORM == rc);
|
||||
mcode_or_die("new_conn: curl_multi_socket_all", rc);
|
||||
check_run_count(g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This gets called whenever data is received from the fifo */
|
||||
void fifo_cb(int fd, short event, void *arg) {
|
||||
char s[1024];
|
||||
long int rv=0;
|
||||
int n=0;
|
||||
GlobalInfo *g = (GlobalInfo *)arg;
|
||||
|
||||
do {
|
||||
s[0]='\0';
|
||||
rv=fscanf(g->input, "%1023s%n", s, &n);
|
||||
s[n]='\0';
|
||||
if ( n && s[0] ) {
|
||||
new_conn(s,arg); /* if we read a URL, go get it! */
|
||||
} else break;
|
||||
} while ( rv != EOF);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Create a named pipe and tell libevent to monitor it */
|
||||
int init_fifo (GlobalInfo *g) {
|
||||
struct stat st;
|
||||
char *fifo = "hiper.fifo";
|
||||
int socket;
|
||||
|
||||
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
|
||||
if (lstat (fifo, &st) == 0) {
|
||||
if ((st.st_mode & S_IFMT) == S_IFREG) {
|
||||
errno = EEXIST;
|
||||
perror("lstat");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
unlink(fifo);
|
||||
if (mkfifo (fifo, 0600) == -1) {
|
||||
perror("mkfifo");
|
||||
exit (1);
|
||||
}
|
||||
socket = open(fifo, O_RDWR | O_NONBLOCK, 0);
|
||||
if (socket == -1) {
|
||||
perror("open");
|
||||
exit (1);
|
||||
}
|
||||
g->input = fdopen(socket, "r");
|
||||
|
||||
fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo);
|
||||
event_set(&g->fifo_event, socket, EV_READ | EV_PERSIST, fifo_cb, g);
|
||||
event_add(&g->fifo_event, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GlobalInfo g;
|
||||
CURLMcode rc;
|
||||
|
||||
memset(&g, 0, sizeof(GlobalInfo));
|
||||
event_init();
|
||||
init_fifo(&g);
|
||||
g.multi = curl_multi_init();
|
||||
evtimer_set(&g.timer_event, timer_cb, &g);
|
||||
curl_multi_setopt(g.multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
|
||||
curl_multi_setopt(g.multi, CURLMOPT_SOCKETDATA, &g);
|
||||
do {
|
||||
rc = curl_multi_socket_all(g.multi, &g.still_running);
|
||||
} while (CURLM_CALL_MULTI_PERFORM == rc);
|
||||
update_timeout(&g);
|
||||
event_dispatch();
|
||||
curl_multi_cleanup(g.multi);
|
||||
return 0;
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: htmltidy.c,v 1.1 2005/02/02 19:25:37 bagder Exp $
|
||||
*
|
||||
* Download a document and use libtidy to parse the HTML.
|
||||
* Written by Jeff Pohlmeyer
|
||||
*
|
||||
* LibTidy => http://tidy.sourceforge.net
|
||||
*
|
||||
* gcc -Wall -I/usr/local/include tidycurl.c -lcurl -ltidy -o tidycurl
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tidy/tidy.h>
|
||||
#include <tidy/buffio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* curl write callback, to fill tidy's input buffer... */
|
||||
uint write_cb(char *in, uint size, uint nmemb, TidyBuffer *out)
|
||||
{
|
||||
uint r;
|
||||
r = size * nmemb;
|
||||
tidyBufAppend( out, in, r );
|
||||
return(r);
|
||||
}
|
||||
|
||||
/* Traverse the document tree */
|
||||
void dumpNode(TidyDoc doc, TidyNode tnod, int indent )
|
||||
{
|
||||
TidyNode child;
|
||||
for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) )
|
||||
{
|
||||
ctmbstr name = tidyNodeGetName( child );
|
||||
if ( name )
|
||||
{
|
||||
/* if it has a name, then it's an HTML tag ... */
|
||||
TidyAttr attr;
|
||||
printf( "%*.*s%s ", indent, indent, "<", name);
|
||||
/* walk the attribute list */
|
||||
for ( attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) {
|
||||
printf(tidyAttrName(attr));
|
||||
tidyAttrValue(attr)?printf("=\"%s\" ",
|
||||
tidyAttrValue(attr)):printf(" ");
|
||||
}
|
||||
printf( ">\n");
|
||||
}
|
||||
else {
|
||||
/* if it doesn't have a name, then it's probably text, cdata, etc... */
|
||||
TidyBuffer buf;
|
||||
tidyBufInit(&buf);
|
||||
tidyNodeGetText(doc, child, &buf);
|
||||
printf("%*.*s\n", indent, indent, buf.bp?(char *)buf.bp:"");
|
||||
tidyBufFree(&buf);
|
||||
}
|
||||
dumpNode( doc, child, indent + 4 ); /* recursive */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv )
|
||||
{
|
||||
CURL *curl;
|
||||
char curl_errbuf[CURL_ERROR_SIZE];
|
||||
TidyDoc tdoc;
|
||||
TidyBuffer docbuf = {0};
|
||||
TidyBuffer tidy_errbuf = {0};
|
||||
int err;
|
||||
if ( argc == 2) {
|
||||
curl = curl_easy_init();
|
||||
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, no);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, yes);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
|
||||
|
||||
tdoc = tidyCreate();
|
||||
tidyOptSetBool(tdoc, TidyForceOutput, yes); /* try harder */
|
||||
tidyOptSetInt(tdoc, TidyWrapLen, 4096);
|
||||
tidySetErrorBuffer( tdoc, &tidy_errbuf );
|
||||
tidyBufInit(&docbuf);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf);
|
||||
err=curl_easy_perform(curl);
|
||||
if ( !err ) {
|
||||
err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */
|
||||
if ( err >= 0 ) {
|
||||
err = tidyCleanAndRepair(tdoc); /* fix any problems */
|
||||
if ( err >= 0 ) {
|
||||
err = tidyRunDiagnostics(tdoc); /* load tidy error buffer */
|
||||
if ( err >= 0 ) {
|
||||
dumpNode( tdoc, tidyGetRoot(tdoc), 0 ); /* walk the tree */
|
||||
fprintf(stderr, "%s\n", tidy_errbuf.bp); /* show errors */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "%s\n", curl_errbuf);
|
||||
|
||||
/* clean-up */
|
||||
curl_easy_cleanup(curl);
|
||||
tidyBufFree(&docbuf);
|
||||
tidyBufFree(&tidy_errbuf);
|
||||
tidyRelease(tdoc);
|
||||
return(err);
|
||||
|
||||
}
|
||||
else
|
||||
printf( "usage: %s <url>\n", argv[0] );
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -1,301 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: htmltitle.cc,v 1.3 2005/02/09 15:15:01 giva Exp $
|
||||
*/
|
||||
|
||||
// Get a web page, parse it with libxml.
|
||||
//
|
||||
// Written by Lars Nilsson
|
||||
//
|
||||
// GNU C++ compile command line suggestion (edit paths accordingly):
|
||||
//
|
||||
// g++ -Wall -I/opt/curl/include -I/opt/libxml/include/libxml2 htmltitle.cc \
|
||||
// -o htmltitle -L/opt/curl/lib -L/opt/libxml/lib -lcurl -lxml2
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <curl/curl.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
|
||||
//
|
||||
// Case-insensitive string comparison
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define COMPARE(a, b) (!stricmp((a), (b)))
|
||||
#else
|
||||
#define COMPARE(a, b) (!strcasecmp((a), (b)))
|
||||
#endif
|
||||
|
||||
//
|
||||
// libxml callback context structure
|
||||
//
|
||||
|
||||
struct Context
|
||||
{
|
||||
Context(): addTitle(false) { }
|
||||
|
||||
bool addTitle;
|
||||
std::string title;
|
||||
};
|
||||
|
||||
//
|
||||
// libcurl variables for error strings and returned data
|
||||
|
||||
static char errorBuffer[CURL_ERROR_SIZE];
|
||||
static std::string buffer;
|
||||
|
||||
//
|
||||
// libcurl write callback function
|
||||
//
|
||||
|
||||
static int writer(char *data, size_t size, size_t nmemb,
|
||||
std::string *writerData)
|
||||
{
|
||||
if (writerData == NULL)
|
||||
return 0;
|
||||
|
||||
writerData->append(data, size*nmemb);
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
//
|
||||
// libcurl connection initialization
|
||||
//
|
||||
|
||||
static bool init(CURL *&conn, char *url)
|
||||
{
|
||||
CURLcode code;
|
||||
|
||||
conn = curl_easy_init();
|
||||
|
||||
if (conn == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to create CURL connection\n");
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
code = curl_easy_setopt(conn, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to set error buffer [%d]\n", code);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
code = curl_easy_setopt(conn, CURLOPT_URL, url);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to set URL [%s]\n", errorBuffer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
code = curl_easy_setopt(conn, CURLOPT_FOLLOWLOCATION, 1);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to set redirect option [%s]\n", errorBuffer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
code = curl_easy_setopt(conn, CURLOPT_WRITEFUNCTION, writer);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to set writer [%s]\n", errorBuffer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
code = curl_easy_setopt(conn, CURLOPT_WRITEDATA, &buffer);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to set write data [%s]\n", errorBuffer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// libxml start element callback function
|
||||
//
|
||||
|
||||
static void StartElement(void *voidContext,
|
||||
const xmlChar *name,
|
||||
const xmlChar **attributes)
|
||||
{
|
||||
Context *context = (Context *)voidContext;
|
||||
|
||||
if (COMPARE((char *)name, "TITLE"))
|
||||
{
|
||||
context->title = "";
|
||||
context->addTitle = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// libxml end element callback function
|
||||
//
|
||||
|
||||
static void EndElement(void *voidContext,
|
||||
const xmlChar *name)
|
||||
{
|
||||
Context *context = (Context *)voidContext;
|
||||
|
||||
if (COMPARE((char *)name, "TITLE"))
|
||||
context->addTitle = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Text handling helper function
|
||||
//
|
||||
|
||||
static void handleCharacters(Context *context,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
{
|
||||
if (context->addTitle)
|
||||
context->title.append((char *)chars, length);
|
||||
}
|
||||
|
||||
//
|
||||
// libxml PCDATA callback function
|
||||
//
|
||||
|
||||
static void Characters(void *voidContext,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
{
|
||||
Context *context = (Context *)voidContext;
|
||||
|
||||
handleCharacters(context, chars, length);
|
||||
}
|
||||
|
||||
//
|
||||
// libxml CDATA callback function
|
||||
//
|
||||
|
||||
static void cdata(void *voidContext,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
{
|
||||
Context *context = (Context *)voidContext;
|
||||
|
||||
handleCharacters(context, chars, length);
|
||||
}
|
||||
|
||||
//
|
||||
// libxml SAX callback structure
|
||||
//
|
||||
|
||||
static htmlSAXHandler saxHandler =
|
||||
{
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
StartElement,
|
||||
EndElement,
|
||||
NULL,
|
||||
Characters,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
cdata,
|
||||
NULL
|
||||
};
|
||||
|
||||
//
|
||||
// Parse given (assumed to be) HTML text and return the title
|
||||
//
|
||||
|
||||
static void parseHtml(const std::string &html,
|
||||
std::string &title)
|
||||
{
|
||||
htmlParserCtxtPtr ctxt;
|
||||
Context context;
|
||||
|
||||
ctxt = htmlCreatePushParserCtxt(&saxHandler, &context, "", 0, "",
|
||||
XML_CHAR_ENCODING_NONE);
|
||||
|
||||
htmlParseChunk(ctxt, html.c_str(), html.size(), 0);
|
||||
htmlParseChunk(ctxt, "", 0, 1);
|
||||
|
||||
htmlFreeParserCtxt(ctxt);
|
||||
|
||||
title = context.title;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CURL *conn = NULL;
|
||||
CURLcode code;
|
||||
std::string title;
|
||||
|
||||
// Ensure one argument is given
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <url>\n", argv[0]);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
// Initialize CURL connection
|
||||
|
||||
if (!init(conn, argv[1]))
|
||||
{
|
||||
fprintf(stderr, "Connection initializion failed\n");
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Retrieve content for the URL
|
||||
|
||||
code = curl_easy_perform(conn);
|
||||
curl_easy_cleanup(conn);
|
||||
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "Failed to get '%s' [%s]\n", argv[1], errorBuffer);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Parse the (assumed) HTML code
|
||||
|
||||
parseHtml(buffer, title);
|
||||
|
||||
// Display the extracted title
|
||||
|
||||
printf("Title: %s\n", title.c_str());
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: http-post.c,v 1.2 2004/11/22 14:41:36 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* First set the URL that is about to receive our POST. This URL can
|
||||
just as well be a https:// URL if that is what should receive the
|
||||
data. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi");
|
||||
/* Now specify the POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: httpput.c,v 1.8 2006-06-30 10:26:26 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* This example shows a HTTP PUT operation. PUTs a file given as a command
|
||||
* line argument to the URL also given on the command line.
|
||||
*
|
||||
* This example also uses its own read callback.
|
||||
*
|
||||
* Here's an article on how to setup a PUT handler for Apache:
|
||||
* http://www.apacheweek.com/features/put
|
||||
*/
|
||||
|
||||
size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
size_t retcode;
|
||||
|
||||
/* in real-world cases, this would probably get this data differently
|
||||
as this fread() stuff is exactly what the library already would do
|
||||
by default internally */
|
||||
retcode = fread(ptr, size, nmemb, stream);
|
||||
|
||||
fprintf(stderr, "*** We read %d bytes from file\n", retcode);
|
||||
|
||||
return retcode;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE * hd_src ;
|
||||
int hd ;
|
||||
struct stat file_info;
|
||||
|
||||
char *file;
|
||||
char *url;
|
||||
|
||||
if(argc < 3)
|
||||
return 1;
|
||||
|
||||
file= argv[1];
|
||||
url = argv[2];
|
||||
|
||||
/* get the file size of the local file */
|
||||
hd = open(file, O_RDONLY) ;
|
||||
fstat(hd, &file_info);
|
||||
close(hd) ;
|
||||
|
||||
/* get a FILE * of the same file, could also be made with
|
||||
fdopen() from the previous descriptor, but hey this is just
|
||||
an example! */
|
||||
hd_src = fopen(file, "rb");
|
||||
|
||||
/* In windows, this will init the winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* enable uploading */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
||||
|
||||
/* HTTP PUT please */
|
||||
curl_easy_setopt(curl, CURLOPT_PUT, TRUE);
|
||||
|
||||
/* specify target URL, and note that this URL should include a file
|
||||
name, not only a directory */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, url);
|
||||
|
||||
/* now specify which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
/* provide the size of the upload, we specicially typecast the value
|
||||
to curl_off_t since we must be sure to use the correct data size */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
(curl_off_t)file_info.st_size);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
fclose(hd_src); /* close the local file */
|
||||
|
||||
curl_global_cleanup();
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: https.c,v 1.2 2004/11/24 16:11:35 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://sourceforge.net/");
|
||||
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
/*
|
||||
* If you want to connect to a site who isn't using a certificate that is
|
||||
* signed by one of the certs in the CA bundle you have, you can skip the
|
||||
* verification of the server's certificate. This makes the connection
|
||||
* A LOT LESS SECURE.
|
||||
*
|
||||
* If you have a CA cert for the server stored someplace else than in the
|
||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||
* you.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
#endif
|
||||
|
||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||
/*
|
||||
* If the site you're connecting to uses a different host name that what
|
||||
* they have mentioned in their server certificate's commonName (or
|
||||
* subjectAltName) fields, libcurl will refuse to connect. You can skip
|
||||
* this check, but this will make the connection less secure.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
#endif
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#
|
||||
# Adapted for djgpp / Watt-32 / DOS by
|
||||
# Gisle Vanem <giva@bgnett.no>
|
||||
#
|
||||
|
||||
include ../../packages/DOS/common.dj
|
||||
|
||||
CFLAGS += -I../../include -DFALSE=0 -DTRUE=1
|
||||
|
||||
LIBS = ../../lib/libcurl.a
|
||||
|
||||
ifeq ($(USE_SSL),1)
|
||||
LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a
|
||||
endif
|
||||
|
||||
LIBS += $(WATT32_ROOT)/lib/libwatt.a $(ZLIB_ROOT)/libz.a
|
||||
|
||||
CSOURCES = fopen.c ftpget.c ftpgetresp.c ftpupload.c getinmemory.c \
|
||||
http-post.c httpput.c multi-app.c multi-double.c multi-post.c \
|
||||
multi-single.c persistant.c post-callback.c postit2.c \
|
||||
sepheaders.c simple.c simplessl.c https.c ftp3rdparty.c \
|
||||
getinfo.c anyauthput.c cookie_interface.c 10-at-a-time.c
|
||||
|
||||
PROGRAMS = $(CSOURCES:.c=.exe)
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
%.exe: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
@echo
|
||||
|
||||
clean:
|
||||
rm -f $(PROGRAMS)
|
||||
|
||||
# DO NOT DELETE THIS LINE
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multi-app.c,v 1.7 2006-10-13 14:01:19 bagder Exp $
|
||||
*
|
||||
* This is an example application source code using the multi interface.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* somewhat unix-specific */
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* Download a HTTP file and upload an FTP file simultaneously.
|
||||
*/
|
||||
|
||||
#define HANDLECOUNT 2 /* Number of simultaneous transfers */
|
||||
#define HTTP_HANDLE 0 /* Index for the HTTP transfer */
|
||||
#define FTP_HANDLE 1 /* Index for the FTP transfer */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *handles[HANDLECOUNT];
|
||||
CURLM *multi_handle;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
int i;
|
||||
|
||||
CURLMsg *msg; /* for picking up messages with the transfer status */
|
||||
int msgs_left; /* how many messages are left */
|
||||
|
||||
/* Allocate one CURL handle per transfer */
|
||||
for (i=0; i<HANDLECOUNT; i++)
|
||||
handles[i] = curl_easy_init();
|
||||
|
||||
/* set the options (I left out a few, you'll get the point anyway) */
|
||||
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://website.com");
|
||||
|
||||
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://ftpsite.com");
|
||||
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_UPLOAD, TRUE);
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
/* add the individual transfers */
|
||||
for (i=0; i<HANDLECOUNT; i++)
|
||||
curl_multi_add_handle(multi_handle, handles[i]);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1 so
|
||||
that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
case 0:
|
||||
/* timeout, do something else */
|
||||
break;
|
||||
default:
|
||||
/* one or more of curl's file descriptors say there's data to read
|
||||
or write */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* See how the transfers went */
|
||||
while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
|
||||
if (msg->msg == CURLMSG_DONE) {
|
||||
|
||||
int idx, found = 0;
|
||||
|
||||
/* Find out which handle this message is about */
|
||||
for (idx=0; (!found && (idx<HANDLECOUNT)); idx++) found = (msg->easy_handle == handles[idx]);
|
||||
|
||||
switch (idx) {
|
||||
case HTTP_HANDLE:
|
||||
printf("HTTP transfer completed with status %d\n", msg->data.result);
|
||||
break;
|
||||
case FTP_HANDLE:
|
||||
printf("FTP transfer completed with status %d\n", msg->data.result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
/* Free the CURL handles */
|
||||
for (i=0; i<HANDLECOUNT; i++)
|
||||
curl_easy_cleanup(handles[i]);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multi-debugcallback.c,v 1.2 2006-10-13 14:01:19 bagder Exp $
|
||||
*
|
||||
* This is a very simple example using the multi interface and the debug
|
||||
* callback.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* somewhat unix-specific */
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
|
||||
typedef char bool;
|
||||
#define TRUE 1
|
||||
|
||||
static
|
||||
void dump(const char *text,
|
||||
FILE *stream, unsigned char *ptr, size_t size,
|
||||
bool nohex)
|
||||
{
|
||||
size_t i;
|
||||
size_t c;
|
||||
|
||||
unsigned int width=0x10;
|
||||
|
||||
if(nohex)
|
||||
/* without the hex output, we can fit more on screen */
|
||||
width = 0x40;
|
||||
|
||||
fprintf(stream, "%s, %zd bytes (0x%zx)\n", text, size, size);
|
||||
|
||||
for(i=0; i<size; i+= width) {
|
||||
|
||||
fprintf(stream, "%04zx: ", i);
|
||||
|
||||
if(!nohex) {
|
||||
/* hex not disabled, show it */
|
||||
for(c = 0; c < width; c++)
|
||||
if(i+c < size)
|
||||
fprintf(stream, "%02x ", ptr[i+c]);
|
||||
else
|
||||
fputs(" ", stream);
|
||||
}
|
||||
|
||||
for(c = 0; (c < width) && (i+c < size); c++) {
|
||||
/* check for 0D0A; if found, skip past and start a new line of output */
|
||||
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
|
||||
i+=(c+2-width);
|
||||
break;
|
||||
}
|
||||
fprintf(stream, "%c",
|
||||
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
|
||||
/* check again for 0D0A, to avoid an extra \n if it's at width */
|
||||
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
|
||||
i+=(c+3-width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fputc('\n', stream); /* newline */
|
||||
}
|
||||
fflush(stream);
|
||||
}
|
||||
|
||||
static
|
||||
int my_trace(CURL *handle, curl_infotype type,
|
||||
unsigned char *data, size_t size,
|
||||
void *userp)
|
||||
{
|
||||
const char *text;
|
||||
|
||||
(void)handle; /* prevent compiler warning */
|
||||
|
||||
switch (type) {
|
||||
case CURLINFO_TEXT:
|
||||
fprintf(stderr, "== Info: %s", data);
|
||||
default: /* in case a new one is introduced to shock us */
|
||||
return 0;
|
||||
|
||||
case CURLINFO_HEADER_OUT:
|
||||
text = "=> Send header";
|
||||
break;
|
||||
case CURLINFO_DATA_OUT:
|
||||
text = "=> Send data";
|
||||
break;
|
||||
case CURLINFO_HEADER_IN:
|
||||
text = "<= Recv header";
|
||||
break;
|
||||
case CURLINFO_DATA_IN:
|
||||
text = "<= Recv data";
|
||||
break;
|
||||
}
|
||||
|
||||
dump(text, stderr, data, size, TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simply download a HTTP file.
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *http_handle;
|
||||
CURLM *multi_handle;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
|
||||
http_handle = curl_easy_init();
|
||||
|
||||
/* set the options (I left out a few, you'll get the point anyway) */
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.haxx.se/");
|
||||
|
||||
curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||
curl_easy_setopt(http_handle, CURLOPT_VERBOSE, TRUE);
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
/* add the individual transfers */
|
||||
curl_multi_add_handle(multi_handle, http_handle);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1
|
||||
so that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
still_running = 0;
|
||||
printf("select() returns error, this is badness\n");
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
curl_easy_cleanup(http_handle);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multi-double.c,v 1.4 2006-10-13 14:01:19 bagder Exp $
|
||||
*
|
||||
* This is a very simple example using the multi interface.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* somewhat unix-specific */
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* Simply download two HTTP files!
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *http_handle;
|
||||
CURL *http_handle2;
|
||||
CURLM *multi_handle;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
|
||||
http_handle = curl_easy_init();
|
||||
http_handle2 = curl_easy_init();
|
||||
|
||||
/* set options */
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.haxx.se/");
|
||||
|
||||
/* set options */
|
||||
curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
/* add the individual transfers */
|
||||
curl_multi_add_handle(multi_handle, http_handle);
|
||||
curl_multi_add_handle(multi_handle, http_handle2);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1 so
|
||||
that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
curl_easy_cleanup(http_handle);
|
||||
curl_easy_cleanup(http_handle2);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multi-post.c,v 1.4 2006-10-13 14:01:19 bagder Exp $
|
||||
*
|
||||
* This is an example application source code using the multi interface
|
||||
* to do a multipart formpost without "blocking".
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
CURLM *multi_handle;
|
||||
int still_running;
|
||||
|
||||
struct curl_httppost *formpost=NULL;
|
||||
struct curl_httppost *lastptr=NULL;
|
||||
struct curl_slist *headerlist=NULL;
|
||||
char buf[] = "Expect:";
|
||||
|
||||
/* Fill in the file upload field. This makes libcurl load data from
|
||||
the given file name when curl_easy_perform() is called. */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "sendfile",
|
||||
CURLFORM_FILE, "postit2.c",
|
||||
CURLFORM_END);
|
||||
|
||||
/* Fill in the filename field */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "filename",
|
||||
CURLFORM_COPYCONTENTS, "postit2.c",
|
||||
CURLFORM_END);
|
||||
|
||||
/* Fill in the submit field too, even if this is rarely needed */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "submit",
|
||||
CURLFORM_COPYCONTENTS, "send",
|
||||
CURLFORM_END);
|
||||
|
||||
curl = curl_easy_init();
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
/* initalize custom header list (stating that Expect: 100-continue is not
|
||||
wanted */
|
||||
headerlist = curl_slist_append(headerlist, buf);
|
||||
if(curl && multi_handle) {
|
||||
int perform=0;
|
||||
|
||||
/* what URL that receives this POST */
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"http://www.fillinyoururl.com/upload.cgi");
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
|
||||
curl_multi_add_handle(multi_handle, curl);
|
||||
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1
|
||||
so that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
case 0:
|
||||
printf("timeout!\n");
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
printf("perform!\n");
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
printf("running: %d!\n", still_running);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
/* then cleanup the formpost chain */
|
||||
curl_formfree(formpost);
|
||||
|
||||
/* free slist */
|
||||
curl_slist_free_all (headerlist);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multi-single.c,v 1.6 2006-10-13 14:01:20 bagder Exp $
|
||||
*
|
||||
* This is a very simple example using the multi interface.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* somewhat unix-specific */
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
* Simply download a HTTP file.
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *http_handle;
|
||||
CURLM *multi_handle;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
|
||||
http_handle = curl_easy_init();
|
||||
|
||||
/* set the options (I left out a few, you'll get the point anyway) */
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.haxx.se/");
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
/* add the individual transfers */
|
||||
curl_multi_add_handle(multi_handle, http_handle);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
|
||||
while(still_running) {
|
||||
struct timeval timeout;
|
||||
int rc; /* select() return code */
|
||||
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
int maxfd;
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* In a real-world program you OF COURSE check the return code of the
|
||||
function calls, *and* you make sure that maxfd is bigger than -1 so
|
||||
that the call to select() below makes sense! */
|
||||
|
||||
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
switch(rc) {
|
||||
case -1:
|
||||
/* select error */
|
||||
still_running = 0;
|
||||
printf("select() returns error, this is badness\n");
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
/* timeout or readable/writable sockets */
|
||||
while(CURLM_CALL_MULTI_PERFORM ==
|
||||
curl_multi_perform(multi_handle, &still_running));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
curl_easy_cleanup(http_handle);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: multithread.c,v 1.2 2004/11/16 08:49:51 bagder Exp $
|
||||
*/
|
||||
|
||||
/* A multi-threaded example that uses pthreads extensively to fetch
|
||||
* X remote files at once */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/*
|
||||
List of URLs to fetch.
|
||||
|
||||
If you intend to use a SSL-based protocol here you MUST setup the OpenSSL
|
||||
callback functions as described here:
|
||||
|
||||
http://www.openssl.org/docs/crypto/threads.html#DESCRIPTION
|
||||
|
||||
*/
|
||||
char *urls[]= {
|
||||
"http://curl.haxx.se/",
|
||||
"ftp://cool.haxx.se/",
|
||||
"http://www.contactor.se/",
|
||||
"www.haxx.se"
|
||||
};
|
||||
|
||||
void *pull_one_url(void *url)
|
||||
{
|
||||
CURL *curl;
|
||||
|
||||
curl = curl_easy_init();
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_perform(curl); /* ignores error */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int pthread_create(pthread_t *new_thread_ID,
|
||||
const pthread_attr_t *attr,
|
||||
void * (*start_func)(void *), void *arg);
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pthread_t tid[4];
|
||||
int i;
|
||||
int error;
|
||||
for(i=0; i< 4; i++) {
|
||||
error = pthread_create(&tid[i],
|
||||
NULL, /* default attributes please */
|
||||
pull_one_url,
|
||||
urls[i]);
|
||||
if(0 != error)
|
||||
fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
|
||||
else
|
||||
fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]);
|
||||
}
|
||||
|
||||
/* now wait for all threads to terminate */
|
||||
for(i=0; i< 4; i++) {
|
||||
error = pthread_join(tid[i], NULL);
|
||||
fprintf(stderr, "Thread %d terminated\n", i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: opensslthreadlock.c,v 1.1 2005/05/09 21:12:03 bagder Exp $
|
||||
*
|
||||
* Example source code to show one way to set the necessary OpenSSL locking
|
||||
* callbacks if you want to do multi-threaded transfers with HTTPS/FTPS with
|
||||
* libcurl built to use OpenSSL.
|
||||
*
|
||||
* This is not a complete stand-alone example.
|
||||
*
|
||||
* Author: Jeremy Brown
|
||||
*/
|
||||
|
||||
#define MUTEX_TYPE pthread_mutex_t
|
||||
#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
|
||||
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
|
||||
#define MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
||||
#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
||||
#define THREAD_ID pthread_self( )
|
||||
|
||||
|
||||
void handle_error(const char *file, int lineno, const char *msg){
|
||||
fprintf(stderr, ** %s:%i %s\n, file, lineno, msg);
|
||||
ERR_print_errors_fp(stderr);
|
||||
/* exit(-1); */
|
||||
}
|
||||
|
||||
/* This array will store all of the mutexes available to OpenSSL. */
|
||||
static MUTEX_TYPE *mutex_buf= NULL;
|
||||
|
||||
|
||||
static void locking_function(int mode, int n, const char * file, int line)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
MUTEX_LOCK(mutex_buf[n]);
|
||||
else
|
||||
MUTEX_UNLOCK(mutex_buf[n]);
|
||||
}
|
||||
|
||||
static unsigned long id_function(void)
|
||||
{
|
||||
return ((unsigned long)THREAD_ID);
|
||||
}
|
||||
|
||||
int thread_setup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
mutex_buf = (MUTEX_TYPE *)malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE));
|
||||
if (!mutex_buf)
|
||||
return 0;
|
||||
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
||||
MUTEX_SETUP(mutex_buf[i]);
|
||||
CRYPTO_set_id_callback(id_function);
|
||||
CRYPTO_set_locking_callback(locking_function);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int thread_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!mutex_buf)
|
||||
return 0;
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
||||
MUTEX_CLEANUP(mutex_buf[i]);
|
||||
free(mutex_buf);
|
||||
mutex_buf = NULL;
|
||||
return 1;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: persistant.c,v 1.3 2004/11/24 16:11:35 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
||||
|
||||
/* get the first document */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://curl.haxx.se/");
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* get another document from the same server using the same
|
||||
connection */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://curl.haxx.se/docs/");
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: post-callback.c,v 1.5 2005/12/14 13:10:14 bagder Exp $
|
||||
*
|
||||
* An example source code that issues a HTTP POST and we provide the actual
|
||||
* data through a read callback.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
char data[]="this is what we post to the silly web server";
|
||||
|
||||
struct WriteThis {
|
||||
char *readptr;
|
||||
int sizeleft;
|
||||
};
|
||||
|
||||
size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||
|
||||
if(size*nmemb < 1)
|
||||
return 0;
|
||||
|
||||
if(pooh->sizeleft) {
|
||||
*(char *)ptr = pooh->readptr[0]; /* copy one single byte */
|
||||
pooh->readptr++; /* advance pointer */
|
||||
pooh->sizeleft--; /* less data left */
|
||||
return 1; /* we return 1 byte at a time! */
|
||||
}
|
||||
|
||||
return -1; /* no more data left to deliver */
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
struct WriteThis pooh;
|
||||
|
||||
pooh.readptr = data;
|
||||
pooh.sizeleft = strlen(data);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"http://receivingsite.com.pooh/index.cgi");
|
||||
/* Now specify we want to POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, TRUE);
|
||||
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* pointer to pass to our read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &pooh);
|
||||
|
||||
/* get verbose debug output please */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
|
||||
/*
|
||||
If you use POST to a HTTP 1.1 server, you can send data without knowing
|
||||
the size before starting the POST if you use chunked encoding. You
|
||||
enable this by adding a header like "Transfer-Encoding: chunked" with
|
||||
CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you must
|
||||
specify the size in the request.
|
||||
*/
|
||||
#ifdef USE_CHUNKED
|
||||
{
|
||||
curl_slist *chunk = NULL;
|
||||
|
||||
chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked");
|
||||
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
|
||||
/* use curl_slist_free_all() after the *perform() call to free this
|
||||
list again */
|
||||
}
|
||||
#else
|
||||
/* Set the expected POST size. If you want to POST large amounts of data,
|
||||
consider CURLOPT_POSTFIELDSIZE_LARGE */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft);
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_EXPECT
|
||||
/*
|
||||
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue"
|
||||
header. You can disable this header with CURLOPT_HTTPHEADER as usual.
|
||||
NOTE: if you want chunked transfer too, you need to combine these two
|
||||
since you can only set one list of headers with CURLOPT_HTTPHEADER. */
|
||||
|
||||
/* A less good option would be to enforce HTTP 1.0, but that might also
|
||||
have other implications. */
|
||||
{
|
||||
curl_slist *chunk = NULL;
|
||||
|
||||
chunk = curl_slist_append(chunk, "Expect:");
|
||||
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
|
||||
/* use curl_slist_free_all() after the *perform() call to free this
|
||||
list again */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: postit2.c,v 1.4 2004/08/23 14:22:52 bagder Exp $
|
||||
*
|
||||
* Example code that uploads a file name 'foo' to a remote script that accepts
|
||||
* "HTML form based" (as described in RFC1738) uploads using HTTP POST.
|
||||
*
|
||||
* The imaginary form we'll fill in looks like:
|
||||
*
|
||||
* <form method="post" enctype="multipart/form-data" action="examplepost.cgi">
|
||||
* Enter file: <input type="file" name="sendfile" size="40">
|
||||
* Enter file name: <input type="text" name="filename" size="30">
|
||||
* <input type="submit" value="send" name="submit">
|
||||
* </form>
|
||||
*
|
||||
* This exact source code has not been verified to work.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
struct curl_httppost *formpost=NULL;
|
||||
struct curl_httppost *lastptr=NULL;
|
||||
struct curl_slist *headerlist=NULL;
|
||||
char buf[] = "Expect:";
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* Fill in the file upload field */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "sendfile",
|
||||
CURLFORM_FILE, "postit2.c",
|
||||
CURLFORM_END);
|
||||
|
||||
/* Fill in the filename field */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "filename",
|
||||
CURLFORM_COPYCONTENTS, "postit2.c",
|
||||
CURLFORM_END);
|
||||
|
||||
|
||||
/* Fill in the submit field too, even if this is rarely needed */
|
||||
curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "submit",
|
||||
CURLFORM_COPYCONTENTS, "send",
|
||||
CURLFORM_END);
|
||||
|
||||
curl = curl_easy_init();
|
||||
/* initalize custom header list (stating that Expect: 100-continue is not
|
||||
wanted */
|
||||
headerlist = curl_slist_append(headerlist, buf);
|
||||
if(curl) {
|
||||
/* what URL that receives this POST */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://curl.haxx.se/examplepost.cgi");
|
||||
if ( (argc == 2) && (!strcmp(argv[1], "noexpectheader")) )
|
||||
/* only disable 100-continue header if explicitly requested */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
/* then cleanup the formpost chain */
|
||||
curl_formfree(formpost);
|
||||
/* free slist */
|
||||
curl_slist_free_all (headerlist);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: sampleconv.c,v 1.1 2006-04-09 08:39:08 bagder Exp $
|
||||
*/
|
||||
/*
|
||||
This is a simple example showing how a program on a non-ASCII platform
|
||||
would invoke callbacks to do its own codeset conversions instead of
|
||||
using the built-in iconv functions in libcurl.
|
||||
|
||||
The IBM-1047 EBCDIC codeset is used for this example but the code
|
||||
would be similar for other non-ASCII codesets.
|
||||
|
||||
Three callback functions are created below:
|
||||
my_conv_from_ascii_to_ebcdic,
|
||||
my_conv_from_ebcdic_to_ascii, and
|
||||
my_conv_from_utf8_to_ebcdic
|
||||
|
||||
The "platform_xxx" calls represent platform-specific conversion routines.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length)
|
||||
{
|
||||
char *tempptrin, *tempptrout;
|
||||
size_t bytes = length;
|
||||
int rc;
|
||||
tempptrin = tempptrout = buffer;
|
||||
rc = platform_a2e(&tempptrin, &bytes, &tempptrout, &bytes);
|
||||
if (rc == PLATFORM_CONV_OK) {
|
||||
return(CURLE_OK);
|
||||
} else {
|
||||
return(CURLE_CONV_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length)
|
||||
{
|
||||
char *tempptrin, *tempptrout;
|
||||
size_t bytes = length;
|
||||
int rc;
|
||||
tempptrin = tempptrout = buffer;
|
||||
rc = platform_e2a(&tempptrin, &bytes, &tempptrout, &bytes);
|
||||
if (rc == PLATFORM_CONV_OK) {
|
||||
return(CURLE_OK);
|
||||
} else {
|
||||
return(CURLE_CONV_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length)
|
||||
{
|
||||
char *tempptrin, *tempptrout;
|
||||
size_t bytes = length;
|
||||
int rc;
|
||||
tempptrin = tempptrout = buffer;
|
||||
rc = platform_u2e(&tempptrin, &bytes, &tempptrout, &bytes);
|
||||
if (rc == PLATFORM_CONV_OK) {
|
||||
return(CURLE_OK);
|
||||
} else {
|
||||
return(CURLE_CONV_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
|
||||
|
||||
/* use platform-specific functions for codeset conversions */
|
||||
curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION,
|
||||
my_conv_from_ascii_to_ebcdic);
|
||||
curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION,
|
||||
my_conv_from_ebcdic_to_ascii);
|
||||
curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
|
||||
my_conv_from_utf8_to_ebcdic);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: sepheaders.c,v 1.6 2003/11/19 08:21:34 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
int written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
return written;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl_handle;
|
||||
char *headerfilename = "head.out";
|
||||
FILE *headerfile;
|
||||
char *bodyfilename = "body.out";
|
||||
FILE *bodyfile;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* init the curl session */
|
||||
curl_handle = curl_easy_init();
|
||||
|
||||
/* set URL to get */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://curl.haxx.se");
|
||||
|
||||
/* no progress meter please */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
|
||||
|
||||
/* shut up completely */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_MUTE, 1);
|
||||
|
||||
/* send all data to this function */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
|
||||
|
||||
/* open the files */
|
||||
headerfile = fopen(headerfilename,"w");
|
||||
if (headerfile == NULL) {
|
||||
curl_easy_cleanup(curl_handle);
|
||||
return -1;
|
||||
}
|
||||
bodyfile = fopen(bodyfilename,"w");
|
||||
if (bodyfile == NULL) {
|
||||
curl_easy_cleanup(curl_handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we want the headers to this file handle */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER ,headerfile);
|
||||
|
||||
/*
|
||||
* Notice here that if you want the actual data sent anywhere else but
|
||||
* stdout, you should consider using the CURLOPT_WRITEDATA option. */
|
||||
|
||||
/* get it! */
|
||||
curl_easy_perform(curl_handle);
|
||||
|
||||
/* close the header file */
|
||||
fclose(headerfile);
|
||||
|
||||
/* cleanup curl stuff */
|
||||
curl_easy_cleanup(curl_handle);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: simple.c,v 1.6 2004/08/23 14:22:52 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: simplepost.c,v 1.2 2004/11/24 16:11:35 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
char *postthis="moo mooo moo moo";
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://posthere.com");
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
|
||||
|
||||
/* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
|
||||
itself */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postthis));
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: simplessl.c,v 1.6 2004/08/12 07:01:20 bagder Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
|
||||
/* some requirements for this to work:
|
||||
1. set pCertFile to the file with the client certificate
|
||||
2. if the key is passphrase protected, set pPassphrase to the
|
||||
passphrase you use
|
||||
3. if you are using a crypto engine:
|
||||
3.1. set a #define USE_ENGINE
|
||||
3.2. set pEngine to the name of the crypto engine you use
|
||||
3.3. set pKeyName to the key identifier you want to use
|
||||
4. if you don't use a crypto engine:
|
||||
4.1. set pKeyName to the file name of your client key
|
||||
4.2. if the format of the key file is DER, set pKeyType to "DER"
|
||||
|
||||
!! verify of the server certificate is not implemented here !!
|
||||
|
||||
**** This example only works with libcurl 7.9.3 and later! ****
|
||||
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *headerfile;
|
||||
|
||||
const char *pCertFile = "testcert.pem";
|
||||
const char *pCACertFile="cacert.pem";
|
||||
|
||||
const char *pKeyName;
|
||||
const char *pKeyType;
|
||||
|
||||
const char *pEngine;
|
||||
|
||||
#if USE_ENGINE
|
||||
pKeyName = "rsa_test";
|
||||
pKeyType = "ENG";
|
||||
pEngine = "chil"; /* for nChiper HSM... */
|
||||
#else
|
||||
pKeyName = "testkey.pem";
|
||||
pKeyType = "PEM";
|
||||
pEngine = NULL;
|
||||
#endif
|
||||
|
||||
const char *pPassphrase = NULL;
|
||||
|
||||
headerfile = fopen("dumpit", "w");
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* what call to write: */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
|
||||
|
||||
while(1) /* do some ugly short cut... */
|
||||
{
|
||||
if (pEngine) /* use crypto engine */
|
||||
{
|
||||
if (curl_easy_setopt(curl, CURLOPT_SSLENGINE,pEngine) != CURLE_OK)
|
||||
{ /* load the crypto engine */
|
||||
fprintf(stderr,"can't set crypto engine\n");
|
||||
break;
|
||||
}
|
||||
if (curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT,1) != CURLE_OK)
|
||||
{ /* set the crypto engine as default */
|
||||
/* only needed for the first time you load
|
||||
a engine in a curl object... */
|
||||
fprintf(stderr,"can't set crypto engine as default\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* cert is stored PEM coded in file... */
|
||||
/* since PEM is default, we needn't set it for PEM */
|
||||
curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
|
||||
|
||||
/* set the cert for client authentication */
|
||||
curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile);
|
||||
|
||||
/* sorry, for engine we must set the passphrase
|
||||
(if the key has one...) */
|
||||
if (pPassphrase)
|
||||
curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,pPassphrase);
|
||||
|
||||
/* if we use a key stored in a crypto engine,
|
||||
we must set the key type to "ENG" */
|
||||
curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType);
|
||||
|
||||
/* set the private key (file or ID in engine) */
|
||||
curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName);
|
||||
|
||||
/* set the file with the certs vaildating the server */
|
||||
curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);
|
||||
|
||||
/* disconnect if we can't validate server's cert */
|
||||
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
break; /* we are done... */
|
||||
}
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,341 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id: synctime.c,v 1.2 2006-07-05 23:10:38 yangtse Exp $
|
||||
*
|
||||
* This example code only builds as-is on Windows.
|
||||
*
|
||||
* Synchronising your computer clock via Internet time server usually relies
|
||||
* on DAYTIME, TIME, or NTP protocols. These protocols provide good accurate
|
||||
* time synchronisation but it does not work very well through a
|
||||
* firewall/proxy. Some adjustment has to be made to the firewall/proxy for
|
||||
* these protocols to work properly.
|
||||
*
|
||||
* There is an indirect method. Since most webserver provide server time in
|
||||
* their HTTP header, therefore you could synchronise your computer clock
|
||||
* using HTTP protocol which has no problem with firewall/proxy.
|
||||
*
|
||||
* For this software to work, you should take note of these items.
|
||||
* 1. Your firewall/proxy must allow your computer to surf internet.
|
||||
* 2. Webserver system time must in sync with the NTP time server,
|
||||
* or at least provide an accurate time keeping.
|
||||
* 3. Webserver HTTP header does not provide the milliseconds units,
|
||||
* so there is no way to get very accurate time.
|
||||
* 4. This software could only provide an accuracy of +- a few seconds,
|
||||
* as Round-Trip delay time is not taken into consideration.
|
||||
* Compensation of network, firewall/proxy delay cannot be simply divide
|
||||
* the Round-Trip delay time by half.
|
||||
* 5. Win32 SetSystemTime() API will set your computer clock according to
|
||||
* GMT/UTC time. Therefore your computer timezone must be properly set.
|
||||
* 6. Webserver data should not be cached by the proxy server. Some
|
||||
* webserver provide Cache-Control to prevent caching.
|
||||
*
|
||||
* References:
|
||||
* http://tf.nist.gov/timefreq/service/its.htm
|
||||
* http://tf.nist.gov/timefreq/service/firewall.htm
|
||||
*
|
||||
* Usage:
|
||||
* This software will synchronise your computer clock only when you issue
|
||||
* it with --synctime. By default, it only display the webserver's clock.
|
||||
*
|
||||
* Written by: Frank (contributed to libcurl)
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR OF THIS SOFTWARE BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#ifndef __CYGWIN__
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
||||
#define MAX_STRING 256
|
||||
#define MAX_STRING1 MAX_STRING+1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char http_proxy[MAX_STRING1];
|
||||
char proxy_user[MAX_STRING1];
|
||||
char timeserver[MAX_STRING1];
|
||||
} conf_t;
|
||||
|
||||
char DefaultTimeServer[4][MAX_STRING1] =
|
||||
{
|
||||
"http://nist.time.gov/timezone.cgi?UTC/s/0",
|
||||
"http://www.google.com/",
|
||||
"http://www.worldtimeserver.com/current_time_in_UTC.aspx",
|
||||
"http://www.worldtime.com/cgi-bin/wt.cgi"
|
||||
};
|
||||
|
||||
char *DayStr[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
char *MthStr[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
int ShowAllHeader;
|
||||
int AutoSyncTime;
|
||||
SYSTEMTIME SYSTime;
|
||||
SYSTEMTIME LOCALTime;
|
||||
|
||||
#define HTTP_COMMAND_HEAD 0
|
||||
#define HTTP_COMMAND_GET 1
|
||||
|
||||
|
||||
size_t SyncTime_CURL_WriteOutput(void *ptr, size_t size, size_t nmemb,
|
||||
void *stream)
|
||||
{
|
||||
fwrite(ptr, size, nmemb, stream);
|
||||
return(nmemb*size);
|
||||
}
|
||||
|
||||
size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
|
||||
void *stream)
|
||||
{
|
||||
int i, RetVal;
|
||||
char TmpStr1[26], TmpStr2[26];
|
||||
|
||||
if (ShowAllHeader == 1)
|
||||
fprintf(stderr, "%s", (char *)(ptr));
|
||||
|
||||
if (strncmp((char *)(ptr), "Date:", 5) == 0) {
|
||||
if (ShowAllHeader == 0)
|
||||
fprintf(stderr, "HTTP Server. %s", (char *)(ptr));
|
||||
|
||||
if (AutoSyncTime == 1) {
|
||||
*TmpStr1 = 0;
|
||||
*TmpStr2 = 0;
|
||||
if (strlen((char *)(ptr)) > 50) /* Can prevent buffer overflow to
|
||||
TmpStr1 & 2? */
|
||||
AutoSyncTime = 0;
|
||||
else {
|
||||
RetVal = sscanf ((char *)(ptr), "Date: %s %d %s %d %d:%d:%d",
|
||||
TmpStr1, &SYSTime.wDay, TmpStr2, &SYSTime.wYear,
|
||||
&SYSTime.wHour, &SYSTime.wMinute, &SYSTime.wSecond);
|
||||
|
||||
if (RetVal == 7) {
|
||||
|
||||
SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */
|
||||
for (i=0; i<12; i++) {
|
||||
if (strcmp(MthStr[i], TmpStr2) == 0) {
|
||||
SYSTime.wMonth = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AutoSyncTime = 3; /* Computer clock will be adjusted */
|
||||
}
|
||||
else {
|
||||
AutoSyncTime = 0; /* Error in sscanf() fields conversion */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp((char *)(ptr), "X-Cache: HIT", 12) == 0) {
|
||||
fprintf(stderr, "ERROR: HTTP Server data is cached."
|
||||
" Server Date is no longer valid.\n");
|
||||
AutoSyncTime = 0;
|
||||
}
|
||||
return(nmemb*size);
|
||||
}
|
||||
|
||||
void SyncTime_CURL_Init(CURL *curl, char *proxy_port,
|
||||
char *proxy_user_password)
|
||||
{
|
||||
if (strlen(proxy_port) > 0)
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, proxy_port);
|
||||
|
||||
if (strlen(proxy_user_password) > 0)
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user_password);
|
||||
|
||||
/* Trick Webserver by claiming that you are using Microsoft WinXP SP2, IE6 */
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT,
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, *SyncTime_CURL_WriteOutput);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, *SyncTime_CURL_WriteHeader);
|
||||
}
|
||||
|
||||
int SyncTime_CURL_Fetch(CURL *curl, char *URL_Str, char *OutFileName,
|
||||
int HttpGetBody)
|
||||
{
|
||||
FILE *outfile;
|
||||
CURLcode res;
|
||||
|
||||
outfile = NULL;
|
||||
if (HttpGetBody == HTTP_COMMAND_HEAD)
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
||||
else {
|
||||
outfile = fopen(OutFileName, "wb");
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL_Str);
|
||||
res = curl_easy_perform(curl);
|
||||
if (outfile != NULL)
|
||||
fclose(outfile);
|
||||
return res; /* (CURLE_OK) */
|
||||
}
|
||||
|
||||
void showUsage(void)
|
||||
{
|
||||
fprintf(stderr, "SYNCTIME: Synchronising computer clock with time server"
|
||||
" using HTTP protocol.\n");
|
||||
fprintf(stderr, "Usage : SYNCTIME [Option]\n");
|
||||
fprintf(stderr, "Options :\n");
|
||||
fprintf(stderr, " --server=WEBSERVER Use this time server instead"
|
||||
" of default.\n");
|
||||
fprintf(stderr, " --showall Show all HTTP header.\n");
|
||||
fprintf(stderr, " --synctime Synchronising computer clock"
|
||||
" with time server.\n");
|
||||
fprintf(stderr, " --proxy-user=USER[:PASS] Set proxy username and"
|
||||
" password.\n");
|
||||
fprintf(stderr, " --proxy=HOST[:PORT] Use HTTP proxy on given"
|
||||
" port.\n");
|
||||
fprintf(stderr, " --help Print this help.\n");
|
||||
fprintf(stderr, "\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int conf_init(conf_t *conf)
|
||||
{
|
||||
int i;
|
||||
|
||||
*conf->http_proxy = 0;
|
||||
for (i=0; i<MAX_STRING1; i++)
|
||||
conf->proxy_user[i] = 0; /* Clean up password from memory */
|
||||
*conf->timeserver = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CURL *curl;
|
||||
conf_t conf[1];
|
||||
int OptionIndex;
|
||||
struct tm *lt;
|
||||
struct tm *gmt;
|
||||
time_t tt;
|
||||
time_t tt_local;
|
||||
time_t tt_gmt;
|
||||
double tzonediffFloat;
|
||||
int tzonediffWord;
|
||||
char timeBuf[61];
|
||||
char tzoneBuf[16];
|
||||
int RetValue;
|
||||
|
||||
OptionIndex = 0;
|
||||
ShowAllHeader = 0; /* Do not show HTTP Header */
|
||||
AutoSyncTime = 0; /* Do not synchronise computer clock */
|
||||
RetValue = 0; /* Successful Exit */
|
||||
conf_init(conf);
|
||||
|
||||
if (argc > 1) {
|
||||
while (OptionIndex < argc) {
|
||||
if (strncmp(argv[OptionIndex], "--server=", 9) == 0)
|
||||
snprintf(conf->timeserver, MAX_STRING, "%s", &argv[OptionIndex][9]);
|
||||
|
||||
if (strcmp(argv[OptionIndex], "--showall") == 0)
|
||||
ShowAllHeader = 1;
|
||||
|
||||
if (strcmp(argv[OptionIndex], "--synctime") == 0)
|
||||
AutoSyncTime = 1;
|
||||
|
||||
if (strncmp(argv[OptionIndex], "--proxy-user=", 13) == 0)
|
||||
snprintf(conf->proxy_user, MAX_STRING, "%s", &argv[OptionIndex][13]);
|
||||
|
||||
if (strncmp(argv[OptionIndex], "--proxy=", 8) == 0)
|
||||
snprintf(conf->http_proxy, MAX_STRING, "%s", &argv[OptionIndex][8]);
|
||||
|
||||
if ((strcmp(argv[OptionIndex], "--help") == 0) ||
|
||||
(strcmp(argv[OptionIndex], "/?") == 0)) {
|
||||
showUsage();
|
||||
return 0;
|
||||
}
|
||||
OptionIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*conf->timeserver == 0) /* Use default server for time information */
|
||||
snprintf(conf->timeserver, MAX_STRING, "%s", DefaultTimeServer[0]);
|
||||
|
||||
/* Init CURL before usage */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
SyncTime_CURL_Init(curl, conf->http_proxy, conf->proxy_user);
|
||||
|
||||
/* Calculating time diff between GMT and localtime */
|
||||
tt = time(0);
|
||||
lt = localtime(&tt);
|
||||
tt_local = mktime(lt);
|
||||
gmt = gmtime(&tt);
|
||||
tt_gmt = mktime(gmt);
|
||||
tzonediffFloat = difftime(tt_local, tt_gmt);
|
||||
tzonediffWord = (int)(tzonediffFloat/3600.0);
|
||||
|
||||
if ((double)(tzonediffWord * 3600) == tzonediffFloat)
|
||||
snprintf(tzoneBuf, 15, "%+03d'00'", tzonediffWord);
|
||||
else
|
||||
snprintf(tzoneBuf, 15, "%+03d'30'", tzonediffWord);
|
||||
|
||||
/* Get current system time and local time */
|
||||
GetSystemTime(&SYSTime);
|
||||
GetLocalTime(&LOCALTime);
|
||||
snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ",
|
||||
DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay,
|
||||
MthStr[LOCALTime.wMonth-1], LOCALTime.wYear,
|
||||
LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond,
|
||||
LOCALTime.wMilliseconds);
|
||||
fprintf(stderr, "\nBefore HTTP. Date: %s%s\n\n", timeBuf, tzoneBuf);
|
||||
|
||||
/* HTTP HEAD command to the Webserver */
|
||||
fprintf(stderr, "Fetch: %s\n", conf->timeserver);
|
||||
SyncTime_CURL_Fetch(curl, conf->timeserver, "index.htm",
|
||||
HTTP_COMMAND_HEAD);
|
||||
|
||||
GetLocalTime(&LOCALTime);
|
||||
snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ",
|
||||
DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay,
|
||||
MthStr[LOCALTime.wMonth-1], LOCALTime.wYear,
|
||||
LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond,
|
||||
LOCALTime.wMilliseconds);
|
||||
fprintf(stderr, "\nAfter HTTP. Date: %s%s\n", timeBuf, tzoneBuf);
|
||||
|
||||
if (AutoSyncTime == 3) {
|
||||
/* Synchronising computer clock */
|
||||
if (!SetSystemTime(&SYSTime)) { /* Set system time */
|
||||
fprintf(stderr, "ERROR: Unable to set system time.\n");
|
||||
RetValue = 1;
|
||||
}
|
||||
else {
|
||||
/* Successfully re-adjusted computer clock */
|
||||
GetLocalTime(&LOCALTime);
|
||||
snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ",
|
||||
DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay,
|
||||
MthStr[LOCALTime.wMonth-1], LOCALTime.wYear,
|
||||
LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond,
|
||||
LOCALTime.wMilliseconds);
|
||||
fprintf(stderr, "\nNew System's Date: %s%s\n", timeBuf, tzoneBuf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Cleanup before exit */
|
||||
conf_init(conf);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
return RetValue;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>Index to Curl documentation</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 align="center">Index to Curl documentation</h1>
|
||||
|
||||
<h2>Programs</h2>
|
||||
<a href="curl-config.html">curl-config</A>
|
||||
<br><a href="curl.html">curl</A>
|
||||
|
||||
<h2>Tutorial</h2>
|
||||
<a href="TheArtOfHttpScripting">The Art Of Scripting HTTP Requests Using Curl</a> (plain text)
|
||||
|
||||
<h2>libcurl</h2>
|
||||
See the <a href="libcurl/index.html">libcurl section</a>
|
||||
|
||||
</body></html>
|
|
@ -1,78 +0,0 @@
|
|||
#
|
||||
# $Id: Makefile.am,v 1.25 2006-07-26 22:19:42 bagder Exp $
|
||||
#
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
man_MANS = curl_easy_cleanup.3 curl_easy_getinfo.3 curl_easy_init.3 \
|
||||
curl_easy_perform.3 curl_easy_setopt.3 curl_easy_duphandle.3 \
|
||||
curl_formadd.3 curl_formfree.3 curl_getdate.3 curl_getenv.3 \
|
||||
curl_slist_append.3 curl_slist_free_all.3 curl_version.3 \
|
||||
curl_version_info.3 curl_escape.3 curl_unescape.3 curl_free.3 \
|
||||
curl_strequal.3 curl_mprintf.3 curl_global_init.3 curl_global_cleanup.3 \
|
||||
curl_multi_add_handle.3 curl_multi_cleanup.3 curl_multi_fdset.3 \
|
||||
curl_multi_info_read.3 curl_multi_init.3 curl_multi_perform.3 \
|
||||
curl_multi_remove_handle.3 curl_share_cleanup.3 curl_share_init.3 \
|
||||
curl_share_setopt.3 libcurl.3 libcurl-easy.3 libcurl-multi.3 \
|
||||
libcurl-share.3 libcurl-errors.3 curl_easy_strerror.3 \
|
||||
curl_multi_strerror.3 curl_share_strerror.3 curl_global_init_mem.3 \
|
||||
libcurl-tutorial.3 curl_easy_reset.3 curl_easy_escape.3 \
|
||||
curl_easy_unescape.3 curl_multi_setopt.3 curl_multi_socket.3 \
|
||||
curl_multi_timeout.3 curl_formget.3 curl_multi_assign.3
|
||||
|
||||
HTMLPAGES = curl_easy_cleanup.html curl_easy_getinfo.html \
|
||||
curl_easy_init.html curl_easy_perform.html curl_easy_setopt.html \
|
||||
curl_easy_duphandle.html curl_formadd.html curl_formfree.html \
|
||||
curl_getdate.html curl_getenv.html curl_slist_append.html \
|
||||
curl_slist_free_all.html curl_version.html curl_version_info.html \
|
||||
curl_escape.html curl_unescape.html curl_free.html curl_strequal.html \
|
||||
curl_mprintf.html curl_global_init.html curl_global_cleanup.html \
|
||||
curl_multi_add_handle.html curl_multi_cleanup.html curl_multi_fdset.html \
|
||||
curl_multi_info_read.html curl_multi_init.html curl_multi_perform.html \
|
||||
curl_multi_remove_handle.html curl_share_cleanup.html \
|
||||
curl_share_init.html curl_share_setopt.html libcurl.html \
|
||||
libcurl-multi.html libcurl-easy.html libcurl-share.html \
|
||||
libcurl-errors.html curl_easy_strerror.html curl_multi_strerror.html \
|
||||
curl_share_strerror.html curl_global_init_mem.html libcurl-tutorial.html \
|
||||
curl_easy_reset.html curl_easy_escape.html curl_easy_unescape.html \
|
||||
curl_multi_setopt.html curl_multi_socket.html curl_multi_timeout.html \
|
||||
curl_formget.html curl_multi_assign.html
|
||||
|
||||
PDFPAGES = curl_easy_cleanup.pdf curl_easy_getinfo.pdf curl_easy_init.pdf \
|
||||
curl_easy_perform.pdf curl_easy_setopt.pdf curl_easy_duphandle.pdf \
|
||||
curl_formadd.pdf curl_formfree.pdf curl_getdate.pdf curl_getenv.pdf \
|
||||
curl_slist_append.pdf curl_slist_free_all.pdf curl_version.pdf \
|
||||
curl_version_info.pdf curl_escape.pdf curl_unescape.pdf curl_free.pdf \
|
||||
curl_strequal.pdf curl_mprintf.pdf curl_global_init.pdf \
|
||||
curl_global_cleanup.pdf curl_multi_add_handle.pdf curl_multi_cleanup.pdf \
|
||||
curl_multi_fdset.pdf curl_multi_info_read.pdf curl_multi_init.pdf \
|
||||
curl_multi_perform.pdf curl_multi_remove_handle.pdf \
|
||||
curl_share_cleanup.pdf curl_share_init.pdf curl_share_setopt.pdf \
|
||||
libcurl.pdf libcurl-multi.pdf libcurl-easy.pdf libcurl-share.pdf \
|
||||
libcurl-errors.pdf curl_easy_strerror.pdf curl_multi_strerror.pdf \
|
||||
curl_share_strerror.pdf curl_global_init_mem.pdf libcurl-tutorial.pdf \
|
||||
curl_easy_reset.pdf curl_easy_escape.pdf curl_easy_unescape.pdf \
|
||||
curl_multi_setopt.pdf curl_multi_socket.pdf curl_multi_timeout.pdf \
|
||||
curl_formget.pdf curl_multi_assign.pdf
|
||||
|
||||
CLEANFILES = $(HTMLPAGES) $(PDFPAGES)
|
||||
|
||||
EXTRA_DIST = $(man_MANS) $(HTMLPAGES) index.html $(PDFPAGES) libcurl.m4
|
||||
|
||||
MAN2HTML= roffit --mandir=. < $< >$@
|
||||
|
||||
SUFFIXES = .3 .html
|
||||
|
||||
html: $(HTMLPAGES)
|
||||
|
||||
.3.html:
|
||||
$(MAN2HTML)
|
||||
|
||||
pdf: $(PDFPAGES)
|
||||
|
||||
.3.pdf:
|
||||
@(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \
|
||||
groff -Tps -man $< >$$foo.ps; \
|
||||
ps2pdf $$foo.ps $@; \
|
||||
rm $$foo.ps; \
|
||||
echo "converted $< to $@")
|
|
@ -1,31 +0,0 @@
|
|||
.\" You can view this file with:
|
||||
.\" nroff -man [file]
|
||||
.\" $Id: curl_easy_cleanup.3,v 1.6 2006-10-12 14:35:20 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_cleanup 3 "12 Oct 2006" "libcurl 7.7" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_cleanup - End a libcurl easy session
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
|
||||
.BI "void curl_easy_cleanup(CURL *" handle ");"
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function must be the last function to call for an easy session. It is the
|
||||
opposite of the \fIcurl_easy_init(3)\fP function and must be called with the
|
||||
same \fIhandle\fP as input that the curl_easy_init call returned.
|
||||
|
||||
This will effectively close all connections this handle has used and possibly
|
||||
has kept open until now. Don't call this function if you intend to transfer
|
||||
more files.
|
||||
|
||||
When you've called this, you can safely remove all the strings you've
|
||||
previously told libcurl to use, as it won't use them anymore now.
|
||||
|
||||
Any uses of the \fBhandle\fP after this function has been called are
|
||||
illegal. This kills the handle and all memory associated with it!
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_init "(3), "
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_cleanup man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_cleanup - End a libcurl easy session <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">void curl_easy_cleanup(CURL * handle );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">This function must be the last function to call for an easy session. It is the opposite of the <a class="emphasis" href="./curl_easy_init.html">curl_easy_init(3)</a> function and must be called with the same <span Class="emphasis">handle</span> as input that the curl_easy_init call returned.
|
||||
<p class="level0">This will effectively close all connections this handle has used and possibly has kept open until now. Don't call this function if you intend to transfer more files.
|
||||
<p class="level0">When you've called this, you can safely remove all the strings you've previously told libcurl to use, as it won't use them anymore now.
|
||||
<p class="level0">Any uses of the <span Class="bold">handle</span> after this function has been called are illegal. This kills the handle and all memory associated with it! <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">None <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_init.html">curl_easy_init (3)</a> <span Class="manpage"> </span>
|
||||
<p class="level0"><p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,34 +0,0 @@
|
|||
.\" You can view this file with:
|
||||
.\" nroff -man [file]
|
||||
.\" $Id: curl_easy_duphandle.3,v 1.4 2004/04/13 09:08:52 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_duphandle 3 "18 September 2001" "libcurl 7.9" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_duphandle - Clone a libcurl session handle
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
|
||||
.BI "CURL *curl_easy_duphandle(CURL *"handle ");"
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function will return a new curl handle, a duplicate, using all the
|
||||
options previously set in the input curl \fIhandle\fP. Both handles can
|
||||
subsequently be used independently and they must both be freed with
|
||||
\fIcurl_easy_cleanup(3)\fP.
|
||||
|
||||
All strings that the input handle has been told to point to (as opposed to
|
||||
copy) with previous calls to \fIcurl_easy_setopt(3)\fP using char * inputs,
|
||||
will be pointed to by the new handle as well. You must therefore make sure to
|
||||
keep the data around until both handles have been cleaned up.
|
||||
|
||||
The new handle will \fBnot\fP inherit any state information, no connections,
|
||||
no SSL sessions and no cookies.
|
||||
|
||||
\fBNote\fP that even in multi-threaded programs, this function must be called
|
||||
in a synchronous way, the input handle may not be in use when cloned.
|
||||
.SH RETURN VALUE
|
||||
If this function returns NULL, something went wrong and no valid handle was
|
||||
returned.
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_init "(3)," curl_easy_cleanup "(3)," curl_global_init "(3)
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_duphandle man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_duphandle - Clone a libcurl session handle <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">CURL *curl_easy_duphandle(CURL *handle );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">This function will return a new curl handle, a duplicate, using all the options previously set in the input curl <span Class="emphasis">handle</span>. Both handles can subsequently be used independently and they must both be freed with <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a>.
|
||||
<p class="level0">All strings that the input handle has been told to point to (as opposed to copy) with previous calls to <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a> using char * inputs, will be pointed to by the new handle as well. You must therefore make sure to keep the data around until both handles have been cleaned up.
|
||||
<p class="level0">The new handle will <span Class="bold">not</span> inherit any state information, no connections, no SSL sessions and no cookies.
|
||||
<p class="level0"><span Class="bold">Note</span> that even in multi-threaded programs, this function must be called in a synchronous way, the input handle may not be in use when cloned. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">If this function returns NULL, something went wrong and no valid handle was returned. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_init.html">curl_easy_init (3)</a> <a class="manpage" href="./curl_easy_cleanup.html"> curl_easy_cleanup (3)</a> <a class="manpage" href="./curl_global_init.html"> curl_global_init (3)</a>
|
||||
<p class="level0"><p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,47 +0,0 @@
|
|||
.\" **************************************************************************
|
||||
.\" * _ _ ____ _
|
||||
.\" * Project ___| | | | _ \| |
|
||||
.\" * / __| | | | |_) | |
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
.\" *
|
||||
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
.\" * copies of the Software, and permit persons to whom the Software is
|
||||
.\" * furnished to do so, under the terms of the COPYING file.
|
||||
.\" *
|
||||
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
.\" * KIND, either express or implied.
|
||||
.\" *
|
||||
.\" * $Id: curl_easy_escape.3,v 1.1 2006-04-07 21:50:47 bagder Exp $
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH curl_easy_escape 3 "7 April 2006" "libcurl 7.15.4" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_escape - URL encodes the given string
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
.sp
|
||||
.BI "char *curl_easy_escape( CURL *" curl ", char *" url ", int "length " );"
|
||||
.ad
|
||||
.SH DESCRIPTION
|
||||
This function converts the given input string to an URL encoded string and
|
||||
returns that as a new allocated string. All input characters that are not a-z,
|
||||
A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a
|
||||
two-digit hexadecimal number).
|
||||
|
||||
If the \fBlength\fP argument is set to 0 (zero), curl_easy_escape() uses
|
||||
strlen() on the input \fBurl\fP to find out the size.
|
||||
|
||||
You must \fIcurl_free(3)\fP the returned string when you're done with it.
|
||||
.SH AVAILABILITY
|
||||
Added in 7.15.4 and replaces the old curl_escape() function.
|
||||
.SH RETURN VALUE
|
||||
A pointer to a zero terminated string or NULL if it failed.
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_unescape "(3), " curl_free "(3), " RFC 2396
|
|
@ -1,58 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_escape man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_escape - URL encodes the given string <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">char *curl_easy_escape( CURL * curl , char * url , int length );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">This function converts the given input string to an URL encoded string and returns that as a new allocated string. All input characters that are not a-z, A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number).
|
||||
<p class="level0">If the <span Class="bold">length</span> argument is set to 0 (zero), curl_easy_escape() uses strlen() on the input <span Class="bold">url</span> to find out the size.
|
||||
<p class="level0">You must <a class="emphasis" href="./curl_free.html">curl_free(3)</a> the returned string when you're done with it. <a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
|
||||
<p class="level0">Added in 7.15.4 and replaces the old curl_escape() function. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">A pointer to a zero terminated string or NULL if it failed. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_unescape.html">curl_easy_unescape (3)</a> <a class="manpage" href="./curl_free.html"> curl_free (3)</a> <span Class="manpage"> RFC 2396</span> <p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,209 +0,0 @@
|
|||
.\" **************************************************************************
|
||||
.\" * _ _ ____ _
|
||||
.\" * Project ___| | | | _ \| |
|
||||
.\" * / __| | | | |_) | |
|
||||
.\" * | (__| |_| | _ <| |___
|
||||
.\" * \___|\___/|_| \_\_____|
|
||||
.\" *
|
||||
.\" * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
.\" *
|
||||
.\" * This software is licensed as described in the file COPYING, which
|
||||
.\" * you should have received as part of this distribution. The terms
|
||||
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
.\" *
|
||||
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
.\" * copies of the Software, and permit persons to whom the Software is
|
||||
.\" * furnished to do so, under the terms of the COPYING file.
|
||||
.\" *
|
||||
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
.\" * KIND, either express or implied.
|
||||
.\" *
|
||||
.\" * $Id: curl_easy_getinfo.3,v 1.29 2006-06-08 11:06:26 bagder Exp $
|
||||
.\" **************************************************************************
|
||||
.\"
|
||||
.TH curl_easy_getinfo 3 "21 Mar 2006" "libcurl 7.15.4" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_getinfo - extract information from a curl handle
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
|
||||
.B "CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );"
|
||||
|
||||
.SH DESCRIPTION
|
||||
Request internal information from the curl session with this function. The
|
||||
third argument \fBMUST\fP be a pointer to a long, a pointer to a char *, a
|
||||
pointer to a struct curl_slist * or a pointer to a double (as this
|
||||
documentation describes further down). The data pointed-to will be filled in
|
||||
accordingly and can be relied upon only if the function returns CURLE_OK. Use
|
||||
this function AFTER a performed transfer if you want to get transfer- oriented
|
||||
data.
|
||||
|
||||
You should not free the memory returned by this function unless it is
|
||||
explictly mentioned below.
|
||||
.SH AVAILABLE INFORMATION
|
||||
The following information can be extracted:
|
||||
.IP CURLINFO_EFFECTIVE_URL
|
||||
Pass a pointer to a 'char *' to receive the last used effective URL.
|
||||
.IP CURLINFO_RESPONSE_CODE
|
||||
Pass a pointer to a long to receive the last received HTTP or FTP code. This
|
||||
option was known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. This
|
||||
will be zero if no server response code has been received. Note that a proxy's
|
||||
CONNECT response should be read with \fICURLINFO_HTTP_CONNECTCODE\fP and not
|
||||
this.
|
||||
.IP CURLINFO_HTTP_CONNECTCODE
|
||||
Pass a pointer to a long to receive the last received proxy response code to a
|
||||
CONNECT request.
|
||||
.IP CURLINFO_FILETIME
|
||||
Pass a pointer to a long to receive the remote time of the retrieved document
|
||||
(in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If you get
|
||||
-1, it can be because of many reasons (unknown, the server hides it or the
|
||||
server doesn't support the command that tells document time etc) and the time
|
||||
of the document is unknown. Note that you must tell the server to collect this
|
||||
information before the transfer is made, by using the CURLOPT_FILETIME option
|
||||
to \fIcurl_easy_setopt(3)\fP or you will unconditionally get a -1 back. (Added
|
||||
in 7.5)
|
||||
.IP CURLINFO_TOTAL_TIME
|
||||
Pass a pointer to a double to receive the total time in seconds for the
|
||||
previous transfer, including name resolving, TCP connect etc.
|
||||
.IP CURLINFO_NAMELOOKUP_TIME
|
||||
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||
start until the name resolving was completed.
|
||||
.IP CURLINFO_CONNECT_TIME
|
||||
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||
start until the connect to the remote host (or proxy) was completed.
|
||||
.IP CURLINFO_PRETRANSFER_TIME
|
||||
Pass a pointer to a double to receive 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.
|
||||
.IP CURLINFO_STARTTRANSFER_TIME
|
||||
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||
start until the first byte is just about to be transferred. This includes
|
||||
CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate
|
||||
the result.
|
||||
.IP CURLINFO_REDIRECT_TIME
|
||||
Pass a pointer to a double to receive the total time, in seconds, it took for
|
||||
all redirection steps include name lookup, connect, pretransfer and transfer
|
||||
before final transaction was started. CURLINFO_REDIRECT_TIME contains the
|
||||
complete execution time for multiple redirections. (Added in 7.9.7)
|
||||
.IP CURLINFO_REDIRECT_COUNT
|
||||
Pass a pointer to a long to receive the total number of redirections that were
|
||||
actually followed. (Added in 7.9.7)
|
||||
.IP CURLINFO_SIZE_UPLOAD
|
||||
Pass a pointer to a double to receive the total amount of bytes that were
|
||||
uploaded.
|
||||
.IP CURLINFO_SIZE_DOWNLOAD
|
||||
Pass a pointer to a double to receive the total amount of bytes that were
|
||||
downloaded. The amount is only for the latest transfer and will be reset again
|
||||
for each new transfer.
|
||||
.IP CURLINFO_SPEED_DOWNLOAD
|
||||
Pass a pointer to a double to receive the average download speed that curl
|
||||
measured for the complete download.
|
||||
.IP CURLINFO_SPEED_UPLOAD
|
||||
Pass a pointer to a double to receive the average upload speed that curl
|
||||
measured for the complete upload.
|
||||
.IP CURLINFO_HEADER_SIZE
|
||||
Pass a pointer to a long to receive the total size of all the headers
|
||||
received.
|
||||
.IP CURLINFO_REQUEST_SIZE
|
||||
Pass a pointer to a long to receive the total size of the issued
|
||||
requests. This is so far only for HTTP requests. Note that this may be more
|
||||
than one request if FOLLOWLOCATION is true.
|
||||
.IP CURLINFO_SSL_VERIFYRESULT
|
||||
Pass a pointer to a long to receive the result of the certification
|
||||
verification that was requested (using the CURLOPT_SSL_VERIFYPEER option to
|
||||
\fIcurl_easy_setopt(3)\fP).
|
||||
.IP CURLINFO_SSL_ENGINES
|
||||
Pass the address of a 'struct curl_slist *' to receive a linked-list of
|
||||
OpenSSL crypto-engines supported. Note that engines are normally implemented
|
||||
in separate dynamic libraries. Hence not all the returned engines may be
|
||||
available at run-time. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP
|
||||
on the list pointer once you're done with it, as libcurl will not free the
|
||||
data for you. (Added in 7.12.3)
|
||||
.IP CURLINFO_CONTENT_LENGTH_DOWNLOAD
|
||||
Pass a pointer to a double to receive the content-length of the download. This
|
||||
is the value read from the Content-Length: field.
|
||||
.IP CURLINFO_CONTENT_LENGTH_UPLOAD
|
||||
Pass a pointer to a double to receive the specified size of the upload.
|
||||
.IP CURLINFO_CONTENT_TYPE
|
||||
Pass a pointer to a 'char *' to receive the content-type of the downloaded
|
||||
object. This is the value read from the Content-Type: field. If you get NULL,
|
||||
it means that the server didn't send a valid Content-Type header or that the
|
||||
protocol used doesn't support this.
|
||||
.IP CURLINFO_PRIVATE
|
||||
Pass a pointer to a 'char *' to receive the pointer to the private data
|
||||
associated with the curl handle (set with the CURLOPT_PRIVATE option to
|
||||
\fIcurl_easy_setopt(3)\fP). (Added in 7.10.3)
|
||||
.IP CURLINFO_HTTPAUTH_AVAIL
|
||||
Pass a pointer to a long to receive a bitmask indicating the authentication
|
||||
method(s) available. The meaning of the bits is explained in the
|
||||
CURLOPT_HTTPAUTH option for \fIcurl_easy_setopt(3)\fP. (Added in 7.10.8)
|
||||
.IP CURLINFO_PROXYAUTH_AVAIL
|
||||
Pass a pointer to a long to receive a bitmask indicating the authentication
|
||||
method(s) available for your proxy authentication. (Added in 7.10.8)
|
||||
.IP CURLINFO_OS_ERRNO
|
||||
Pass a pointer to a long to receive the errno variable from a connect failure.
|
||||
(Added in 7.12.2)
|
||||
.IP CURLINFO_NUM_CONNECTS
|
||||
Pass a pointer to a long to receive how many new connections libcurl had to
|
||||
create to achieve the previous transfer (only the successful connects are
|
||||
counted). Combined with \fICURLINFO_REDIRECT_COUNT\fP you are able to know
|
||||
how many times libcurl successfully reused existing connection(s) or not. See
|
||||
the Connection Options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries
|
||||
to make persistent connections to save time. (Added in 7.12.3)
|
||||
.IP CURLINFO_COOKIELIST
|
||||
Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
|
||||
cookies cURL knows (expired ones, too). Don't forget to
|
||||
\fIcurl_slist_free_all(3)\fP the list after it has been used. If there are no
|
||||
cookies (cookies for the handle have not been enabled or simply none have been
|
||||
received) 'struct curl_slist *' will be set to point to NULL. (Added in
|
||||
7.14.1)
|
||||
.IP CURLINFO_LASTSOCKET
|
||||
Pass a pointer to a long to receive the last socket used by this curl
|
||||
session. If the socket is no longer valid, -1 is returned. When you finish
|
||||
working with the socket, you must call curl_easy_cleanup() as usual and let
|
||||
libcurl close the socket and cleanup other resources associated with the
|
||||
handle. This is typically used in combination with \fICURLOPT_CONNECT_ONLY\fP.
|
||||
(Added in 7.15.2)
|
||||
.IP CURLINFO_FTP_ENTRY_PATH
|
||||
Pass a pointer to a 'char *' to receive a pointer to a string holding the path
|
||||
of the entry path. That is the initial path libcurl ended up in when logging
|
||||
on to the remote FTP server. This stores a NULL as pointer if something is
|
||||
wrong. (Added in 7.15.4)
|
||||
.SH TIMES
|
||||
.NF
|
||||
An overview of the six time values available from curl_easy_getinfo()
|
||||
|
||||
curl_easy_perform()
|
||||
|
|
||||
|--NT
|
||||
|--|--CT
|
||||
|--|--|--PT
|
||||
|--|--|--|--ST
|
||||
|--|--|--|--|--TT
|
||||
|--|--|--|--|--RT
|
||||
.FI
|
||||
.IP NT
|
||||
\fICURLINFO_NAMELOOKUP_TIME\fP. The time it took from the start until the name
|
||||
resolving was completed.
|
||||
.IP CT
|
||||
\fICURLINFO_CONNECT_TIME\fP. The time it took from the start until the connect
|
||||
to the remote host (or proxy) was completed.
|
||||
.IP PT
|
||||
\fICURLINFO_PRETRANSFER_TIME\fP. The time 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.
|
||||
.IP ST
|
||||
\fICURLINFO_STARTTRANSFER_TIME\fP. The time it took from the start until the
|
||||
first byte is just about to be transferred.
|
||||
.IP TT
|
||||
\fICURLINFO_TOTAL_TIME\fP. Total time of the previous request.
|
||||
.IP RT
|
||||
\fICURLINFO_REDIRECT_TIME\fP. The time it took for all redirection steps
|
||||
include name lookup, connect, pretransfer and transfer before final
|
||||
transaction was started. So, this is zero if no redirection took place.
|
||||
.SH RETURN VALUE
|
||||
If the operation was successful, CURLE_OK is returned. Otherwise an
|
||||
appropriate error code will be returned.
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_setopt "(3)"
|
|
@ -1,142 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_getinfo man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_getinfo - extract information from a curl handle <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">Request internal information from the curl session with this function. The third argument <span Class="bold">MUST</span> be a pointer to a long, a pointer to a char *, a pointer to a struct curl_slist * or a pointer to a double (as this documentation describes further down). The data pointed-to will be filled in accordingly and can be relied upon only if the function returns CURLE_OK. Use this function AFTER a performed transfer if you want to get transfer- oriented data.
|
||||
<p class="level0">You should not free the memory returned by this function unless it is explictly mentioned below. <a name="AVAILABLE"></a><h2 class="nroffsh">AVAILABLE INFORMATION</h2>
|
||||
<p class="level0">The following information can be extracted:
|
||||
<p class="level0"><a name="CURLINFOEFFECTIVEURL"></a><span class="nroffip">CURLINFO_EFFECTIVE_URL</span>
|
||||
<p class="level1">Pass a pointer to a 'char *' to receive the last used effective URL.
|
||||
<p class="level0"><a name="CURLINFORESPONSECODE"></a><span class="nroffip">CURLINFO_RESPONSE_CODE</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the last received HTTP or FTP code. This option was known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. This will be zero if no server response code has been received. Note that a proxy's CONNECT response should be read with <a class="emphasis" href="#CURLINFOHTTPCONNECTCODE">CURLINFO_HTTP_CONNECTCODE</a> and not this.
|
||||
<p class="level0"><a name="CURLINFOHTTPCONNECTCODE"></a><span class="nroffip">CURLINFO_HTTP_CONNECTCODE</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the last received proxy response code to a CONNECT request.
|
||||
<p class="level0"><a name="CURLINFOFILETIME"></a><span class="nroffip">CURLINFO_FILETIME</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the remote time of the retrieved document (in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If you get -1, it can be because of many reasons (unknown, the server hides it or the server doesn't support the command that tells document time etc) and the time of the document is unknown. Note that you must tell the server to collect this information before the transfer is made, by using the CURLOPT_FILETIME option to <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a> or you will unconditionally get a -1 back. (Added in 7.5)
|
||||
<p class="level0"><a name="CURLINFOTOTALTIME"></a><span class="nroffip">CURLINFO_TOTAL_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
|
||||
<p class="level0"><a name="CURLINFONAMELOOKUPTIME"></a><span class="nroffip">CURLINFO_NAMELOOKUP_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the time, in seconds, it took from the start until the name resolving was completed.
|
||||
<p class="level0"><a name="CURLINFOCONNECTTIME"></a><span class="nroffip">CURLINFO_CONNECT_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
|
||||
<p class="level0"><a name="CURLINFOPRETRANSFERTIME"></a><span class="nroffip">CURLINFO_PRETRANSFER_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive 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.
|
||||
<p class="level0"><a name="CURLINFOSTARTTRANSFERTIME"></a><span class="nroffip">CURLINFO_STARTTRANSFER_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the time, in seconds, it took from the start until the first byte is just about to be transferred. This includes CURLINFO_PRETRANSFER_TIME and also the time the server needs to calculate the result.
|
||||
<p class="level0"><a name="CURLINFOREDIRECTTIME"></a><span class="nroffip">CURLINFO_REDIRECT_TIME</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. CURLINFO_REDIRECT_TIME contains the complete execution time for multiple redirections. (Added in 7.9.7)
|
||||
<p class="level0"><a name="CURLINFOREDIRECTCOUNT"></a><span class="nroffip">CURLINFO_REDIRECT_COUNT</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the total number of redirections that were actually followed. (Added in 7.9.7)
|
||||
<p class="level0"><a name="CURLINFOSIZEUPLOAD"></a><span class="nroffip">CURLINFO_SIZE_UPLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the total amount of bytes that were uploaded.
|
||||
<p class="level0"><a name="CURLINFOSIZEDOWNLOAD"></a><span class="nroffip">CURLINFO_SIZE_DOWNLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the total amount of bytes that were downloaded. The amount is only for the latest transfer and will be reset again for each new transfer.
|
||||
<p class="level0"><a name="CURLINFOSPEEDDOWNLOAD"></a><span class="nroffip">CURLINFO_SPEED_DOWNLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the average download speed that curl measured for the complete download.
|
||||
<p class="level0"><a name="CURLINFOSPEEDUPLOAD"></a><span class="nroffip">CURLINFO_SPEED_UPLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the average upload speed that curl measured for the complete upload.
|
||||
<p class="level0"><a name="CURLINFOHEADERSIZE"></a><span class="nroffip">CURLINFO_HEADER_SIZE</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the total size of all the headers received.
|
||||
<p class="level0"><a name="CURLINFOREQUESTSIZE"></a><span class="nroffip">CURLINFO_REQUEST_SIZE</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the total size of the issued requests. This is so far only for HTTP requests. Note that this may be more than one request if FOLLOWLOCATION is true.
|
||||
<p class="level0"><a name="CURLINFOSSLVERIFYRESULT"></a><span class="nroffip">CURLINFO_SSL_VERIFYRESULT</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the result of the certification verification that was requested (using the CURLOPT_SSL_VERIFYPEER option to <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a>).
|
||||
<p class="level0"><a name="CURLINFOSSLENGINES"></a><span class="nroffip">CURLINFO_SSL_ENGINES</span>
|
||||
<p class="level1">Pass the address of a 'struct curl_slist *' to receive a linked-list of OpenSSL crypto-engines supported. Note that engines are normally implemented in separate dynamic libraries. Hence not all the returned engines may be available at run-time. <span Class="bold">NOTE:</span> you must call <a class="emphasis" href="./curl_slist_free_all.html">curl_slist_free_all(3)</a> on the list pointer once you're done with it, as libcurl will not free the data for you. (Added in 7.12.3)
|
||||
<p class="level0"><a name="CURLINFOCONTENTLENGTHDOWNLOAD"></a><span class="nroffip">CURLINFO_CONTENT_LENGTH_DOWNLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the content-length of the download. This is the value read from the Content-Length: field.
|
||||
<p class="level0"><a name="CURLINFOCONTENTLENGTHUPLOAD"></a><span class="nroffip">CURLINFO_CONTENT_LENGTH_UPLOAD</span>
|
||||
<p class="level1">Pass a pointer to a double to receive the specified size of the upload.
|
||||
<p class="level0"><a name="CURLINFOCONTENTTYPE"></a><span class="nroffip">CURLINFO_CONTENT_TYPE</span>
|
||||
<p class="level1">Pass a pointer to a 'char *' to receive the content-type of the downloaded object. This is the value read from the Content-Type: field. If you get NULL, it means that the server didn't send a valid Content-Type header or that the protocol used doesn't support this.
|
||||
<p class="level0"><a name="CURLINFOPRIVATE"></a><span class="nroffip">CURLINFO_PRIVATE</span>
|
||||
<p class="level1">Pass a pointer to a 'char *' to receive the pointer to the private data associated with the curl handle (set with the CURLOPT_PRIVATE option to <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a>). (Added in 7.10.3)
|
||||
<p class="level0"><a name="CURLINFOHTTPAUTHAVAIL"></a><span class="nroffip">CURLINFO_HTTPAUTH_AVAIL</span>
|
||||
<p class="level1">Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available. The meaning of the bits is explained in the CURLOPT_HTTPAUTH option for <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a>. (Added in 7.10.8)
|
||||
<p class="level0"><a name="CURLINFOPROXYAUTHAVAIL"></a><span class="nroffip">CURLINFO_PROXYAUTH_AVAIL</span>
|
||||
<p class="level1">Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available for your proxy authentication. (Added in 7.10.8)
|
||||
<p class="level0"><a name="CURLINFOOSERRNO"></a><span class="nroffip">CURLINFO_OS_ERRNO</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the errno variable from a connect failure. (Added in 7.12.2)
|
||||
<p class="level0"><a name="CURLINFONUMCONNECTS"></a><span class="nroffip">CURLINFO_NUM_CONNECTS</span>
|
||||
<p class="level1">Pass a pointer to a long to receive how many new connections libcurl had to create to achieve the previous transfer (only the successful connects are counted). Combined with <a class="emphasis" href="#CURLINFOREDIRECTCOUNT">CURLINFO_REDIRECT_COUNT</a> you are able to know how many times libcurl successfully reused existing connection(s) or not. See the Connection Options of <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a> to see how libcurl tries to make persistent connections to save time. (Added in 7.12.3)
|
||||
<p class="level0"><a name="CURLINFOCOOKIELIST"></a><span class="nroffip">CURLINFO_COOKIELIST</span>
|
||||
<p class="level1">Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all cookies cURL knows (expired ones, too). Don't forget to <a class="emphasis" href="./curl_slist_free_all.html">curl_slist_free_all(3)</a> the list after it has been used. If there are no cookies (cookies for the handle have not been enabled or simply none have been received) 'struct curl_slist *' will be set to point to NULL. (Added in 7.14.1)
|
||||
<p class="level0"><a name="CURLINFOLASTSOCKET"></a><span class="nroffip">CURLINFO_LASTSOCKET</span>
|
||||
<p class="level1">Pass a pointer to a long to receive the last socket used by this curl session. If the socket is no longer valid, -1 is returned. When you finish working with the socket, you must call curl_easy_cleanup() as usual and let libcurl close the socket and cleanup other resources associated with the handle. This is typically used in combination with <span Class="emphasis">CURLOPT_CONNECT_ONLY</span>. (Added in 7.15.2)
|
||||
<p class="level0"><a name="CURLINFOFTPENTRYPATH"></a><span class="nroffip">CURLINFO_FTP_ENTRY_PATH</span>
|
||||
<p class="level1">Pass a pointer to a 'char *' to receive a pointer to a string holding the path of the entry path. That is the initial path libcurl ended up in when logging on to the remote FTP server. This stores a NULL as pointer if something is wrong. (Added in 7.15.4) <a name="TIMES"></a><h2 class="nroffsh">TIMES</h2>
|
||||
<p class="level0"><pre>
|
||||
<p class="level0">An overview of the six time values available from curl_easy_getinfo()
|
||||
<p class="level0">curl_easy_perform()
|
||||
|
|
||||
|--NT
|
||||
|--|--CT
|
||||
|--|--|--PT
|
||||
|--|--|--|--ST
|
||||
|--|--|--|--|--TT
|
||||
|--|--|--|--|--RT
|
||||
<p class="level0"><a name="NT"></a><span class="nroffip">NT</span> <p class="level1"><a class="emphasis" href="#CURLINFONAMELOOKUPTIME">CURLINFO_NAMELOOKUP_TIME</a>. The time it took from the start until the name
|
||||
resolving was completed.
|
||||
<p class="level0"><a name="CT"></a><span class="nroffip">CT</span> <p class="level1"><a class="emphasis" href="#CURLINFOCONNECTTIME">CURLINFO_CONNECT_TIME</a>. The time it took from the start until the connect
|
||||
to the remote host (or proxy) was completed.
|
||||
<p class="level0"><a name="PT"></a><span class="nroffip">PT</span> <p class="level1"><a class="emphasis" href="#CURLINFOPRETRANSFERTIME">CURLINFO_PRETRANSFER_TIME</a>. The time 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.
|
||||
<p class="level0"><a name="ST"></a><span class="nroffip">ST</span> <p class="level1"><a class="emphasis" href="#CURLINFOSTARTTRANSFERTIME">CURLINFO_STARTTRANSFER_TIME</a>. The time it took from the start until the
|
||||
first byte is just about to be transferred.
|
||||
<p class="level0"><a name="TT"></a><span class="nroffip">TT</span> <p class="level1"><a class="emphasis" href="#CURLINFOTOTALTIME">CURLINFO_TOTAL_TIME</a>. Total time of the previous request.
|
||||
<p class="level0"><a name="RT"></a><span class="nroffip">RT</span> <p class="level1"><a class="emphasis" href="#CURLINFOREDIRECTTIME">CURLINFO_REDIRECT_TIME</a>. The time it took for all redirection steps
|
||||
include name lookup, connect, pretransfer and transfer before final
|
||||
transaction was started. So, this is zero if no redirection took place.
|
||||
</pre>
|
||||
<a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_setopt.html">curl_easy_setopt (3)</a> <p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,32 +0,0 @@
|
|||
.\" $Id: curl_easy_init.3,v 1.9 2006/01/15 23:55:53 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_init 3 "4 March 2002" "libcurl 7.8.1" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_init - Start a libcurl easy session
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
|
||||
.BI "CURL *curl_easy_init( );"
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function must be the first function to call, and it returns a CURL easy
|
||||
handle that you must use as input to other easy-functions. curl_easy_init
|
||||
initializes curl and this call \fBMUST\fP have a corresponding call to
|
||||
\fIcurl_easy_cleanup(3)\fP when the operation is complete.
|
||||
|
||||
If you did not already call \fIcurl_global_init(3)\fP,
|
||||
\fIcurl_easy_init(3)\fP does it automatically.
|
||||
This may be lethal in multi-threaded cases, since \fIcurl_global_init(3)\fP is
|
||||
not thread-safe, and it may result in resource problems because there is
|
||||
no corresponding cleanup.
|
||||
|
||||
You are strongly advised to not allow this automatic behaviour, by
|
||||
calling \fIcurl_global_init(3)\fP yourself properly.
|
||||
See the description in \fBlibcurl\fP(3) of global environment
|
||||
requirements for details of how to use this function.
|
||||
|
||||
.SH RETURN VALUE
|
||||
If this function returns NULL, something went wrong and you cannot use the
|
||||
other curl functions.
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_cleanup "(3), " curl_global_init "(3), " curl_easy_reset "(3)"
|
|
@ -1,58 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_init man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_init - Start a libcurl easy session <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">CURL *curl_easy_init( );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">This function must be the first function to call, and it returns a CURL easy handle that you must use as input to other easy-functions. curl_easy_init initializes curl and this call <span Class="bold">MUST</span> have a corresponding call to <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a> when the operation is complete.
|
||||
<p class="level0">If you did not already call <a class="emphasis" href="./curl_global_init.html">curl_global_init(3)</a>, <a class="emphasis" href="./curl_easy_init.html">curl_easy_init(3)</a> does it automatically. This may be lethal in multi-threaded cases, since <a class="emphasis" href="./curl_global_init.html">curl_global_init(3)</a> is not thread-safe, and it may result in resource problems because there is no corresponding cleanup.
|
||||
<p class="level0">You are strongly advised to not allow this automatic behaviour, by calling <a class="emphasis" href="./curl_global_init.html">curl_global_init(3)</a> yourself properly. See the description in <span Class="bold">libcurl</span>(3) of global environment requirements for details of how to use this function.
|
||||
<p class="level0"><a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">If this function returns NULL, something went wrong and you cannot use the other curl functions. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_cleanup.html">curl_easy_cleanup (3)</a> <a class="manpage" href="./curl_global_init.html"> curl_global_init (3)</a> <a class="manpage" href="./curl_easy_reset.html"> curl_easy_reset (3)</a> <p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,40 +0,0 @@
|
|||
.\" You can view this file with:
|
||||
.\" nroff -man [file]
|
||||
.\" $Id: curl_easy_perform.3,v 1.2 2004/02/27 15:34:06 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_perform 3 "5 Mar 2001" "libcurl 7.7" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_perform - Perform a file transfer
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
.sp
|
||||
.BI "CURLcode curl_easy_perform(CURL *" handle ");"
|
||||
.ad
|
||||
.SH DESCRIPTION
|
||||
This function is called after the init and all the \fIcurl_easy_setopt(3)\fP
|
||||
calls are made, and will perform the transfer as described in the options. It
|
||||
must be called with the same
|
||||
.I handle
|
||||
as input as the curl_easy_init call returned.
|
||||
|
||||
You can do any amount of calls to \fIcurl_easy_perform(3)\fP while using the
|
||||
same handle. If you intend to transfer more than one file, you are even
|
||||
encouraged to do so. libcurl will then attempt to re-use the same connection
|
||||
for the following transfers, thus making the operations faster, less CPU
|
||||
intense and using less network resources. Just note that you will have to use
|
||||
\fIcurl_easy_setopt(3)\fP between the invokes to set options for the following
|
||||
curl_easy_perform.
|
||||
|
||||
You must never call this function simultaneously from two places using the
|
||||
same handle. Let the function return first before invoking it another time. If
|
||||
you want parallel transfers, you must use several curl handles.
|
||||
.SH RETURN VALUE
|
||||
0 means everything was ok, non-zero means an error occurred as
|
||||
.I <curl/curl.h>
|
||||
defines. If the CURLOPT_ERRORBUFFER was set with
|
||||
.I curl_easy_setopt
|
||||
there will be a readable error message in the error buffer when non-zero is
|
||||
returned.
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_init "(3), " curl_easy_setopt "(3), "
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_perform man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_perform - Perform a file transfer <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">CURLcode curl_easy_perform(CURL * handle );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">This function is called after the init and all the <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a> calls are made, and will perform the transfer as described in the options. It must be called with the same <span Class="emphasis">handle</span> as input as the curl_easy_init call returned.
|
||||
<p class="level0">You can do any amount of calls to <a class="emphasis" href="./curl_easy_perform.html">curl_easy_perform(3)</a> while using the same handle. If you intend to transfer more than one file, you are even encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use <a class="emphasis" href="./curl_easy_setopt.html">curl_easy_setopt(3)</a> between the invokes to set options for the following curl_easy_perform.
|
||||
<p class="level0">You must never call this function simultaneously from two places using the same handle. Let the function return first before invoking it another time. If you want parallel transfers, you must use several curl handles. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">0 means everything was ok, non-zero means an error occurred as <span Class="emphasis"><curl/curl.h></span> defines. If the CURLOPT_ERRORBUFFER was set with <span Class="emphasis">curl_easy_setopt</span> there will be a readable error message in the error buffer when non-zero is returned. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_init.html">curl_easy_init (3)</a> <a class="manpage" href="./curl_easy_setopt.html"> curl_easy_setopt (3)</a> <span Class="manpage"> </span>
|
||||
<p class="level0"><p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,24 +0,0 @@
|
|||
.\" $Id: curl_easy_reset.3,v 1.3 2006/01/02 23:32:36 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_reset 3 "31 July 2004" "libcurl 7.12.1" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_reset - reset all options of a libcurl session handle
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
|
||||
.BI "void curl_easy_reset(CURL *"handle ");"
|
||||
|
||||
.SH DESCRIPTION
|
||||
Re-initializes all options previously set on a specified CURL handle to the
|
||||
default values. This puts back the handle to the same state as it was in when
|
||||
it was just created with \fIcurl_easy_init(3)\fP.
|
||||
|
||||
It does not change the following information kept in the handle: live
|
||||
connections, the Session ID cache, the DNS cache, the cookies and shares.
|
||||
.SH AVAILABILITY
|
||||
This function was added in libcurl 7.12.1
|
||||
.SH RETURN VALUE
|
||||
Nothing
|
||||
.SH "SEE ALSO"
|
||||
.BR curl_easy_init "(3)," curl_easy_cleanup "(3)," curl_easy_setopt "(3)
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_reset man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_reset - reset all options of a libcurl session handle <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0"><span Class="bold">#include <curl/curl.h></span>
|
||||
<p class="level0"><span Class="bold">void curl_easy_reset(CURL *handle );</span>
|
||||
<p class="level0"><a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">Re-initializes all options previously set on a specified CURL handle to the default values. This puts back the handle to the same state as it was in when it was just created with <a class="emphasis" href="./curl_easy_init.html">curl_easy_init(3)</a>.
|
||||
<p class="level0">It does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares. <a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
|
||||
<p class="level0">This function was added in libcurl 7.12.1 <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">Nothing <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_init.html">curl_easy_init (3)</a> <a class="manpage" href="./curl_easy_cleanup.html"> curl_easy_cleanup (3)</a> <a class="manpage" href="./curl_easy_setopt.html"> curl_easy_setopt (3)</a>
|
||||
<p class="level0"><p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,539 +0,0 @@
|
|||
<html><head>
|
||||
<title>curl_easy_setopt man page</title>
|
||||
<meta name="generator" content="roffit 0.7">
|
||||
<STYLE type="text/css">
|
||||
P.level0 {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
P.level1 {
|
||||
padding-left: 4em;
|
||||
}
|
||||
|
||||
P.level2 {
|
||||
padding-left: 6em;
|
||||
}
|
||||
|
||||
span.emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.manpage {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2.nroffsh {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
span.nroffip {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
p.roffit {
|
||||
text-align: center;
|
||||
font-size: 80%;
|
||||
}
|
||||
</STYLE>
|
||||
</head><body>
|
||||
|
||||
<p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
|
||||
<p class="level0">curl_easy_setopt - set options for a curl easy handle <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
|
||||
<p class="level0">#include <curl/curl.h>
|
||||
<p class="level0">CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter); <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
|
||||
<p class="level0">curl_easy_setopt() is used to tell libcurl how to behave. By using the appropriate options to <span Class="emphasis">curl_easy_setopt</span>, you can change libcurl's behavior. All options are set with the <span Class="emphasis">option</span> followed by a <span Class="emphasis">parameter</span>. That parameter can be a <span Class="bold">long</span>, a <span Class="bold">function pointer</span>, an <span Class="bold">object pointer</span> or a <span Class="bold">curl_off_t</span>, depending on what the specific option expects. Read this manual carefully as bad input values may cause libcurl to behave badly! You can only set one option in each function call. A typical application uses many curl_easy_setopt() calls in the setup phase.
|
||||
<p class="level0">Options set with this function call are valid for all forthcoming transfers performed using this <span Class="emphasis">handle</span>. The options are not in any way reset between transfers, so if you want subsequent transfers with different options, you must change them between the transfers. You can optionally reset all options back to internal default with <a class="emphasis" href="./curl_easy_reset.html">curl_easy_reset(3)</a>.
|
||||
<p class="level0">Strings passed to libcurl as 'char *' arguments, will not be copied by the library. Instead you should keep them available until libcurl no longer needs them. Failing to do so will cause very odd behavior or even crashes. libcurl will need them until you call <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a> or you set the same option again to use a different pointer.
|
||||
<p class="level0">The <span Class="emphasis">handle</span> is the return code from a <a class="emphasis" href="./curl_easy_init.html">curl_easy_init(3)</a> or <a class="emphasis" href="./curl_easy_duphandle.html">curl_easy_duphandle(3)</a> call. <a name="BEHAVIOR"></a><h2 class="nroffsh">BEHAVIOR OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTVERBOSE"></a><span class="nroffip">CURLOPT_VERBOSE</span>
|
||||
<p class="level1">Set the parameter to non-zero to get the library to display a lot of verbose information about its operations. Very useful for libcurl and/or protocol debugging and understanding. The verbose information will be sent to stderr, or the stream set with <a class="emphasis" href="#CURLOPTSTDERR">CURLOPT_STDERR</a>.
|
||||
<p class="level1">You hardly ever want this set in production use, you will almost always want this when you debug/report problems. Another neat option for debugging is the <a class="emphasis" href="#CURLOPTDEBUGFUNCTION">CURLOPT_DEBUGFUNCTION</a>.
|
||||
<p class="level0"><a name="CURLOPTHEADER"></a><span class="nroffip">CURLOPT_HEADER</span>
|
||||
<p class="level1">A non-zero parameter tells the library to include the header in the body output. This is only relevant for protocols that actually have headers preceding the data (like HTTP).
|
||||
<p class="level0"><a name="CURLOPTNOPROGRESS"></a><span class="nroffip">CURLOPT_NOPROGRESS</span>
|
||||
<p class="level1">A non-zero parameter tells the library to shut off the built-in progress meter completely.
|
||||
<p class="level1">Future versions of libcurl is likely to not have any built-in progress meter at all.
|
||||
<p class="level0"><a name="CURLOPTNOSIGNAL"></a><span class="nroffip">CURLOPT_NOSIGNAL</span>
|
||||
<p class="level1">Pass a long. If it is non-zero, libcurl will not use any functions that install signal handlers or any functions that cause signals to be sent to the process. This option is mainly here to allow multi-threaded unix applications to still set/use all timeout options etc, without risking getting signals. (Added in 7.10)
|
||||
<p class="level1">Consider building libcurl with ares support to enable asynchronous DNS lookups. It enables nice timeouts for name resolves without signals. <a name="CALLBACK"></a><h2 class="nroffsh">CALLBACK OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTWRITEFUNCTION"></a><span class="nroffip">CURLOPT_WRITEFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the following prototype: <span class="bold">size_t function( void *ptr, size_t size, size_t nmemb, void *stream);</span> This function gets called by libcurl as soon as there is data received that needs to be saved. The size of the data pointed to by <span Class="emphasis">ptr</span> is <span Class="emphasis">size</span> multiplied with <span Class="emphasis">nmemb</span>, it will not be zero terminated. Return the number of bytes actually taken care of. If that amount differs from the amount passed to your function, it'll signal an error to the library and it will abort the transfer and return <span Class="emphasis">CURLE_WRITE_ERROR</span>.
|
||||
<p class="level1">This function may be called with zero bytes data if the transfered file is empty.
|
||||
<p class="level1">Set this option to NULL to get the internal default function. The internal default function will write the data to the FILE * given with <a class="emphasis" href="#CURLOPTWRITEDATA">CURLOPT_WRITEDATA</a>.
|
||||
<p class="level1">Set the <span Class="emphasis">stream</span> argument with the <a class="emphasis" href="#CURLOPTWRITEDATA">CURLOPT_WRITEDATA</a> option.
|
||||
<p class="level1">The callback function will be passed as much data as possible in all invokes, but you cannot possibly make any assumptions. It may be one byte, it may be thousands. The maximum amount of data that can be passed to the write callback is defined in the curl.h header file: CURL_MAX_WRITE_SIZE.
|
||||
<p class="level0"><a name="CURLOPTWRITEDATA"></a><span class="nroffip">CURLOPT_WRITEDATA</span>
|
||||
<p class="level1">Data pointer to pass to the file write function. If you use the <a class="emphasis" href="#CURLOPTWRITEFUNCTION">CURLOPT_WRITEFUNCTION</a> option, this is the pointer you'll get as input. If you don't use a callback, you must pass a 'FILE *' as libcurl will pass this to fwrite() when writing data.
|
||||
<p class="level1">The internal <a class="emphasis" href="#CURLOPTWRITEFUNCTION">CURLOPT_WRITEFUNCTION</a> will write the data to the FILE * given with this option, or to stdout if this option hasn't been set.
|
||||
<p class="level1">If you're using libcurl as a win32 DLL, you <span Class="bold">MUST</span> use the <a class="emphasis" href="#CURLOPTWRITEFUNCTION">CURLOPT_WRITEFUNCTION</a> if you set this option or you will experience crashes.
|
||||
<p class="level1">This option is also known with the older name <span Class="emphasis">CURLOPT_FILE</span>, the name <a class="emphasis" href="#CURLOPTWRITEDATA">CURLOPT_WRITEDATA</a> was introduced in 7.9.7.
|
||||
<p class="level0"><a name="CURLOPTREADFUNCTION"></a><span class="nroffip">CURLOPT_READFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the following prototype: <span class="bold">size_t function( void *ptr, size_t size, size_t nmemb, void *stream);</span> This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. The data area pointed at by the pointer <span Class="emphasis">ptr</span> may be filled with at most <span Class="emphasis">size</span> multiplied with <span Class="emphasis">nmemb</span> number of bytes. Your function must return the actual number of bytes that you stored in that memory area. Returning 0 will signal end-of-file to the library and cause it to stop the current transfer.
|
||||
<p class="level1">If you stop the current transfer by returning 0 "pre-maturely" (i.e before the server expected it, like when you've told you will upload N bytes and you upload less than N bytes), you may experience that the server "hangs" waiting for the rest of the data that won't come.
|
||||
<p class="level1">The read callback may return <span Class="emphasis">CURL_READFUNC_ABORT</span> to stop the current operation immediately, resulting in a <span Class="emphasis">CURLE_ABORTED_BY_CALLBACK</span> error code from the transfer (Added in 7.12.1)
|
||||
<p class="level1">If you set the callback pointer to NULL, or doesn't set it at all, the default internal read function will be used. It is simply doing an fread() on the FILE * stream set with <a class="emphasis" href="#CURLOPTREADDATA">CURLOPT_READDATA</a>.
|
||||
<p class="level0"><a name="CURLOPTREADDATA"></a><span class="nroffip">CURLOPT_READDATA</span>
|
||||
<p class="level1">Data pointer to pass to the file read function. If you use the <a class="emphasis" href="#CURLOPTREADFUNCTION">CURLOPT_READFUNCTION</a> option, this is the pointer you'll get as input. If you don't specify a read callback but instead rely on the default internal read function, this data must be a valid readable FILE *.
|
||||
<p class="level1">If you're using libcurl as a win32 DLL, you MUST use a <a class="emphasis" href="#CURLOPTREADFUNCTION">CURLOPT_READFUNCTION</a> if you set this option.
|
||||
<p class="level1">This option is also known with the older name <span Class="emphasis">CURLOPT_INFILE</span>, the name <a class="emphasis" href="#CURLOPTREADDATA">CURLOPT_READDATA</a> was introduced in 7.9.7.
|
||||
<p class="level0"><a name="CURLOPTIOCTLFUNCTION"></a><span class="nroffip">CURLOPT_IOCTLFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the <span Class="emphasis">curl_ioctl_callback</span> prototype found in <span Class="emphasis"><curl/curl.h></span>. This function gets called by libcurl when something special I/O-related needs to be done that the library can't do by itself. For now, rewinding the read data stream is the only action it can request. The rewinding of the read data stream may be necessary when doing a HTTP PUT or POST with a multi-pass authentication method. (Option added in 7.12.3)
|
||||
<p class="level0"><a name="CURLOPTIOCTLDATA"></a><span class="nroffip">CURLOPT_IOCTLDATA</span>
|
||||
<p class="level1">Pass a pointer that will be untouched by libcurl and passed as the 3rd argument in the ioctl callback set with <a class="emphasis" href="#CURLOPTIOCTLFUNCTION">CURLOPT_IOCTLFUNCTION</a>. (Option added in 7.12.3)
|
||||
<p class="level0"><a name="CURLOPTSOCKOPTFUNCTION"></a><span class="nroffip">CURLOPT_SOCKOPTFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the <span Class="emphasis">curl_sockopt_callback</span> prototype found in <span Class="emphasis"><curl/curl.h></span>. This function gets called by libcurl after the socket() call but before the connect() call. The callback's <span Class="emphasis">purpose</span> argument identifies the exact purpose for this particular socket, and currently only one value is supported: <span Class="emphasis">CURLSOCKTYPE_IPCXN</span> for the primary connection (meaning the control connection in the FTP case). Future versions of libcurl may support more purposes. It passes the newly created socket descriptor so additional setsockopt() calls can be done at the user's discretion. A non-zero return code from the callback function will signal an unrecoverable error to the library and it will close the socket and return <span Class="emphasis">CURLE_COULDNT_CONNECT</span>. (Option added in 7.15.6.)
|
||||
<p class="level0"><a name="CURLOPTSOCKOPTDATA"></a><span class="nroffip">CURLOPT_SOCKOPTDATA</span>
|
||||
<p class="level1">Pass a pointer that will be untouched by libcurl and passed as the first argument in the sockopt callback set with <a class="emphasis" href="#CURLOPTSOCKOPTFUNCTION">CURLOPT_SOCKOPTFUNCTION</a>. (Option added in 7.15.6.)
|
||||
<p class="level0"><a name="CURLOPTPROGRESSFUNCTION"></a><span class="nroffip">CURLOPT_PROGRESSFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the <span Class="emphasis">curl_progress_callback</span> prototype found in <span Class="emphasis"><curl/curl.h></span>. This function gets called by libcurl instead of its internal equivalent with a frequent interval during operation (roughly once per second) no matter if data is being transfered or not. Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Returning a non-zero value from this callback will cause libcurl to abort the transfer and return <span Class="emphasis">CURLE_ABORTED_BY_CALLBACK</span>.
|
||||
<p class="level1">If you transfer data with the multi interface, this function will not be called during periods of idleness unless you call the appropriate libcurl function that performs transfers. Usage of the <a class="bold" href="#CURLOPTPROGRESSFUNCTION">CURLOPT_PROGRESSFUNCTION</a> callback is not recommended when using the multi interface.
|
||||
<p class="level1"><a class="emphasis" href="#CURLOPTNOPROGRESS">CURLOPT_NOPROGRESS</a> must be set to FALSE to make this function actually get called.
|
||||
<p class="level0"><a name="CURLOPTPROGRESSDATA"></a><span class="nroffip">CURLOPT_PROGRESSDATA</span>
|
||||
<p class="level1">Pass a pointer that will be untouched by libcurl and passed as the first argument in the progress callback set with <a class="emphasis" href="#CURLOPTPROGRESSFUNCTION">CURLOPT_PROGRESSFUNCTION</a>.
|
||||
<p class="level0"><a name="CURLOPTHEADERFUNCTION"></a><span class="nroffip">CURLOPT_HEADERFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the following prototype: <span class="emphasis">size_t function( void *ptr, size_t size, size_t nmemb, void *stream);</span>. This function gets called by libcurl as soon as it has received header data. The header callback will be called once for each header and only complete header lines are passed on to the callback. Parsing headers should be easy enough using this. The size of the data pointed to by <span Class="emphasis">ptr</span> is <span Class="emphasis">size</span> multiplied with <span Class="emphasis">nmemb</span>. Do not assume that the header line is zero terminated! The pointer named <span Class="emphasis">stream</span> is the one you set with the <a class="emphasis" href="#CURLOPTWRITEHEADER">CURLOPT_WRITEHEADER</a> option. The callback function must return the number of bytes actually taken care of, or return -1 to signal error to the library (it will cause it to abort the transfer with a <span Class="emphasis">CURLE_WRITE_ERROR</span> return code).
|
||||
<p class="level1">Since 7.14.1: When a server sends a chunked encoded transfer, it may contain a trailer. That trailer is identical to a HTTP header and if such a trailer is received it is passed to the application using this callback as well. There are several ways to detect it being a trailer and not an ordinary header: 1) it comes after the response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: header among the response-headers mention what header to expect in the trailer.
|
||||
<p class="level0"><a name="CURLOPTWRITEHEADER"></a><span class="nroffip">CURLOPT_WRITEHEADER</span>
|
||||
<p class="level1">(This option is also known as <span Class="bold">CURLOPT_HEADERDATA</span>) Pass a pointer to be used to write the header part of the received data to. If you don't use your own callback to take care of the writing, this must be a valid FILE *. See also the <a class="emphasis" href="#CURLOPTHEADERFUNCTION">CURLOPT_HEADERFUNCTION</a> option above on how to set a custom get-all-headers callback.
|
||||
<p class="level0"><a name="CURLOPTDEBUGFUNCTION"></a><span class="nroffip">CURLOPT_DEBUGFUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the following prototype: <span class="emphasis">int curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);</span> <a class="emphasis" href="#CURLOPTDEBUGFUNCTION">CURLOPT_DEBUGFUNCTION</a> replaces the standard debug function used when <a class="emphasis" href="#CURLOPTVERBOSE">CURLOPT_VERBOSE </a> is in effect. This callback receives debug information, as specified with the <span Class="bold">curl_infotype</span> argument. This function must return 0. The data pointed to by the char * passed to this function WILL NOT be zero terminated, but will be exactly of the size as told by the size_t argument.
|
||||
<p class="level1">Available curl_infotype values:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLINFOTEXT"></a><span class="nroffip">CURLINFO_TEXT</span>
|
||||
<p class="level2">The data is informational text.
|
||||
<p class="level1"><a name="CURLINFOHEADERIN"></a><span class="nroffip">CURLINFO_HEADER_IN</span>
|
||||
<p class="level2">The data is header (or header-like) data received from the peer.
|
||||
<p class="level1"><a name="CURLINFOHEADEROUT"></a><span class="nroffip">CURLINFO_HEADER_OUT</span>
|
||||
<p class="level2">The data is header (or header-like) data sent to the peer.
|
||||
<p class="level1"><a name="CURLINFODATAIN"></a><span class="nroffip">CURLINFO_DATA_IN</span>
|
||||
<p class="level2">The data is protocol data received from the peer.
|
||||
<p class="level1"><a name="CURLINFODATAOUT"></a><span class="nroffip">CURLINFO_DATA_OUT</span>
|
||||
<p class="level2">The data is protocol data sent to the peer.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTDEBUGDATA"></a><span class="nroffip">CURLOPT_DEBUGDATA</span>
|
||||
<p class="level1">Pass a pointer to whatever you want passed in to your <a class="emphasis" href="#CURLOPTDEBUGFUNCTION">CURLOPT_DEBUGFUNCTION</a> in the last void * argument. This pointer is not used by libcurl, it is only passed to the callback.
|
||||
<p class="level0"><a name="CURLOPTSSLCTXFUNCTION"></a><span class="nroffip">CURLOPT_SSL_CTX_FUNCTION</span>
|
||||
<p class="level1">Function pointer that should match the following prototype: <span class="bold">CURLcode sslctxfun(CURL *curl, void *sslctx, void *parm);</span> This function gets called by libcurl just before the initialization of an SSL connection after having processed all other SSL related options to give a last chance to an application to modify the behaviour of openssl's ssl initialization. The <span Class="emphasis">sslctx</span> parameter is actually a pointer to an openssl <span Class="emphasis">SSL_CTX</span>. If an error is returned no attempt to establish a connection is made and the perform operation will return the error code from this callback function. Set the <span Class="emphasis">parm</span> argument with the <a class="emphasis" href="#CURLOPTSSLCTXDATA">CURLOPT_SSL_CTX_DATA</a> option. This option was introduced in 7.11.0.
|
||||
<p class="level1">This function will get called on all new connections made to a server, during the SSL negotiation. The SSL_CTX pointer will be a new one every time.
|
||||
<p class="level1">To use this properly, a non-trivial amount of knowledge of the openssl libraries is necessary. Using this function allows for example to use openssl callbacks to add additional validation code for certificates, and even to change the actual URI of an HTTPS request (example used in the lib509 test case). See also the example section for a replacement of the key, certificate and trust file settings.
|
||||
<p class="level0"><a name="CURLOPTSSLCTXDATA"></a><span class="nroffip">CURLOPT_SSL_CTX_DATA</span>
|
||||
<p class="level1">Data pointer to pass to the ssl context callback set by the option <a class="emphasis" href="#CURLOPTSSLCTXFUNCTION">CURLOPT_SSL_CTX_FUNCTION</a>, this is the pointer you'll get as third parameter, otherwise <span Class="bold">NULL</span>. (Added in 7.11.0)
|
||||
<p class="level0"><a name="CURLOPTCONVTONETWORKFUNCTION"></a><span class="nroffip">CURLOPT_CONV_TO_NETWORK_FUNCTION</span>
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTCONVFROMNETWORKFUNCTION"></a><span class="nroffip">CURLOPT_CONV_FROM_NETWORK_FUNCTION</span>
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTCONVFROMUTF8FUNCTION"></a><span class="nroffip">CURLOPT_CONV_FROM_UTF8_FUNCTION</span>
|
||||
<p class="level1">Function pointers that should match the following prototype: CURLcode function(char *ptr, size_t length);
|
||||
<p class="level1">These three options apply to non-ASCII platforms only. They are available only if <span Class="bold">CURL_DOES_CONVERSIONS</span> was defined when libcurl was built. When this is the case, <a class="emphasis" href="./curl_version_info.html">curl_version_info(3)</a> will return the CURL_VERSION_CONV feature bit set.
|
||||
<p class="level1">The data to be converted is in a buffer pointed to by the ptr parameter. The amount of data to convert is indicated by the length parameter. The converted data overlays the input data in the buffer pointed to by the ptr parameter. CURLE_OK should be returned upon successful conversion. A CURLcode return value defined by curl.h, such as CURLE_CONV_FAILED, should be returned if an error was encountered.
|
||||
<p class="level1"><a class="bold" href="#CURLOPTCONVTONETWORKFUNCTION">CURLOPT_CONV_TO_NETWORK_FUNCTION</a> and <a class="bold" href="#CURLOPTCONVFROMNETWORKFUNCTION">CURLOPT_CONV_FROM_NETWORK_FUNCTION</a> convert between the host encoding and the network encoding. They are used when commands or ASCII data are sent/received over the network.
|
||||
<p class="level1"><a class="bold" href="#CURLOPTCONVFROMUTF8FUNCTION">CURLOPT_CONV_FROM_UTF8_FUNCTION</a> is called to convert from UTF8 into the host encoding. It is required only for SSL processing.
|
||||
<p class="level1">If you set a callback pointer to NULL, or don't set it at all, the built-in libcurl iconv functions will be used. If HAVE_ICONV was not defined when libcurl was built, and no callback has been established, conversion will return the CURLE_CONV_REQD error code.
|
||||
<p class="level1">If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined. For example:
|
||||
<p class="level1"> #define CURL_ICONV_CODESET_OF_HOST "IBM-1047"
|
||||
<p class="level1">The iconv code in libcurl will default the network and UTF8 codeset names as follows:
|
||||
<p class="level1"> #define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1"
|
||||
<p class="level1"> #define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8"
|
||||
<p class="level1">You will need to override these definitions if they are different on your system. <a name="ERROR"></a><h2 class="nroffsh">ERROR OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTERRORBUFFER"></a><span class="nroffip">CURLOPT_ERRORBUFFER</span>
|
||||
<p class="level1">Pass a char * to a buffer that the libcurl may store human readable error messages in. This may be more helpful than just the return code from <span Class="emphasis">curl_easy_perform</span>. The buffer must be at least CURL_ERROR_SIZE big.
|
||||
<p class="level1">Use <a class="emphasis" href="#CURLOPTVERBOSE">CURLOPT_VERBOSE</a> and <a class="emphasis" href="#CURLOPTDEBUGFUNCTION">CURLOPT_DEBUGFUNCTION</a> to better debug/trace why errors happen.
|
||||
<p class="level1">If the library does not return an error, the buffer may not have been touched. Do not rely on the contents in those cases.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTSTDERR"></a><span class="nroffip">CURLOPT_STDERR</span>
|
||||
<p class="level1">Pass a FILE * as parameter. Tell libcurl to use this stream instead of stderr when showing the progress meter and displaying <a class="emphasis" href="#CURLOPTVERBOSE">CURLOPT_VERBOSE</a> data.
|
||||
<p class="level0"><a name="CURLOPTFAILONERROR"></a><span class="nroffip">CURLOPT_FAILONERROR</span>
|
||||
<p class="level1">A non-zero parameter tells the library to fail silently if the HTTP code returned is equal to or larger than 400. The default action would be to return the page normally, ignoring that code.
|
||||
<p class="level1">This method is not fail-safe and there are occasions where non-succesful response codes will slip through, especially when authentication is involved (response codes 401 and 407).
|
||||
<p class="level1">You might get some amounts of headers transferred before this situation is detected, like for when a "100-continue" is received as a response to a POST/PUT and a 401 or 407 is received immediately afterwards. <a name="NETWORK"></a><h2 class="nroffsh">NETWORK OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTURL"></a><span class="nroffip">CURLOPT_URL</span>
|
||||
<p class="level1">The actual URL to deal with. The parameter should be a char * to a zero terminated string. The string must remain present until curl no longer needs it, as it doesn't copy the string.
|
||||
<p class="level1">If the given URL lacks the protocol part ("http://" or "ftp://" etc), it will attempt to guess which protocol to use based on the given host name. If the given protocol of the set URL is not supported, libcurl will return on error (<span Class="emphasis">CURLE_UNSUPPORTED_PROTOCOL</span>) when you call <a class="emphasis" href="./curl_easy_perform.html">curl_easy_perform(3)</a> or <a class="emphasis" href="./curl_multi_perform.html">curl_multi_perform(3)</a>. Use <a class="emphasis" href="./curl_version_info.html">curl_version_info(3)</a> for detailed info on which protocols that are supported.
|
||||
<p class="level1">The string given to CURLOPT_URL must be url-encoded and following the RFC 2396 (<a href="http://curl.haxx.se/rfc/rfc2396.txt">http://curl.haxx.se/rfc/rfc2396.txt</a>).
|
||||
<p class="level1"><a class="emphasis" href="#CURLOPTURL">CURLOPT_URL</a> is the only option that <span Class="bold">must</span> be set before <a class="emphasis" href="./curl_easy_perform.html">curl_easy_perform(3)</a> is called.
|
||||
<p class="level0"><a name="CURLOPTPROXY"></a><span class="nroffip">CURLOPT_PROXY</span>
|
||||
<p class="level1">Set HTTP proxy to use. The parameter should be a char * to a zero terminated string holding the host name or dotted IP address. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]:// since any such prefix will be ignored. The proxy's port number may optionally be specified with the separate option <a class="emphasis" href="#CURLOPTPROXYPORT">CURLOPT_PROXYPORT</a>.
|
||||
<p class="level1">When you tell the library to use an HTTP proxy, libcurl will transparently convert operations to HTTP even if you specify an FTP URL etc. This may have an impact on what other features of the library you can use, such as <a class="emphasis" href="#CURLOPTQUOTE">CURLOPT_QUOTE</a> and similar FTP specifics that don't work unless you tunnel through the HTTP proxy. Such tunneling is activated with <a class="emphasis" href="#CURLOPTHTTPPROXYTUNNEL">CURLOPT_HTTPPROXYTUNNEL</a>.
|
||||
<p class="level1">libcurl respects the environment variables <span Class="bold">http_proxy</span>, <span Class="bold">ftp_proxy</span>, <span Class="bold">all_proxy</span> etc, if any of those is set. The <a class="emphasis" href="#CURLOPTPROXY">CURLOPT_PROXY</a> option does however override any possibly set environment variables.
|
||||
<p class="level1">Starting with 7.14.1, the proxy host string given in environment variables can be specified the exact same way as the proxy can be set with <a class="emphasis" href="#CURLOPTPROXY">CURLOPT_PROXY</a>, include protocol prefix (http://) and embedded user + password.
|
||||
<p class="level0"><a name="CURLOPTPROXYPORT"></a><span class="nroffip">CURLOPT_PROXYPORT</span>
|
||||
<p class="level1">Pass a long with this option to set the proxy port to connect to unless it is specified in the proxy string <a class="emphasis" href="#CURLOPTPROXY">CURLOPT_PROXY</a>.
|
||||
<p class="level0"><a name="CURLOPTPROXYTYPE"></a><span class="nroffip">CURLOPT_PROXYTYPE</span>
|
||||
<p class="level1">Pass a long with this option to set type of the proxy. Available options for this are <span Class="emphasis">CURLPROXY_HTTP</span>, <span Class="emphasis">CURLPROXY_SOCKS4</span> (added in 7.15.2) <span Class="emphasis">CURLPROXY_SOCKS5</span>. The HTTP type is default. (Added in 7.10)
|
||||
<p class="level0"><a name="CURLOPTHTTPPROXYTUNNEL"></a><span class="nroffip">CURLOPT_HTTPPROXYTUNNEL</span>
|
||||
<p class="level1">Set the parameter to non-zero to get the library to tunnel all operations through a given HTTP proxy. There is a big difference between using a proxy and to tunnel through it. If you don't know what this means, you probably don't want this tunneling option.
|
||||
<p class="level0"><a name="CURLOPTINTERFACE"></a><span class="nroffip">CURLOPT_INTERFACE</span>
|
||||
<p class="level1">Pass a char * as parameter. This set the interface name to use as outgoing network interface. The name can be an interface name, an IP address or a host name.
|
||||
<p class="level0"><a name="CURLOPTLOCALPORT"></a><span class="nroffip">CURLOPT_LOCALPORT</span>
|
||||
<p class="level1">Pass a long. This sets the local port number of the socket used for connection. This can be used in combination with <a class="emphasis" href="#CURLOPTINTERFACE">CURLOPT_INTERFACE</a> and you are recommended to use <a class="emphasis" href="#CURLOPTLOCALPORTRANGE">CURLOPT_LOCALPORTRANGE</a> as well when this is set. Note that port numbers are only valid 1 - 65535. (Added in 7.15.2)
|
||||
<p class="level0"><a name="CURLOPTLOCALPORTRANGE"></a><span class="nroffip">CURLOPT_LOCALPORTRANGE</span>
|
||||
<p class="level1">Pass a long. This is the number of attempts libcurl should do to find a working local port number. It starts with the given <a class="emphasis" href="#CURLOPTLOCALPORT">CURLOPT_LOCALPORT</a> and adds one to the number for each retry. Setting this value to 1 or below will make libcurl do only one try for exact port number. Note that port numbers by nature is a scarce resource that will be busy at times so setting this value to something too low might cause unnecessary connection setup failures. (Added in 7.15.2)
|
||||
<p class="level0"><a name="CURLOPTDNSCACHETIMEOUT"></a><span class="nroffip">CURLOPT_DNS_CACHE_TIMEOUT</span>
|
||||
<p class="level1">Pass a long, this sets the timeout in seconds. Name resolves will be kept in memory for this number of seconds. Set to zero (0) to completely disable caching, or set to -1 to make the cached entries remain forever. By default, libcurl caches this info for 60 seconds.
|
||||
<p class="level0"><a name="CURLOPTDNSUSEGLOBALCACHE"></a><span class="nroffip">CURLOPT_DNS_USE_GLOBAL_CACHE</span>
|
||||
<p class="level1">Pass a long. If the value is non-zero, it tells curl to use a global DNS cache that will survive between easy handle creations and deletions. This is not thread-safe and this will use a global variable.
|
||||
<p class="level1"><span Class="bold">WARNING:</span> this option is considered obsolete. Stop using it. Switch over to using the share interface instead! See <a class="emphasis" href="#CURLOPTSHARE">CURLOPT_SHARE</a> and <a class="emphasis" href="./curl_share_init.html">curl_share_init(3)</a>.
|
||||
<p class="level0"><a name="CURLOPTBUFFERSIZE"></a><span class="nroffip">CURLOPT_BUFFERSIZE</span>
|
||||
<p class="level1">Pass a long specifying your preferred size (in bytes) for the receive buffer in libcurl. The main point of this would be that the write callback gets called more often and with smaller chunks. This is just treated as a request, not an order. You cannot be guaranteed to actually get the given size. (Added in 7.10)
|
||||
<p class="level1">This size is by default set as big as possible (CURL_MAX_WRITE_SIZE), so it only makse sense to use this option if you want it smaller.
|
||||
<p class="level0"><a name="CURLOPTPORT"></a><span class="nroffip">CURLOPT_PORT</span>
|
||||
<p class="level1">Pass a long specifying what remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol.
|
||||
<p class="level0"><a name="CURLOPTTCPNODELAY"></a><span class="nroffip">CURLOPT_TCP_NODELAY</span>
|
||||
<p class="level1">Pass a long specifying whether the TCP_NODELAY option should be set or cleared (1 = set, 0 = clear). The option is cleared by default. This will have no effect after the connection has been established.
|
||||
<p class="level1">Setting this option will disable TCP's Nagle algorithm. The purpose of this algorithm is to try to minimize the number of small packets on the network (where "small packets" means TCP segments less than the Maximum Segment Size (MSS) for the network).
|
||||
<p class="level1">Maximizing the amount of data sent per TCP segment is good because it amortizes the overhead of the send. However, in some cases (most notably telnet or rlogin) small segments may need to be sent without delay. This is less efficient than sending larger amounts of data at a time, and can contribute to congestion on the network if overdone. <a name="NAMES"></a><h2 class="nroffsh">NAMES and PASSWORDS OPTIONS (Authentication)</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTNETRC"></a><span class="nroffip">CURLOPT_NETRC</span>
|
||||
<p class="level1">This parameter controls the preference of libcurl between using user names and passwords from your <span Class="emphasis">~/.netrc</span> file, relative to user names and passwords in the URL supplied with <a class="emphasis" href="#CURLOPTURL">CURLOPT_URL</a>.
|
||||
<p class="level1">libcurl uses a user name (and supplied or prompted password) supplied with <a class="emphasis" href="#CURLOPTUSERPWD">CURLOPT_USERPWD</a> in preference to any of the options controlled by this parameter.
|
||||
<p class="level1">Pass a long, set to one of the values described below.
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLNETRCOPTIONAL"></a><span class="nroffip">CURL_NETRC_OPTIONAL</span>
|
||||
<p class="level2">The use of your <span Class="emphasis">~/.netrc</span> file is optional, and information in the URL is to be preferred. The file will be scanned with the host and user name (to find the password only) or with the host only, to find the first user name and password after that <span Class="emphasis">machine</span>, which ever information is not specified in the URL.
|
||||
<p class="level2">Undefined values of the option will have this effect.
|
||||
<p class="level1"><a name="CURLNETRCIGNORED"></a><span class="nroffip">CURL_NETRC_IGNORED</span>
|
||||
<p class="level2">The library will ignore the file and use only the information in the URL.
|
||||
<p class="level2">This is the default.
|
||||
<p class="level1"><a name="CURLNETRCREQUIRED"></a><span class="nroffip">CURL_NETRC_REQUIRED</span>
|
||||
<p class="level2">This value tells the library that use of the file is required, to ignore the information in the URL, and to search the file with the host only.
|
||||
<p class="level1">Only machine name, user name and password are taken into account (init macros and similar things aren't supported).
|
||||
<p class="level1">libcurl does not verify that the file has the correct properties set (as the standard Unix ftp client does). It should only be readable by user.
|
||||
<p class="level0"><a name="CURLOPTNETRCFILE"></a><span class="nroffip">CURLOPT_NETRC_FILE</span>
|
||||
<p class="level1">Pass a char * as parameter, pointing to a zero terminated string containing the full path name to the file you want libcurl to use as .netrc file. If this option is omitted, and <a class="emphasis" href="#CURLOPTNETRC">CURLOPT_NETRC</a> is set, libcurl will attempt to find the a .netrc file in the current user's home directory. (Added in 7.10.9)
|
||||
<p class="level0"><a name="CURLOPTUSERPWD"></a><span class="nroffip">CURLOPT_USERPWD</span>
|
||||
<p class="level1">Pass a char * as parameter, which should be [user name]:[password] to use for the connection. Use <a class="emphasis" href="#CURLOPTHTTPAUTH">CURLOPT_HTTPAUTH</a> to decide authentication method.
|
||||
<p class="level1">When using NTLM, you can set domain by prepending it to the user name and separating the domain and name with a forward (/) or backward slash (). Like this: "domain/user:password" or "domainuser:password". Some HTTP servers (on Windows) support this style even for Basic authentication.
|
||||
<p class="level1">When using HTTP and <a class="emphasis" href="#CURLOPTFOLLOWLOCATION">CURLOPT_FOLLOWLOCATION</a>, libcurl might perform several requests to possibly different hosts. libcurl will only send this user and password information to hosts using the initial host name (unless <a class="emphasis" href="#CURLOPTUNRESTRICTEDAUTH">CURLOPT_UNRESTRICTED_AUTH</a> is set), so if libcurl follows locations to other hosts it will not send the user and password to those. This is enforced to prevent accidental information leakage.
|
||||
<p class="level0"><a name="CURLOPTPROXYUSERPWD"></a><span class="nroffip">CURLOPT_PROXYUSERPWD</span>
|
||||
<p class="level1">Pass a char * as parameter, which should be [user name]:[password] to use for the connection to the HTTP proxy. Use <a class="emphasis" href="#CURLOPTPROXYAUTH">CURLOPT_PROXYAUTH</a> to decide authentication method.
|
||||
<p class="level0"><a name="CURLOPTHTTPAUTH"></a><span class="nroffip">CURLOPT_HTTPAUTH</span>
|
||||
<p class="level1">Pass a long as parameter, which is set to a bitmask, to tell libcurl what authentication method(s) you want it to use. The available bits are listed below. If more than one bit is set, libcurl will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. For some methods, this will induce an extra network round-trip. Set the actual name and password with the <a class="emphasis" href="#CURLOPTUSERPWD">CURLOPT_USERPWD</a> option. (Added in 7.10.6)
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLAUTHBASIC"></a><span class="nroffip">CURLAUTH_BASIC</span>
|
||||
<p class="level2">HTTP Basic authentication. This is the default choice, and the only method that is in wide-spread use and supported virtually everywhere. This is sending the user name and password over the network in plain text, easily captured by others.
|
||||
<p class="level1"><a name="CURLAUTHDIGEST"></a><span class="nroffip">CURLAUTH_DIGEST</span>
|
||||
<p class="level2">HTTP Digest authentication. Digest authentication is defined in RFC2617 and is a more secure way to do authentication over public networks than the regular old-fashioned Basic method.
|
||||
<p class="level1"><a name="CURLAUTHGSSNEGOTIATE"></a><span class="nroffip">CURLAUTH_GSSNEGOTIATE</span>
|
||||
<p class="level2">HTTP GSS-Negotiate authentication. The GSS-Negotiate (also known as plain "Negotiate") method was designed by Microsoft and is used in their web applications. It is primarily meant as a support for Kerberos5 authentication but may be also used along with another authentication methods. For more information see IETF draft draft-brezak-spnego-http-04.txt.
|
||||
<p class="level2">You need to build libcurl with a suitable GSS-API library for this to work.
|
||||
<p class="level1"><a name="CURLAUTHNTLM"></a><span class="nroffip">CURLAUTH_NTLM</span>
|
||||
<p class="level2">HTTP NTLM authentication. A proprietary protocol invented and used by Microsoft. It uses a challenge-response and hash concept similar to Digest, to prevent the password from being eavesdropped.
|
||||
<p class="level2">You need to build libcurl with OpenSSL support for this option to work, or build libcurl on Windows.
|
||||
<p class="level1"><a name="CURLAUTHANY"></a><span class="nroffip">CURLAUTH_ANY</span>
|
||||
<p class="level2">This is a convenience macro that sets all bits and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure.
|
||||
<p class="level1"><a name="CURLAUTHANYSAFE"></a><span class="nroffip">CURLAUTH_ANYSAFE</span>
|
||||
<p class="level2">This is a convenience macro that sets all bits except Basic and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTPROXYAUTH"></a><span class="nroffip">CURLOPT_PROXYAUTH</span>
|
||||
<p class="level1">Pass a long as parameter, which is set to a bitmask, to tell libcurl what authentication method(s) you want it to use for your proxy authentication. If more than one bit is set, libcurl will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. For some methods, this will induce an extra network round-trip. Set the actual name and password with the <a class="emphasis" href="#CURLOPTPROXYUSERPWD">CURLOPT_PROXYUSERPWD</a> option. The bitmask can be constructed by or'ing together the bits listed above for the <a class="emphasis" href="#CURLOPTHTTPAUTH">CURLOPT_HTTPAUTH</a> option. As of this writing, only Basic, Digest and NTLM work. (Added in 7.10.7) <a name="HTTP"></a><h2 class="nroffsh">HTTP OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTAUTOREFERER"></a><span class="nroffip">CURLOPT_AUTOREFERER</span>
|
||||
<p class="level1">Pass a non-zero parameter to enable this. When enabled, libcurl will automatically set the Referer: field in requests where it follows a Location: redirect.
|
||||
<p class="level0"><a name="CURLOPTENCODING"></a><span class="nroffip">CURLOPT_ENCODING</span>
|
||||
<p class="level1">Sets the contents of the Accept-Encoding: header sent in an HTTP request, and enables decoding of a response when a Content-Encoding: header is received. Three encodings are supported: <span Class="emphasis">identity</span>, which does nothing, <span Class="emphasis">deflate</span> which requests the server to compress its response using the zlib algorithm, and <span Class="emphasis">gzip</span> which requests the gzip algorithm. If a zero-length string is set, then an Accept-Encoding: header containing all supported encodings is sent.
|
||||
<p class="level1">This is a request, not an order; the server may or may not do it. This option must be set (to any non-NULL value) or else any unsolicited encoding done by the server is ignored. See the special file lib/README.encoding for details.
|
||||
<p class="level0"><a name="CURLOPTFOLLOWLOCATION"></a><span class="nroffip">CURLOPT_FOLLOWLOCATION</span>
|
||||
<p class="level1">A non-zero parameter tells the library to follow any Location: header that the server sends as part of an HTTP header.
|
||||
<p class="level1">This means that the library will re-send the same request on the new location and follow new Location: headers all the way until no more such headers are returned. <a class="emphasis" href="#CURLOPTMAXREDIRS">CURLOPT_MAXREDIRS</a> can be used to limit the number of redirects libcurl will follow.
|
||||
<p class="level0"><a name="CURLOPTUNRESTRICTEDAUTH"></a><span class="nroffip">CURLOPT_UNRESTRICTED_AUTH</span>
|
||||
<p class="level1">A non-zero parameter tells the library it can continue to send authentication (user+password) when following locations, even when hostname changed. This option is meaningful only when setting <a class="emphasis" href="#CURLOPTFOLLOWLOCATION">CURLOPT_FOLLOWLOCATION</a>.
|
||||
<p class="level0"><a name="CURLOPTMAXREDIRS"></a><span class="nroffip">CURLOPT_MAXREDIRS</span>
|
||||
<p class="level1">Pass a long. The set number will be the redirection limit. If that many redirections have been followed, the next redirect will cause an error (<span Class="emphasis">CURLE_TOO_MANY_REDIRECTS</span>). This option only makes sense if the <a class="emphasis" href="#CURLOPTFOLLOWLOCATION">CURLOPT_FOLLOWLOCATION</a> is used at the same time. Added in 7.15.1: Setting the limit to 0 will make libcurl refuse any redirect. Set it to -1 for an infinite number of redirects (which is the default)
|
||||
<p class="level0"><a name="CURLOPTPUT"></a><span class="nroffip">CURLOPT_PUT</span>
|
||||
<p class="level1">A non-zero parameter tells the library to use HTTP PUT to transfer data. The data should be set with <a class="emphasis" href="#CURLOPTREADDATA">CURLOPT_READDATA</a> and <a class="emphasis" href="#CURLOPTINFILESIZE">CURLOPT_INFILESIZE</a>.
|
||||
<p class="level1">This option is deprecated and starting with version 7.12.1 you should instead use <a class="emphasis" href="#CURLOPTUPLOAD">CURLOPT_UPLOAD</a>.
|
||||
<p class="level0"><a name="CURLOPTPOST"></a><span class="nroffip">CURLOPT_POST</span>
|
||||
<p class="level1">A non-zero parameter tells the library to do a regular HTTP post. This will also make the library use the a "Content-Type: application/x-www-form-urlencoded" header. (This is by far the most commonly used POST method).
|
||||
<p class="level1">Use the <a class="emphasis" href="#CURLOPTPOSTFIELDS">CURLOPT_POSTFIELDS</a> option to specify what data to post and <a class="emphasis" href="#CURLOPTPOSTFIELDSIZE">CURLOPT_POSTFIELDSIZE</a> to set the data size.
|
||||
<p class="level1">Optionally, you can provide data to POST using the <a class="emphasis" href="#CURLOPTREADFUNCTION">CURLOPT_READFUNCTION</a> and <a class="emphasis" href="#CURLOPTREADDATA">CURLOPT_READDATA</a> options but then you must make sure to not set <a class="emphasis" href="#CURLOPTPOSTFIELDS">CURLOPT_POSTFIELDS</a> to anything but NULL. When providing data with a callback, you must transmit it using chunked transfer-encoding or you must set the size of the data with the <a class="emphasis" href="#CURLOPTPOSTFIELDSIZE">CURLOPT_POSTFIELDSIZE</a> option.
|
||||
<p class="level1">You can override the default POST Content-Type: header by setting your own with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a>.
|
||||
<p class="level1">Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a> as usual.
|
||||
<p class="level1">If you use POST to a HTTP 1.1 server, you can send data without knowing the size before starting the POST if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a>. With HTTP 1.0 or without chunked transfer, you must specify the size in the request.
|
||||
<p class="level1">When setting <a class="emphasis" href="#CURLOPTPOST">CURLOPT_POST</a> to a non-zero value, it will automatically set <a class="emphasis" href="#CURLOPTNOBODY">CURLOPT_NOBODY</a> to 0 (since 7.14.1).
|
||||
<p class="level1">If you issue a POST request and then want to make a HEAD or GET using the same re-used handle, you must explictly set the new request type using <a class="emphasis" href="#CURLOPTNOBODY">CURLOPT_NOBODY</a> or <a class="emphasis" href="#CURLOPTHTTPGET">CURLOPT_HTTPGET</a> or similar.
|
||||
<p class="level0"><a name="CURLOPTPOSTFIELDS"></a><span class="nroffip">CURLOPT_POSTFIELDS</span>
|
||||
<p class="level1">Pass a char * as parameter, which should be the full data to post in an HTTP POST operation. You must make sure that the data is formatted the way you want the server to receive it. libcurl will not convert or encode it for you. Most web servers will assume this data to be url-encoded. Take note.
|
||||
<p class="level1">This POST is a normal application/x-www-form-urlencoded kind (and libcurl will set that Content-Type by default when this option is used), which is the most commonly used one by HTML forms. See also the <a class="emphasis" href="#CURLOPTPOST">CURLOPT_POST</a>. Using <a class="emphasis" href="#CURLOPTPOSTFIELDS">CURLOPT_POSTFIELDS</a> implies <a class="emphasis" href="#CURLOPTPOST">CURLOPT_POST</a>.
|
||||
<p class="level1">Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a> as usual.
|
||||
<p class="level1">To make multipart/formdata posts (aka rfc1867-posts), check out the <a class="emphasis" href="#CURLOPTHTTPPOST">CURLOPT_HTTPPOST</a> option.
|
||||
<p class="level0"><a name="CURLOPTPOSTFIELDSIZE"></a><span class="nroffip">CURLOPT_POSTFIELDSIZE</span>
|
||||
<p class="level1">If you want to post data to the server without letting libcurl do a strlen() to measure the data size, this option must be used. When this option is used you can post fully binary data, which otherwise is likely to fail. If this size is set to -1, the library will use strlen() to get the size.
|
||||
<p class="level0"><a name="CURLOPTPOSTFIELDSIZELARGE"></a><span class="nroffip">CURLOPT_POSTFIELDSIZE_LARGE</span>
|
||||
<p class="level1">Pass a curl_off_t as parameter. Use this to set the size of the <a class="emphasis" href="#CURLOPTPOSTFIELDS">CURLOPT_POSTFIELDS</a> data to prevent libcurl from doing strlen() on the data to figure out the size. This is the large file version of the <a class="emphasis" href="#CURLOPTPOSTFIELDSIZE">CURLOPT_POSTFIELDSIZE</a> option. (Added in 7.11.1)
|
||||
<p class="level0"><a name="CURLOPTHTTPPOST"></a><span class="nroffip">CURLOPT_HTTPPOST</span>
|
||||
<p class="level1">Tells libcurl you want a multipart/formdata HTTP POST to be made and you instruct what data to pass on to the server. Pass a pointer to a linked list of curl_httppost structs as parameter. . The easiest way to create such a list, is to use <a class="emphasis" href="./curl_formadd.html">curl_formadd(3)</a> as documented. The data in this list must remain intact until you close this curl handle again with <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a>.
|
||||
<p class="level1">Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a> as usual.
|
||||
<p class="level1">When setting <a class="emphasis" href="#CURLOPTHTTPPOST">CURLOPT_HTTPPOST</a>, it will automatically set <a class="emphasis" href="#CURLOPTNOBODY">CURLOPT_NOBODY</a> to 0 (since 7.14.1).
|
||||
<p class="level0"><a name="CURLOPTREFERER"></a><span class="nroffip">CURLOPT_REFERER</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used to set the Referer: header in the http request sent to the remote server. This can be used to fool servers or scripts. You can also set any custom header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a>.
|
||||
<p class="level0"><a name="CURLOPTUSERAGENT"></a><span class="nroffip">CURLOPT_USERAGENT</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used to set the User-Agent: header in the http request sent to the remote server. This can be used to fool servers or scripts. You can also set any custom header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a>.
|
||||
<p class="level0"><a name="CURLOPTHTTPHEADER"></a><span class="nroffip">CURLOPT_HTTPHEADER</span>
|
||||
<p class="level1">Pass a pointer to a linked list of HTTP headers to pass to the server in your HTTP request. The linked list should be a fully valid list of <span class="bold">struct curl_slist</span> structs properly filled in. Use <a class="emphasis" href="./curl_slist_append.html">curl_slist_append(3)</a> to create the list and <a class="emphasis" href="./curl_slist_free_all.html">curl_slist_free_all(3)</a> to clean up an entire list. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no contents as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no contents, make the contents be two quotes: "". The headers included in the linked list must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified.
|
||||
<p class="level1">The first line in a request (containing the method, usually a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers. Adding this method line in this list of headers will only cause your request to send an invalid header.
|
||||
<p class="level1">Pass a NULL to this to reset back to no custom headers.
|
||||
<p class="level1">The most commonly replaced headers have "shortcuts" in the options <a class="emphasis" href="#CURLOPTCOOKIE">CURLOPT_COOKIE</a>, <a class="emphasis" href="#CURLOPTUSERAGENT">CURLOPT_USERAGENT</a> and <a class="emphasis" href="#CURLOPTREFERER">CURLOPT_REFERER</a>.
|
||||
<p class="level0"><a name="CURLOPTHTTP200ALIASES"></a><span class="nroffip">CURLOPT_HTTP200ALIASES</span>
|
||||
<p class="level1">Pass a pointer to a linked list of aliases to be treated as valid HTTP 200 responses. Some servers respond with a custom header response line. For example, IceCast servers respond with "ICY 200 OK". By including this string in your list of aliases, the response will be treated as a valid HTTP header line such as "HTTP/1.0 200 OK". (Added in 7.10.3)
|
||||
<p class="level1">The linked list should be a fully valid list of struct curl_slist structs, and be properly filled in. Use <a class="emphasis" href="./curl_slist_append.html">curl_slist_append(3)</a> to create the list and <a class="emphasis" href="./curl_slist_free_all.html">curl_slist_free_all(3)</a> to clean up an entire list.
|
||||
<p class="level1">The alias itself is not parsed for any version strings. So if your alias is "MYHTTP/9.9", Libcurl will not treat the server as responding with HTTP version 9.9. Instead Libcurl will use the value set by option <a class="emphasis" href="#CURLOPTHTTPVERSION">CURLOPT_HTTP_VERSION</a>.
|
||||
<p class="level0"><a name="CURLOPTCOOKIE"></a><span class="nroffip">CURLOPT_COOKIE</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used to set a cookie in the http request. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
|
||||
<p class="level1">If you need to set multiple cookies, you need to set them all using a single option and thus you need to concatenate them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
|
||||
<p class="level1">Using this option multiple times will only make the latest string override the previously ones.
|
||||
<p class="level0"><a name="CURLOPTCOOKIEFILE"></a><span class="nroffip">CURLOPT_COOKIEFILE</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It should contain the name of your file holding cookie data to read. The cookie data may be in Netscape / Mozilla cookie data format or just regular HTTP-style headers dumped to a file.
|
||||
<p class="level1">Given an empty or non-existing file or by passing the empty string (""), this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future request.
|
||||
<p class="level1">If you use this option multiple times, you just add more files to read. Subsequent files will add more cookies.
|
||||
<p class="level0"><a name="CURLOPTCOOKIEJAR"></a><span class="nroffip">CURLOPT_COOKIEJAR</span>
|
||||
<p class="level1">Pass a file name as char *, zero terminated. This will make libcurl write all internally known cookies to the specified file when <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a> is called. If no cookies are known, no file will be created. Specify "-" to instead have the cookies written to stdout. Using this option also enables cookies for this session, so if you for example follow a location it will make matching cookies get sent accordingly.
|
||||
<p class="level1">If the cookie jar file can't be created or written to (when the <a class="emphasis" href="./curl_easy_cleanup.html">curl_easy_cleanup(3)</a> is called), libcurl will not and cannot report an error for this. Using <a class="emphasis" href="#CURLOPTVERBOSE">CURLOPT_VERBOSE</a> or <a class="emphasis" href="#CURLOPTDEBUGFUNCTION">CURLOPT_DEBUGFUNCTION</a> will get a warning to display, but that is the only visible feedback you get about this possibly lethal situation.
|
||||
<p class="level0"><a name="CURLOPTCOOKIESESSION"></a><span class="nroffip">CURLOPT_COOKIESESSION</span>
|
||||
<p class="level1">Pass a long set to non-zero to mark this as a new cookie "session". It will force libcurl to ignore all cookies it is about to load that are "session cookies" from the previous session. By default, libcurl always stores and loads all cookies, independent if they are session cookies are not. Session cookies are cookies without expiry date and they are meant to be alive and existing for this "session" only.
|
||||
<p class="level0"><a name="CURLOPTCOOKIELIST"></a><span class="nroffip">CURLOPT_COOKIELIST</span>
|
||||
<p class="level1">Pass a char * to a cookie string. Cookie can be either in Netscape / Mozilla format or just regular HTTP-style header (Set-Cookie: ...) format. If cURL cookie engine was not enabled it will enable its cookie engine. Passing a magic string "ALL" will erase all cookies known by cURL. (Added in 7.14.1) Passing the special string "SESS" will only erase all session cookies known by cURL. (Added in 7.15.4)
|
||||
<p class="level0"><a name="CURLOPTHTTPGET"></a><span class="nroffip">CURLOPT_HTTPGET</span>
|
||||
<p class="level1">Pass a long. If the long is non-zero, this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle.
|
||||
<p class="level1">When setting <a class="emphasis" href="#CURLOPTHTTPGET">CURLOPT_HTTPGET</a> to a non-zero value, it will automatically set <a class="emphasis" href="#CURLOPTNOBODY">CURLOPT_NOBODY</a> to 0 (since 7.14.1).
|
||||
<p class="level0"><a name="CURLOPTHTTPVERSION"></a><span class="nroffip">CURLOPT_HTTP_VERSION</span>
|
||||
<p class="level1">Pass a long, set to one of the values described below. They force libcurl to use the specific HTTP versions. This is not sensible to do unless you have a good reason.
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLHTTPVERSIONNONE"></a><span class="nroffip">CURL_HTTP_VERSION_NONE</span>
|
||||
<p class="level2">We don't care about what version the library uses. libcurl will use whatever it thinks fit.
|
||||
<p class="level1"><a name="CURLHTTPVERSION10"></a><span class="nroffip">CURL_HTTP_VERSION_1_0</span>
|
||||
<p class="level2">Enforce HTTP 1.0 requests.
|
||||
<p class="level1"><a name="CURLHTTPVERSION11"></a><span class="nroffip">CURL_HTTP_VERSION_1_1</span>
|
||||
<p class="level2">Enforce HTTP 1.1 requests.
|
||||
<p class="level1"><a name="CURLOPTIGNORECONTENTLENGTH"></a><span class="nroffip">CURLOPT_IGNORE_CONTENT_LENGTH</span>
|
||||
<p class="level2">Ignore the Content-Length header. This is useful for Apache 1.x (and similar servers) which will report incorrect content length for files over 2 gigabytes. If this option is used, curl will not be able to accurately report progress, and will simply stop the download when the server ends the connection. (added in 7.14.1)
|
||||
<p class="level1"><a name="FTP"></a><h2 class="nroffsh">FTP OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTFTPPORT"></a><span class="nroffip">CURLOPT_FTPPORT</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used to get the IP address to use for the ftp PORT instruction. The PORT instruction tells the remote server to connect to our specified IP address. The string may be a plain IP address, a host name, an network interface name (under Unix) or just a '-' letter to let the library use your systems default IP address. Default FTP operations are passive, and thus won't use PORT.
|
||||
<p class="level1">You disable PORT again and go back to using the passive version by setting this option to NULL.
|
||||
<p class="level0"><a name="CURLOPTQUOTE"></a><span class="nroffip">CURLOPT_QUOTE</span>
|
||||
<p class="level1">Pass a pointer to a linked list of FTP commands to pass to the server prior to your ftp request. This will be done before any other FTP commands are issued (even before the CWD command). The linked list should be a fully valid list of 'struct curl_slist' structs properly filled in. Use <a class="emphasis" href="./curl_slist_append.html">curl_slist_append(3)</a> to append strings (commands) to the list, and clear the entire list afterwards with <a class="emphasis" href="./curl_slist_free_all.html">curl_slist_free_all(3)</a>. Disable this operation again by setting a NULL to this option.
|
||||
<p class="level0"><a name="CURLOPTPOSTQUOTE"></a><span class="nroffip">CURLOPT_POSTQUOTE</span>
|
||||
<p class="level1">Pass a pointer to a linked list of FTP commands to pass to the server after your ftp transfer request. The linked list should be a fully valid list of struct curl_slist structs properly filled in as described for <a class="emphasis" href="#CURLOPTQUOTE">CURLOPT_QUOTE</a>. Disable this operation again by setting a NULL to this option.
|
||||
<p class="level0"><a name="CURLOPTPREQUOTE"></a><span class="nroffip">CURLOPT_PREQUOTE</span>
|
||||
<p class="level1">Pass a pointer to a linked list of FTP commands to pass to the server after the transfer type is set. The linked list should be a fully valid list of struct curl_slist structs properly filled in as described for <a class="emphasis" href="#CURLOPTQUOTE">CURLOPT_QUOTE</a>. Disable this operation again by setting a NULL to this option. Before version 7.15.6, if you also set <a class="emphasis" href="#CURLOPTNOBODY">CURLOPT_NOBODY</a> non-zero, this option didn't work.
|
||||
<p class="level0"><a name="CURLOPTFTPLISTONLY"></a><span class="nroffip">CURLOPT_FTPLISTONLY</span>
|
||||
<p class="level1">A non-zero parameter tells the library to just list the names of an ftp directory, instead of doing a full directory listing that would include file sizes, dates etc.
|
||||
<p class="level1">This causes an FTP NLST command to be sent. Beware that some FTP servers list only files in their response to NLST; they might not include subdirectories and symbolic links.
|
||||
<p class="level0"><a name="CURLOPTFTPAPPEND"></a><span class="nroffip">CURLOPT_FTPAPPEND</span>
|
||||
<p class="level1">A non-zero parameter tells the library to append to the remote file instead of overwrite it. This is only useful when uploading to an ftp site.
|
||||
<p class="level0"><a name="CURLOPTFTPUSEEPRT"></a><span class="nroffip">CURLOPT_FTP_USE_EPRT</span>
|
||||
<p class="level1">Pass a long. If the value is non-zero, it tells curl to use the EPRT (and LPRT) command when doing active FTP downloads (which is enabled by <a class="emphasis" href="#CURLOPTFTPPORT">CURLOPT_FTPPORT</a>). Using EPRT means that it will first attempt to use EPRT and then LPRT before using PORT, but if you pass FALSE (zero) to this option, it will not try using EPRT or LPRT, only plain PORT. (Added in 7.10.5)
|
||||
<p class="level1">If the server is an IPv6 host, this option will have no effect as of 7.12.3.
|
||||
<p class="level0"><a name="CURLOPTFTPUSEEPSV"></a><span class="nroffip">CURLOPT_FTP_USE_EPSV</span>
|
||||
<p class="level1">Pass a long. If the value is non-zero, it tells curl to use the EPSV command when doing passive FTP downloads (which it always does by default). Using EPSV means that it will first attempt to use EPSV before using PASV, but if you pass FALSE (zero) to this option, it will not try using EPSV, only plain PASV.
|
||||
<p class="level1">If the server is an IPv6 host, this option will have no effect as of 7.12.3.
|
||||
<p class="level0"><a name="CURLOPTFTPCREATEMISSINGDIRS"></a><span class="nroffip">CURLOPT_FTP_CREATE_MISSING_DIRS</span>
|
||||
<p class="level1">Pass a long. If the value is non-zero, curl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory. (Added in 7.10.7)
|
||||
<p class="level0"><a name="CURLOPTFTPRESPONSETIMEOUT"></a><span class="nroffip">CURLOPT_FTP_RESPONSE_TIMEOUT</span>
|
||||
<p class="level1">Pass a long. Causes curl to set a timeout period (in seconds) on the amount of time that the server is allowed to take in order to generate a response message for a command before the session is considered hung. While curl is waiting for a response, this value overrides <a class="emphasis" href="#CURLOPTTIMEOUT">CURLOPT_TIMEOUT</a>. It is recommended that if used in conjunction with <a class="emphasis" href="#CURLOPTTIMEOUT">CURLOPT_TIMEOUT</a>, you set <a class="emphasis" href="#CURLOPTFTPRESPONSETIMEOUT">CURLOPT_FTP_RESPONSE_TIMEOUT</a> to a value smaller than <a class="emphasis" href="#CURLOPTTIMEOUT">CURLOPT_TIMEOUT</a>. (Added in 7.10.8)
|
||||
<p class="level0"><a name="CURLOPTFTPALTERNATIVETOUSER"></a><span class="nroffip">CURLOPT_FTP_ALTERNATIVE_TO_USER</span>
|
||||
<p class="level1">Pass a char * as parameter, pointing to a string which will be used to authenticate if the usual FTP "USER user" and "PASS password" negotiation fails. This is currently only known to be required when connecting to Tumbleweed's Secure Transport FTPS server using client certificates for authentication. (Added in 7.15.5)
|
||||
<p class="level0"><a name="CURLOPTFTPSKIPPASVIP"></a><span class="nroffip">CURLOPT_FTP_SKIP_PASV_IP</span>
|
||||
<p class="level1">Pass a long. If set to a non-zero value, it instructs libcurl to not use the IP address the server suggests in its 227-response to libcurl's PASV command when libcurl connects the data connection. Instead libcurl will re-use the same IP address it already uses for the control connection. But it will use the port number from the 227-response. (Added in 7.14.2)
|
||||
<p class="level1">This option has no effect if PORT, EPRT or EPSV is used instead of PASV.
|
||||
<p class="level0"><a name="CURLOPTFTPSSL"></a><span class="nroffip">CURLOPT_FTP_SSL</span>
|
||||
<p class="level1">Pass a long using one of the values from below, to make libcurl use your desired level of SSL for the ftp transfer. (Added in 7.11.0)
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLFTPSSLNONE"></a><span class="nroffip">CURLFTPSSL_NONE</span>
|
||||
<p class="level2">Don't attempt to use SSL.
|
||||
<p class="level1"><a name="CURLFTPSSLTRY"></a><span class="nroffip">CURLFTPSSL_TRY</span>
|
||||
<p class="level2">Try using SSL, proceed as normal otherwise.
|
||||
<p class="level1"><a name="CURLFTPSSLCONTROL"></a><span class="nroffip">CURLFTPSSL_CONTROL</span>
|
||||
<p class="level2">Require SSL for the control connection or fail with <span Class="emphasis">CURLE_FTP_SSL_FAILED</span>.
|
||||
<p class="level1"><a name="CURLFTPSSLALL"></a><span class="nroffip">CURLFTPSSL_ALL</span>
|
||||
<p class="level2">Require SSL for all communication or fail with <span Class="emphasis">CURLE_FTP_SSL_FAILED</span>.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTFTPSSLAUTH"></a><span class="nroffip">CURLOPT_FTPSSLAUTH</span>
|
||||
<p class="level1">Pass a long using one of the values from below, to alter how libcurl issues "AUTH TLS" or "AUTH SSL" when FTP over SSL is activated (see <a class="emphasis" href="#CURLOPTFTPSSL">CURLOPT_FTP_SSL</a>). (Added in 7.12.2)
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLFTPAUTHDEFAULT"></a><span class="nroffip">CURLFTPAUTH_DEFAULT</span>
|
||||
<p class="level2">Allow libcurl to decide
|
||||
<p class="level1"><a name="CURLFTPAUTHSSL"></a><span class="nroffip">CURLFTPAUTH_SSL</span>
|
||||
<p class="level2">Try "AUTH SSL" first, and only if that fails try "AUTH TLS"
|
||||
<p class="level1"><a name="CURLFTPAUTHTLS"></a><span class="nroffip">CURLFTPAUTH_TLS</span>
|
||||
<p class="level2">Try "AUTH TLS" first, and only if that fails try "AUTH SSL"
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTFTPACCOUNT"></a><span class="nroffip">CURLOPT_FTP_ACCOUNT</span>
|
||||
<p class="level1">Pass a pointer to a zero-terminated string (or NULL to disable). When an FTP server asks for "account data" after user name and password has been provided, this data is sent off using the ACCT command. (Added in 7.13.0)
|
||||
<p class="level0"><a name="CURLOPTFTPFILEMETHOD"></a><span class="nroffip">CURLOPT_FTP_FILEMETHOD</span>
|
||||
<p class="level1">Pass a long that should have one of the following values. This option controls what method libcurl should use to reach a file on a FTP(S) server. The argument should be one of the following alternatives:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLFTPMETHODMULTICWD"></a><span class="nroffip">CURLFTPMETHOD_MULTICWD</span>
|
||||
<p class="level2">libcurl does a single CWD operation for each path part in the given URL. For deep hierarchies this means very many commands. This is how RFC1738 says it should be done. This is the default but the slowest behavior.
|
||||
<p class="level1"><a name="CURLFTPMETHODNOCWD"></a><span class="nroffip">CURLFTPMETHOD_NOCWD</span>
|
||||
<p class="level2">libcurl does no CWD at all. libcurl will do SIZE, RETR, STOR etc and give a full path to the server for all these commands. This is the fastest behavior.
|
||||
<p class="level1"><a name="CURLFTPMETHODSINGLECWD"></a><span class="nroffip">CURLFTPMETHOD_SINGLECWD</span>
|
||||
<p class="level2">libcurl does one CWD with the full target directory and then operates on the file "normally" (like in the multicwd case). This is somewhat more standards compliant than 'nocwd' but without the full penalty of 'multicwd'.
|
||||
<p class="level1"><a name="PROTOCOL"></a><h2 class="nroffsh">PROTOCOL OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTTRANSFERTEXT"></a><span class="nroffip">CURLOPT_TRANSFERTEXT</span>
|
||||
<p class="level1">A non-zero parameter tells the library to use ASCII mode for ftp transfers, instead of the default binary transfer. For win32 systems it does not set the stdout to binary mode. This option can be usable when transferring text data between systems with different views on certain characters, such as newlines or similar.
|
||||
<p class="level1">libcurl does not do a complete ASCII conversion when doing ASCII transfers over FTP. This is a known limitation/flaw that nobody has rectified. libcurl simply sets the mode to ascii and performs a standard transfer.
|
||||
<p class="level0"><a name="CURLOPTCRLF"></a><span class="nroffip">CURLOPT_CRLF</span>
|
||||
<p class="level1">Convert Unix newlines to CRLF newlines on transfers.
|
||||
<p class="level0"><a name="CURLOPTRANGE"></a><span class="nroffip">CURLOPT_RANGE</span>
|
||||
<p class="level1">Pass a char * as parameter, which should contain the specified range you want. It should be in the format "X-Y", where X or Y may be left out. HTTP transfers also support several intervals, separated with commas as in <span Class="emphasis">"X-Y,N-M"</span>. Using this kind of multiple intervals will cause the HTTP server to send the response document in pieces (using standard MIME separation techniques). Pass a NULL to this option to disable the use of ranges.
|
||||
<p class="level0"><a name="CURLOPTRESUMEFROM"></a><span class="nroffip">CURLOPT_RESUME_FROM</span>
|
||||
<p class="level1">Pass a long as parameter. It contains the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file (useful to continue an interrupted upload).
|
||||
<p class="level0"><a name="CURLOPTRESUMEFROMLARGE"></a><span class="nroffip">CURLOPT_RESUME_FROM_LARGE</span>
|
||||
<p class="level1">Pass a curl_off_t as parameter. It contains the offset in number of bytes that you want the transfer to start from. (Added in 7.11.0)
|
||||
<p class="level0"><a name="CURLOPTCUSTOMREQUEST"></a><span class="nroffip">CURLOPT_CUSTOMREQUEST</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be user instead of GET or HEAD when doing an HTTP request, or instead of LIST or NLST when doing an ftp directory listing. This is useful for doing DELETE or other more or less obscure HTTP requests. Don't do this at will, make sure your server supports the command first.
|
||||
<p class="level1">Restore to the internal default by setting this to NULL.
|
||||
<p class="level1">Many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. While that might work in many cases, it will cause libcurl to send invalid requests and it could possibly confuse the remote server badly. Use <a class="emphasis" href="#CURLOPTPOST">CURLOPT_POST</a> and <a class="emphasis" href="#CURLOPTPOSTFIELDS">CURLOPT_POSTFIELDS</a> to set POST data. Use <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a> to replace or extend the set of headers sent by libcurl. Use <a class="emphasis" href="#CURLOPTHTTPVERSION">CURLOPT_HTTP_VERSION</a> to change HTTP version.
|
||||
<p class="level0"><a name="CURLOPTFILETIME"></a><span class="nroffip">CURLOPT_FILETIME</span>
|
||||
<p class="level1">Pass a long. If it is a non-zero value, libcurl will attempt to get the modification date of the remote document in this operation. This requires that the remote server sends the time or replies to a time querying command. The <a class="emphasis" href="./curl_easy_getinfo.html">curl_easy_getinfo(3)</a> function with the <span Class="emphasis">CURLINFO_FILETIME</span> argument can be used after a transfer to extract the received time (if any).
|
||||
<p class="level0"><a name="CURLOPTNOBODY"></a><span class="nroffip">CURLOPT_NOBODY</span>
|
||||
<p class="level1">A non-zero parameter tells the library to not include the body-part in the output. This is only relevant for protocols that have separate header and body parts. On HTTP(S) servers, this will make libcurl do a HEAD request.
|
||||
<p class="level1">To change request to GET, you should use <a class="emphasis" href="#CURLOPTHTTPGET">CURLOPT_HTTPGET</a>. Change request to POST with <a class="emphasis" href="#CURLOPTPOST">CURLOPT_POST</a> etc.
|
||||
<p class="level0"><a name="CURLOPTINFILESIZE"></a><span class="nroffip">CURLOPT_INFILESIZE</span>
|
||||
<p class="level1">When uploading a file to a remote site, this option should be used to tell libcurl what the expected size of the infile is. This value should be passed as a long. See also <a class="emphasis" href="#CURLOPTINFILESIZELARGE">CURLOPT_INFILESIZE_LARGE</a>.
|
||||
<p class="level0"><a name="CURLOPTINFILESIZELARGE"></a><span class="nroffip">CURLOPT_INFILESIZE_LARGE</span>
|
||||
<p class="level1">When uploading a file to a remote site, this option should be used to tell libcurl what the expected size of the infile is. This value should be passed as a curl_off_t. (Added in 7.11.0)
|
||||
<p class="level0"><a name="CURLOPTUPLOAD"></a><span class="nroffip">CURLOPT_UPLOAD</span>
|
||||
<p class="level1">A non-zero parameter tells the library to prepare for an upload. The <a class="emphasis" href="#CURLOPTREADDATA">CURLOPT_READDATA</a> and <a class="emphasis" href="#CURLOPTINFILESIZE">CURLOPT_INFILESIZE</a> or <a class="emphasis" href="#CURLOPTINFILESIZELARGE">CURLOPT_INFILESIZE_LARGE</a> options are also interesting for uploads. If the protocol is HTTP, uploading means using the PUT request unless you tell libcurl otherwise.
|
||||
<p class="level1">Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a> as usual.
|
||||
<p class="level1">If you use PUT to a HTTP 1.1 server, you can upload data without knowing the size before starting the transfer if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with <a class="emphasis" href="#CURLOPTHTTPHEADER">CURLOPT_HTTPHEADER</a>. With HTTP 1.0 or without chunked transfer, you must specify the size.
|
||||
<p class="level0"><a name="CURLOPTMAXFILESIZE"></a><span class="nroffip">CURLOPT_MAXFILESIZE</span>
|
||||
<p class="level1">Pass a long as parameter. This allows you to specify the maximum size (in bytes) of a file to download. If the file requested is larger than this value, the transfer will not start and CURLE_FILESIZE_EXCEEDED will be returned.
|
||||
<p class="level1">The file size is not always known prior to download, and for such files this option has no effect even if the file transfer ends up being larger than this given limit. This concerns both FTP and HTTP transfers.
|
||||
<p class="level0"><a name="CURLOPTMAXFILESIZELARGE"></a><span class="nroffip">CURLOPT_MAXFILESIZE_LARGE</span>
|
||||
<p class="level1">Pass a curl_off_t as parameter. This allows you to specify the maximum size (in bytes) of a file to download. If the file requested is larger than this value, the transfer will not start and <span Class="emphasis">CURLE_FILESIZE_EXCEEDED</span> will be returned. (Added in 7.11.0)
|
||||
<p class="level1">The file size is not always known prior to download, and for such files this option has no effect even if the file transfer ends up being larger than this given limit. This concerns both FTP and HTTP transfers.
|
||||
<p class="level0"><a name="CURLOPTTIMECONDITION"></a><span class="nroffip">CURLOPT_TIMECONDITION</span>
|
||||
<p class="level1">Pass a long as parameter. This defines how the <a class="emphasis" href="#CURLOPTTIMEVALUE">CURLOPT_TIMEVALUE</a> time value is treated. You can set this parameter to <span Class="emphasis">CURL_TIMECOND_IFMODSINCE</span> or <span Class="emphasis">CURL_TIMECOND_IFUNMODSINCE</span>. This feature applies to HTTP and FTP.
|
||||
<p class="level1">The last modification time of a file is not always known and in such instances this feature will have no effect even if the given time condition would have not been met.
|
||||
<p class="level0"><a name="CURLOPTTIMEVALUE"></a><span class="nroffip">CURLOPT_TIMEVALUE</span>
|
||||
<p class="level1">Pass a long as parameter. This should be the time in seconds since 1 jan 1970, and the time will be used in a condition as specified with <a class="emphasis" href="#CURLOPTTIMECONDITION">CURLOPT_TIMECONDITION</a>. <a name="CONNECTION"></a><h2 class="nroffsh">CONNECTION OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTTIMEOUT"></a><span class="nroffip">CURLOPT_TIMEOUT</span>
|
||||
<p class="level1">Pass a long as parameter containing the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. This option will cause curl to use the SIGALRM to enable time-outing system calls.
|
||||
<p class="level1">In unix-like systems, this might cause signals to be used unless <a class="emphasis" href="#CURLOPTNOSIGNAL">CURLOPT_NOSIGNAL</a> is set.
|
||||
<p class="level0"><a name="CURLOPTLOWSPEEDLIMIT"></a><span class="nroffip">CURLOPT_LOW_SPEED_LIMIT</span>
|
||||
<p class="level1">Pass a long as parameter. It contains the transfer speed in bytes per second that the transfer should be below during <a class="emphasis" href="#CURLOPTLOWSPEEDTIME">CURLOPT_LOW_SPEED_TIME</a> seconds for the library to consider it too slow and abort.
|
||||
<p class="level0"><a name="CURLOPTLOWSPEEDTIME"></a><span class="nroffip">CURLOPT_LOW_SPEED_TIME</span>
|
||||
<p class="level1">Pass a long as parameter. It contains the time in seconds that the transfer should be below the <a class="emphasis" href="#CURLOPTLOWSPEEDLIMIT">CURLOPT_LOW_SPEED_LIMIT</a> for the library to consider it too slow and abort.
|
||||
<p class="level0"><a name="CURLOPTMAXSENDSPEEDLARGE"></a><span class="nroffip">CURLOPT_MAX_SEND_SPEED_LARGE</span>
|
||||
<p class="level1">Pass a curl_off_t as parameter. If an upload exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to the parameter value. Defaults to unlimited speed. (Added in 7.15.5)
|
||||
<p class="level0"><a name="CURLOPTMAXRECVSPEEDLARGE"></a><span class="nroffip">CURLOPT_MAX_RECV_SPEED_LARGE</span>
|
||||
<p class="level1">Pass a curl_off_t as parameter. If an upload exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to the parameter value. Defaults to unlimited speed. (Added in 7.15.5)
|
||||
<p class="level0"><a name="CURLOPTMAXCONNECTS"></a><span class="nroffip">CURLOPT_MAXCONNECTS</span>
|
||||
<p class="level1">Pass a long. The set number will be the persistent connection cache size. The set amount will be the maximum amount of simultaneously open connections that libcurl may cache. Default is 5, and there isn't much point in changing this value unless you are perfectly aware of how this work and changes libcurl's behaviour. This concerns connection using any of the protocols that support persistent connections.
|
||||
<p class="level1">When reaching the maximum limit, curl uses the <a class="emphasis" href="#CURLOPTCLOSEPOLICY">CURLOPT_CLOSEPOLICY</a> to figure out which of the existing connections to close to prevent the number of open connections to increase.
|
||||
<p class="level1">If you already have performed transfers with this curl handle, setting a smaller MAXCONNECTS than before may cause open connections to get closed unnecessarily.
|
||||
<p class="level0"><a name="CURLOPTCLOSEPOLICY"></a><span class="nroffip">CURLOPT_CLOSEPOLICY</span>
|
||||
<p class="level1">Pass a long. This option sets what policy libcurl should use when the connection cache is filled and one of the open connections has to be closed to make room for a new connection. This must be one of the CURLCLOSEPOLICY_* defines. Use <span Class="emphasis">CURLCLOSEPOLICY_LEAST_RECENTLY_USED</span> to make libcurl close the connection that was least recently used, that connection is also least likely to be capable of re-use. Use <span Class="emphasis">CURLCLOSEPOLICY_OLDEST</span> to make libcurl close the oldest connection, the one that was created first among the ones in the connection cache. The other close policies are not support yet.
|
||||
<p class="level0"><a name="CURLOPTFRESHCONNECT"></a><span class="nroffip">CURLOPT_FRESH_CONNECT</span>
|
||||
<p class="level1">Pass a long. Set to non-zero to make the next transfer use a new (fresh) connection by force. If the connection cache is full before this connection, one of the existing connections will be closed as according to the selected or default policy. This option should be used with caution and only if you understand what it does. Set this to 0 to have libcurl attempt re-using an existing connection (default behavior).
|
||||
<p class="level0"><a name="CURLOPTFORBIDREUSE"></a><span class="nroffip">CURLOPT_FORBID_REUSE</span>
|
||||
<p class="level1">Pass a long. Set to non-zero to make the next transfer explicitly close the connection when done. Normally, libcurl keep all connections alive when done with one transfer in case there comes a succeeding one that can re-use them. This option should be used with caution and only if you understand what it does. Set to 0 to have libcurl keep the connection open for possibly later re-use (default behavior).
|
||||
<p class="level0"><a name="CURLOPTCONNECTTIMEOUT"></a><span class="nroffip">CURLOPT_CONNECTTIMEOUT</span>
|
||||
<p class="level1">Pass a long. It should contain the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to disable connection timeout (it will then only timeout on the system's internal timeouts). See also the <a class="emphasis" href="#CURLOPTTIMEOUT">CURLOPT_TIMEOUT</a> option.
|
||||
<p class="level1">In unix-like systems, this might cause signals to be used unless <a class="emphasis" href="#CURLOPTNOSIGNAL">CURLOPT_NOSIGNAL</a> is set.
|
||||
<p class="level0"><a name="CURLOPTIPRESOLVE"></a><span class="nroffip">CURLOPT_IPRESOLVE</span>
|
||||
<p class="level1">Allows an application to select what kind of IP addresses to use when resolving host names. This is only interesting when using host names that resolve addresses using more than one version of IP. The allowed values are:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLIPRESOLVEWHATEVER"></a><span class="nroffip">CURL_IPRESOLVE_WHATEVER</span>
|
||||
<p class="level2">Default, resolves addresses to all IP versions that your system allows.
|
||||
<p class="level1"><a name="CURLIPRESOLVEV4"></a><span class="nroffip">CURL_IPRESOLVE_V4</span>
|
||||
<p class="level2">Resolve to ipv4 addresses.
|
||||
<p class="level1"><a name="CURLIPRESOLVEV6"></a><span class="nroffip">CURL_IPRESOLVE_V6</span>
|
||||
<p class="level2">Resolve to ipv6 addresses.
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTCONNECTONLY"></a><span class="nroffip">CURLOPT_CONNECT_ONLY</span>
|
||||
<p class="level1">Pass a long. A non-zero parameter tells the library to perform any required proxy authentication and connection setup, but no data transfer.
|
||||
<p class="level1">This option is useful with the <span Class="emphasis">CURLINFO_LASTSOCKET</span> option to <a class="emphasis" href="./curl_easy_getinfo.html">curl_easy_getinfo(3)</a>. The library can set up the connection and then the application can obtain the most recently used socket for special data transfers. (Added in 7.15.2) <a name="SSL"></a><h2 class="nroffsh">SSL and SECURITY OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTSSLCERT"></a><span class="nroffip">CURLOPT_SSLCERT</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. The string should be the file name of your certificate. The default format is "PEM" and can be changed with <a class="emphasis" href="#CURLOPTSSLCERTTYPE">CURLOPT_SSLCERTTYPE</a>.
|
||||
<p class="level0"><a name="CURLOPTSSLCERTTYPE"></a><span class="nroffip">CURLOPT_SSLCERTTYPE</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. The string should be the format of your certificate. Supported formats are "PEM" and "DER". (Added in 7.9.3)
|
||||
<p class="level0"><a name="CURLOPTSSLCERTPASSWD"></a><span class="nroffip">CURLOPT_SSLCERTPASSWD</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used as the password required to use the <a class="emphasis" href="#CURLOPTSSLCERT">CURLOPT_SSLCERT</a> certificate.
|
||||
<p class="level1">This option is replaced by <a class="emphasis" href="#CURLOPTSSLKEYPASSWD">CURLOPT_SSLKEYPASSWD</a> and should only be used for backward compatibility. You never needed a pass phrase to load a certificate but you need one to load your private key.
|
||||
<p class="level0"><a name="CURLOPTSSLKEY"></a><span class="nroffip">CURLOPT_SSLKEY</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. The string should be the file name of your private key. The default format is "PEM" and can be changed with <a class="emphasis" href="#CURLOPTSSLKEYTYPE">CURLOPT_SSLKEYTYPE</a>.
|
||||
<p class="level0"><a name="CURLOPTSSLKEYTYPE"></a><span class="nroffip">CURLOPT_SSLKEYTYPE</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. The string should be the format of your private key. Supported formats are "PEM", "DER" and "ENG".
|
||||
<p class="level1">The format "ENG" enables you to load the private key from a crypto engine. In this case <a class="emphasis" href="#CURLOPTSSLKEY">CURLOPT_SSLKEY</a> is used as an identifier passed to the engine. You have to set the crypto engine with <a class="emphasis" href="#CURLOPTSSLENGINE">CURLOPT_SSLENGINE</a>. "DER" format key file currently does not work because of a bug in OpenSSL.
|
||||
<p class="level0"><a name="CURLOPTSSLKEYPASSWD"></a><span class="nroffip">CURLOPT_SSLKEYPASSWD</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used as the password required to use the <a class="emphasis" href="#CURLOPTSSLKEY">CURLOPT_SSLKEY</a> private key.
|
||||
<p class="level0"><a name="CURLOPTSSLENGINE"></a><span class="nroffip">CURLOPT_SSLENGINE</span>
|
||||
<p class="level1">Pass a pointer to a zero terminated string as parameter. It will be used as the identifier for the crypto engine you want to use for your private key.
|
||||
<p class="level1">If the crypto device cannot be loaded, <span Class="emphasis">CURLE_SSL_ENGINE_NOTFOUND</span> is returned.
|
||||
<p class="level0"><a name="CURLOPTSSLENGINEDEFAULT"></a><span class="nroffip">CURLOPT_SSLENGINE_DEFAULT</span>
|
||||
<p class="level1">Sets the actual crypto engine as the default for (asymmetric) crypto operations.
|
||||
<p class="level1">If the crypto device cannot be set, <span Class="emphasis">CURLE_SSL_ENGINE_SETFAILED</span> is returned.
|
||||
<p class="level0"><a name="CURLOPTSSLVERSION"></a><span class="nroffip">CURLOPT_SSLVERSION</span>
|
||||
<p class="level1">Pass a long as parameter to control what version of SSL/TLS to attempt to use. The available options are:
|
||||
<p class="level2">
|
||||
<p class="level1"><a name="CURLSSLVERSIONDEFAULT"></a><span class="nroffip">CURL_SSLVERSION_DEFAULT</span>
|
||||
<p class="level2">The default action. When libcurl built with OpenSSL, this will attempt to figure out the remote SSL protocol version. Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. When libcurl is built with GnuTLS, this will mean SSLv3.
|
||||
<p class="level1"><a name="CURLSSLVERSIONTLSv1"></a><span class="nroffip">CURL_SSLVERSION_TLSv1</span>
|
||||
<p class="level2">Force TLSv1
|
||||
<p class="level1"><a name="CURLSSLVERSIONSSLv2"></a><span class="nroffip">CURL_SSLVERSION_SSLv2</span>
|
||||
<p class="level2">Force SSLv2
|
||||
<p class="level1"><a name="CURLSSLVERSIONSSLv3"></a><span class="nroffip">CURL_SSLVERSION_SSLv3</span>
|
||||
<p class="level2">Force SSLv3
|
||||
<p class="level1">
|
||||
<p class="level0"><a name="CURLOPTSSLVERIFYPEER"></a><span class="nroffip">CURLOPT_SSL_VERIFYPEER</span>
|
||||
<p class="level1">Pass a long as parameter.
|
||||
<p class="level1">This option determines whether curl verifies the authenticity of the peer's certificate. A nonzero value means curl verifies; zero means it doesn't. The default is nonzero, but before 7.10, it was zero.
|
||||
<p class="level1">When negotiating an SSL connection, the server sends a certificate indicating its identity. Curl verifies whether the certificate is authentic, i.e. that you can trust that the server is who the certificate says it is. This trust is based on a chain of digital signatures, rooted in certification authority (CA) certificates you supply. As of 7.10, curl installs a default bundle of CA certificates and you can specify alternate certificates with the <a class="emphasis" href="#CURLOPTCAINFO">CURLOPT_CAINFO</a> option or the <a class="emphasis" href="#CURLOPTCAPATH">CURLOPT_CAPATH</a> option.
|
||||
<p class="level1">When <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a> is nonzero, and the verification fails to prove that the certificate is authentic, the connection fails. When the option is zero, the connection succeeds regardless.
|
||||
<p class="level1">Authenticating the certificate is not by itself very useful. You typically want to ensure that the server, as authentically identified by its certificate, is the server you mean to be talking to. Use <a class="emphasis" href="#CURLOPTSSLVERIFYHOST">CURLOPT_SSL_VERIFYHOST</a> to control that.
|
||||
<p class="level0"><a name="CURLOPTCAINFO"></a><span class="nroffip">CURLOPT_CAINFO</span>
|
||||
<p class="level1">Pass a char * to a zero terminated string naming a file holding one or more certificates to verify the peer with. This makes sense only when used in combination with the <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a> option. If <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a> is zero, <a class="emphasis" href="#CURLOPTCAINFO">CURLOPT_CAINFO</a> need not even indicate an accessible file.
|
||||
<p class="level1">Note that option is by default set to the system path where libcurl's cacert bundle is assumed to be stored, as established at build time.
|
||||
<p class="level0"><a name="CURLOPTCAPATH"></a><span class="nroffip">CURLOPT_CAPATH</span>
|
||||
<p class="level1">Pass a char * to a zero terminated string naming a directory holding multiple CA certificates to verify the peer with. The certificate directory must be prepared using the openssl c_rehash utility. This makes sense only when used in combination with the <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a> option. If <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a> is zero, <a class="emphasis" href="#CURLOPTCAPATH">CURLOPT_CAPATH</a> need not even indicate an accessible path. The <a class="emphasis" href="#CURLOPTCAPATH">CURLOPT_CAPATH</a> function apparently does not work in Windows due to some limitation in openssl. (Added in 7.9.8)
|
||||
<p class="level0"><a name="CURLOPTRANDOMFILE"></a><span class="nroffip">CURLOPT_RANDOM_FILE</span>
|
||||
<p class="level1">Pass a char * to a zero terminated file name. The file will be used to read from to seed the random engine for SSL. The more random the specified file is, the more secure the SSL connection will become.
|
||||
<p class="level0"><a name="CURLOPTEGDSOCKET"></a><span class="nroffip">CURLOPT_EGDSOCKET</span>
|
||||
<p class="level1">Pass a char * to the zero terminated path name to the Entropy Gathering Daemon socket. It will be used to seed the random engine for SSL.
|
||||
<p class="level0"><a name="CURLOPTSSLVERIFYHOST"></a><span class="nroffip">CURLOPT_SSL_VERIFYHOST</span>
|
||||
<p class="level1">Pass a long as parameter.
|
||||
<p class="level1">This option determines whether libcurl verifies that the server cert is for the server it is known as.
|
||||
<p class="level1">When negotiating an SSL connection, the server sends a certificate indicating its identity.
|
||||
<p class="level1">When <a class="emphasis" href="#CURLOPTSSLVERIFYHOST">CURLOPT_SSL_VERIFYHOST</a> is 2, that certificate must indicate that the server is the server to which you meant to connect, or the connection fails.
|
||||
<p class="level1">Curl considers the server the intended one when the Common Name field or a Subject Alternate Name field in the certificate matches the host name in the URL to which you told Curl to connect.
|
||||
<p class="level1">When the value is 1, the certificate must contain a Common Name field, but it doesn't matter what name it says. (This is not ordinarily a useful setting).
|
||||
<p class="level1">When the value is 0, the connection succeeds regardless of the names in the certificate.
|
||||
<p class="level1">The default, since 7.10, is 2.
|
||||
<p class="level1">The checking this option controls is of the identity that the server <span Class="emphasis">claims</span>. The server could be lying. To control lying, see <a class="emphasis" href="#CURLOPTSSLVERIFYPEER">CURLOPT_SSL_VERIFYPEER</a>.
|
||||
<p class="level0"><a name="CURLOPTSSLCIPHERLIST"></a><span class="nroffip">CURLOPT_SSL_CIPHER_LIST</span>
|
||||
<p class="level1">Pass a char *, pointing to a zero terminated string holding the list of ciphers to use for the SSL connection. The list must be syntactically correct, it consists of one or more cipher strings separated by colons. Commas or spaces are also acceptable separators but colons are normally used, !, - and + can be used as operators. Valid examples of cipher lists include 'RC4-SHA', ´SHA1+DES´, 'TLSv1' and 'DEFAULT'. The default list is normally set when you compile OpenSSL.
|
||||
<p class="level1">You'll find more details about cipher lists on this URL: <span Class="emphasis"><a href="http://www.openssl.org/docs/apps/ciphers.html">http://www.openssl.org/docs/apps/ciphers.html</a></span>
|
||||
<p class="level0"><a name="CURLOPTSSLSESSIONIDCACHE"></a><span class="nroffip">CURLOPT_SSL_SESSIONID_CACHE</span>
|
||||
<p class="level1">Pass a long set to 0 to disable libcurl's use of SSL session-ID caching. Set this to 1 to enable it. By default all transfers are done using the cache. Note that while nothing ever should get hurt by attempting to reuse SSL session-IDs, there seem to be broken SSL implementations in the wild that may require you to disable this in order for you to succeed. (Added in 7.16.0)
|
||||
<p class="level0"><a name="CURLOPTKRB4LEVEL"></a><span class="nroffip">CURLOPT_KRB4LEVEL</span>
|
||||
<p class="level1">Pass a char * as parameter. Set the krb4 security level, this also enables krb4 awareness. This is a string, 'clear', 'safe', 'confidential' or 'private'. If the string is set but doesn't match one of these, 'private' will be used. Set the string to NULL to disable kerberos4. The kerberos support only works for FTP. <a name="OTHER"></a><h2 class="nroffsh">OTHER OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTPRIVATE"></a><span class="nroffip">CURLOPT_PRIVATE</span>
|
||||
<p class="level1">Pass a char * as parameter, pointing to data that should be associated with this curl handle. The pointer can subsequently be retrieved using <a class="emphasis" href="./curl_easy_getinfo.html">curl_easy_getinfo(3)</a> with the CURLINFO_PRIVATE option. libcurl itself does nothing with this data. (Added in 7.10.3)
|
||||
<p class="level0"><a name="CURLOPTSHARE"></a><span class="nroffip">CURLOPT_SHARE</span>
|
||||
<p class="level1">Pass a share handle as a parameter. The share handle must have been created by a previous call to <a class="emphasis" href="./curl_share_init.html">curl_share_init(3)</a>. Setting this option, will make this curl handle use the data from the shared handle instead of keeping the data to itself. This enables several curl handles to share data. If the curl handles are used simultaneously, you <span Class="bold">MUST</span> use the locking methods in the share handle. See <a class="emphasis" href="./curl_share_setopt.html">curl_share_setopt(3)</a> for details. <a name="TELNET"></a><h2 class="nroffsh">TELNET OPTIONS</h2>
|
||||
<p class="level0">
|
||||
<p class="level0"><a name="CURLOPTTELNETOPTIONS"></a><span class="nroffip">CURLOPT_TELNETOPTIONS</span>
|
||||
<p class="level1">Provide a pointer to a curl_slist with variables to pass to the telnet negotiations. The variables should be in the format <option=value>. libcurl supports the options 'TTYPE', 'XDISPLOC' and 'NEW_ENV'. See the TELNET standard for details. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
|
||||
<p class="level0">CURLE_OK (zero) means that the option was set properly, non-zero means an error occurred as <span Class="emphasis"><curl/curl.h></span> defines. See the <span Class="emphasis">libcurl-errors(3)</span> man page for the full list with descriptions.
|
||||
<p class="level0">If you try to set an option that libcurl doesn't know about, perhaps because the library is too old to support it or the option was removed in a recent version, this function will return <span Class="emphasis">CURLE_FAILED_INIT</span>. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
|
||||
<p class="level0"><a class="manpage" href="./curl_easy_init.html">curl_easy_init (3)</a> <a class="manpage" href="./curl_easy_cleanup.html"> curl_easy_cleanup (3)</a> <a class="manpage" href="./curl_easy_reset.html"> curl_easy_reset (3)</a> <span Class="manpage"> </span> <p class="roffit">
|
||||
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
|
||||
</body></html>
|
Binary file not shown.
|
@ -1,20 +0,0 @@
|
|||
.\" You can view this file with:
|
||||
.\" nroff -man [file]
|
||||
.\" $Id: curl_easy_strerror.3,v 1.3 2006/01/02 23:32:36 bagder Exp $
|
||||
.\"
|
||||
.TH curl_easy_strerror 3 "26 Apr 2004" "libcurl 7.12" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_strerror - return string describing error code
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <curl/curl.h>
|
||||
.BI "const char *curl_easy_strerror(CURLcode " errornum ");"
|
||||
.SH DESCRIPTION
|
||||
The curl_easy_strerror() function returns a string describing the CURLcode
|
||||
error code passed in the argument \fIerrornum\fP.
|
||||
.SH AVAILABILITY
|
||||
This function was added in libcurl 7.12.0
|
||||
.SH RETURN VALUE
|
||||
A pointer to a zero terminated string.
|
||||
.SH "SEE ALSO"
|
||||
.BR libcurl-errors "(3), " curl_multi_strerror "(3), " curl_share_strerror "(3)"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue