Compare commits
87 Commits
curl-7_7-b
...
curl-7_7-b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1841c8ee6a | ||
![]() |
70793595fe | ||
![]() |
28a8e1602d | ||
![]() |
cce05b9138 | ||
![]() |
72a7fd4dc7 | ||
![]() |
9a6a476cf5 | ||
![]() |
5d0efedd2d | ||
![]() |
a426818a78 | ||
![]() |
bfe413d8bd | ||
![]() |
dbbd20646f | ||
![]() |
b8fe4deb13 | ||
![]() |
332a016e3c | ||
![]() |
3738e4bdc0 | ||
![]() |
3201d2dafa | ||
![]() |
0a1e002ca4 | ||
![]() |
9195bb64d4 | ||
![]() |
11ee547a0e | ||
![]() |
147de35d41 | ||
![]() |
e16e9b91ae | ||
![]() |
f9cde0646f | ||
![]() |
195233ed5c | ||
![]() |
048e654514 | ||
![]() |
dfbd45142d | ||
![]() |
ff681f7bfd | ||
![]() |
60bbb64a81 | ||
![]() |
c622f2bb4e | ||
![]() |
cd59f13da6 | ||
![]() |
11d718bf52 | ||
![]() |
8e8846d876 | ||
![]() |
7d562bb685 | ||
![]() |
20ddd35669 | ||
![]() |
063f88cd14 | ||
![]() |
87b0b7cab9 | ||
![]() |
70d0d9d4da | ||
![]() |
4ae3bd71ea | ||
![]() |
a9390665b8 | ||
![]() |
fb7a6e3423 | ||
![]() |
cc99e3f7de | ||
![]() |
e6b40bb6ac | ||
![]() |
f2fd1b8856 | ||
![]() |
cb4efcf275 | ||
![]() |
56a27d608a | ||
![]() |
46c9075eab | ||
![]() |
d95fa648e9 | ||
![]() |
563ad213dc | ||
![]() |
0121d7d731 | ||
![]() |
8495fac1c5 | ||
![]() |
38c349f751 | ||
![]() |
542df800ab | ||
![]() |
3e88b1cac5 | ||
![]() |
d774b10afb | ||
![]() |
b449b94393 | ||
![]() |
a6cb9b08b2 | ||
![]() |
440a3101d0 | ||
![]() |
9778a5356b | ||
![]() |
de7dcdbc54 | ||
![]() |
070968abbc | ||
![]() |
e97fc2aab5 | ||
![]() |
a23ac24192 | ||
![]() |
9ee14644a7 | ||
![]() |
c576e114b9 | ||
![]() |
639a7982ba | ||
![]() |
5bbe189420 | ||
![]() |
93ff159e32 | ||
![]() |
8eb8a0a8e4 | ||
![]() |
a4af638867 | ||
![]() |
75a9a87ec2 | ||
![]() |
b5ba011110 | ||
![]() |
e9b763ff05 | ||
![]() |
ac0bad2433 | ||
![]() |
67d5c0a970 | ||
![]() |
580896d615 | ||
![]() |
11693c0faa | ||
![]() |
26cd8eda4a | ||
![]() |
8cd3f44040 | ||
![]() |
2b30bfc349 | ||
![]() |
8ec4dba599 | ||
![]() |
1efec6572e | ||
![]() |
781dd7a9bf | ||
![]() |
beb8761b22 | ||
![]() |
071c7de9fe | ||
![]() |
3e7ebcd051 | ||
![]() |
c67952fc5c | ||
![]() |
7d7c24f915 | ||
![]() |
0dc8c4d451 | ||
![]() |
9cf4434ae2 | ||
![]() |
8ccd8b6dbc |
94
CHANGES
94
CHANGES
@@ -7,10 +7,104 @@
|
||||
History of Changes
|
||||
|
||||
|
||||
Daniel (14 March 2001)
|
||||
- Bj<42>rn Stenberg provided similar fixes as J<>rn did and some additional patches
|
||||
for non-SSL compiles.
|
||||
|
||||
- I increased the interface number for libcurl as I've removed the low level
|
||||
functions from the interface. I also took this opportunity to rename the
|
||||
Curl_strequal function to curl_strequal and Curl_strnequal to
|
||||
curl_strnequal, as they're public libcurl functions (even if they're still
|
||||
undocumented).
|
||||
|
||||
This will make older programs not capable of using the new libcurl with
|
||||
just a drop-in replacement.
|
||||
|
||||
- J<>rn Hartroth updated stuff for win32 compiles:
|
||||
o config-win32.h was fixed for socklen_t
|
||||
o lib/ssluse.c had a bad #endif placement
|
||||
o lib/file.c was made to compile on win32 again
|
||||
o lib/Makefile.m32 was updated with the new files
|
||||
o lib/libcurl.def matches the current interface state
|
||||
|
||||
Daniel (13 March 2001)
|
||||
- It only took an hour or so before J<>rn Hartroth found a problem in the
|
||||
chunked transfer-encoding. Given his fine example-site, I could easily spot
|
||||
the problem and when I re-read the spec (the part I have pasted in the top
|
||||
of the http_chunks.h file), I realized I had made my state-machine slightly
|
||||
wrong and didn't expect/handle the trailing CRLF that comes after the data
|
||||
in each chunk (and those extra two bytes sure feel wasted).
|
||||
|
||||
Had to modify test case 34 to match this as well.
|
||||
|
||||
Version 7.7-beta2
|
||||
|
||||
Daniel (13 March 2001)
|
||||
- Added the policy stuff to the curl_easy_setopt man page for the two supported
|
||||
policies.
|
||||
|
||||
- Implemented some support for the CURLOPT_CLOSEPOLICY option. The policies
|
||||
CURLCLOSEPOLICY_LEAST_RECENTLY_USED and CURLCLOSEPOLICY_OLDEST are now
|
||||
supported, and the "least recently used" is used as default if no policy
|
||||
is chosen.
|
||||
|
||||
Daniel (12 March 2001)
|
||||
- Added CURLOPT_RANDOM_FILE and CURLOPT_EGDSOCKET to libcurl for seeding the
|
||||
SSL random engine. The random seeding support was also brought to the curl
|
||||
client with the new options --random-file <file> and --egd-file <file>. I
|
||||
need some people to really test this to know they work as supposed. Remember
|
||||
that libcurl now informs (if verbose is on) if the random seed is considered
|
||||
weak (HTTPS connections).
|
||||
|
||||
- Made the chunked transfer-encoding engine detected bad formatted data length
|
||||
and return error if so (we can't possibly extract sensible data if this is
|
||||
the case). Added a test case that detects this. Number 36. Now there are 60
|
||||
test cases.
|
||||
|
||||
- Added 5 new libcurl options to curl/curl.h that can be used to control the
|
||||
persistant connection support in libcurl. They're also documented (fairly
|
||||
thoroughly) in the curl_easy_setopt.3 man page. Three of them are now
|
||||
implemented, although not really tested at this point... Anyway, the new
|
||||
implemented options are named CURLOPT_MAXCONNECTS, CURLOPT_FRESH_CONNECT,
|
||||
CURLOPT_FORBID_REUSE. The ones still left to write code for are:
|
||||
CURLOPT_CLOSEPOLICY and its related option CURLOPT_CLOSEFUNCTION.
|
||||
|
||||
- Made curl (the actual command line tool) use the new libcurl 7.7 persistant
|
||||
connection support by re-using the same curl handle for every specified file
|
||||
transfer and after some more test case tweaking we have 100% test case OK.
|
||||
I made some test cases return HTTP/1.0 now to make sure that works as well.
|
||||
|
||||
- Had to add 'Connection: close' to the headers of a bunch of test cases so
|
||||
that curl behaves "old-style" since the test http server doesn't do multiple
|
||||
connections... Now I get 100% test case OK.
|
||||
|
||||
- The curl.haxx.se site, the main curl mailing list and my personal email are
|
||||
all dead today due to power blackout in the area where the main servers are
|
||||
located. Horrible.
|
||||
|
||||
- I've made persistance work over a squid HTTP proxy. I find it disturbing
|
||||
that it uses headers that aren't present in any HTTP standard though
|
||||
(Proxy-Connection:) and that makes me feel that I'm now on the edge of what
|
||||
the standard actually defines. I need to get this code excercised on a lot
|
||||
of different HTTP proxies before I feel safe.
|
||||
|
||||
Now I'm facing the problem with my test suite servers (both FTP and HTTP)
|
||||
not supporting persistant connections and libcurl is doing them now. I have
|
||||
to fix the test servers to get all the test cases do OK.
|
||||
|
||||
Daniel (8 March 2001)
|
||||
- Guenole Bescon reported that libcurl did output errors to stderr even if
|
||||
MUTE and NOPROGRESS was set. It turned out to be a bug and happens if
|
||||
there's an error and no ERRORBUFFER is set. This is now corrected.
|
||||
|
||||
Version 7.7-beta1
|
||||
|
||||
Daniel (8 March 2001)
|
||||
- "Transfer-Encoding: chunked" is no longer any trouble for libcurl. I've
|
||||
added two source files and I've run some test downloads that look fine.
|
||||
|
||||
- HTTP HEAD works too, even on 1.1 servers.
|
||||
|
||||
Daniel (5 March 2001)
|
||||
- The current 57 test cases now pass OK. It would suggest that libcurl works
|
||||
using the old-style with one connection per handle. The test suite doesn't
|
||||
|
@@ -43,6 +43,9 @@
|
||||
/* Define this to 'int' if ssize_t is not an available typedefed type */
|
||||
#undef ssize_t
|
||||
|
||||
/* Define this to 'int' if socklen_t is not an available typedefed type */
|
||||
#undef socklen_t
|
||||
|
||||
/* Define this as a suitable file to read random data from */
|
||||
#undef RANDOM_FILE
|
||||
|
||||
|
@@ -26,6 +26,9 @@
|
||||
/* Define this to 'int' if ssize_t is not an available typedefed type */
|
||||
#define ssize_t int
|
||||
|
||||
/* Define this to 'int' if socklen_t is not an available typedefed type */
|
||||
#define socklen_t int
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
|
25
configure.in
25
configure.in
@@ -693,6 +693,28 @@ AC_CHECK_SIZEOF(long long, 4)
|
||||
# check for ssize_t
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
dnl
|
||||
dnl We can't just AC_CHECK_TYPE() for socklen_t since it doesn't appear
|
||||
dnl in the standard headers. We egrep for it in the socket headers and
|
||||
dnl if it is used there we assume we have the type defined, otherwise
|
||||
dnl we search for it with AC_CHECK_TYPE() the "normal" way
|
||||
dnl
|
||||
|
||||
if test "$ac_cv_header_sys_socket_h" = "yes"; then
|
||||
AC_MSG_CHECKING(for socklen_t in sys/socket.h)
|
||||
AC_EGREP_HEADER(socklen_t,
|
||||
sys/socket.h,
|
||||
socklen_t=yes
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
fi
|
||||
|
||||
if test "$socklen_t" != "yes"; then
|
||||
# check for socklen_t the standard way if it wasn't found before
|
||||
AC_CHECK_TYPE(socklen_t, int)
|
||||
fi
|
||||
|
||||
|
||||
dnl Get system canonical name
|
||||
AC_CANONICAL_HOST
|
||||
AC_DEFINE_UNQUOTED(OS, "${host}")
|
||||
@@ -764,6 +786,5 @@ AC_OUTPUT( Makefile \
|
||||
packages/Linux/Makefile \
|
||||
packages/Linux/RPM/Makefile \
|
||||
packages/Linux/RPM/curl.spec \
|
||||
packages/Linux/RPM/curl-ssl.spec \
|
||||
tiny/Makefile )
|
||||
packages/Linux/RPM/curl-ssl.spec )
|
||||
|
||||
|
17
docs/BUGS
17
docs/BUGS
@@ -6,9 +6,9 @@
|
||||
|
||||
BUGS
|
||||
|
||||
Curl has grown substantially from that day, several years ago, when I
|
||||
started fiddling with it. When I write this, there are 16500 lines of source
|
||||
code, and by the time you read this it has probably grown even more.
|
||||
Curl and libcurl have grown substantially since the beginning. At the time
|
||||
of writing (mid March 2001), there are 23000 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.
|
||||
|
||||
@@ -21,10 +21,11 @@ BUGS
|
||||
http://sourceforge.net/bugs/?group_id=976
|
||||
|
||||
When reporting a bug, you should include information that will help us
|
||||
understand what's wrong, what's expected and how to repeat it. You therefore
|
||||
need to supply 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 and anything else you think matters.
|
||||
understand what's wrong, what you expected to happen and how to repeat the
|
||||
bad behaviour. You therefore need to supply 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 and anything else
|
||||
you think matters.
|
||||
|
||||
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
|
||||
@@ -32,7 +33,7 @@ BUGS
|
||||
a stack trace and send that (much smaller) output to us instead!
|
||||
|
||||
The address and how to subscribe to the mailing list is detailed in the
|
||||
README.curl file.
|
||||
MANUAL file.
|
||||
|
||||
HOW TO GET A STACK TRACE with a common unix debugger
|
||||
====================================================
|
||||
|
@@ -13,7 +13,7 @@ To Think About When Contributing Source Code
|
||||
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.
|
||||
the same license curl and libcurl is already using unless stated 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 enfore any changes to
|
||||
@@ -26,19 +26,19 @@ 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.
|
||||
understandable and be named according to what they're used for. File-local
|
||||
functions should be made static.
|
||||
|
||||
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. I don't ask you to like it, I just
|
||||
ask you to follow the tradition! ;-)
|
||||
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! ;-)
|
||||
|
||||
Commenting
|
||||
|
||||
Comment your source code extensively. I don't see myself as a very good
|
||||
source commenter, but I try to become one. Commented code is quality code and
|
||||
Comment your source code extensively. Commented code is quality code and
|
||||
enables future modifications much more. Uncommented code much more risk being
|
||||
completely replaced when someone wants to extend things, since other persons'
|
||||
source code can get quite hard to read.
|
||||
@@ -71,9 +71,9 @@ Separate Patches Doing Different Things
|
||||
Patch Against Recent Sources
|
||||
|
||||
Please try to get the latest available sources to make your patches
|
||||
against. It makes my life 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!
|
||||
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
|
||||
|
||||
@@ -91,9 +91,9 @@ Write Access to CVS Repository
|
||||
|
||||
Test Cases
|
||||
|
||||
Since the introduction of the test suite, we will get the possibility to
|
||||
quickly verify that the main features are working as supposed to. To maintain
|
||||
this situation and improve it, all new features and functions that are added
|
||||
need tro be tested. Every feature that is added should get at least one valid
|
||||
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
|
||||
post a few test cases, it won't end up as a heavy burden on a single person!
|
||||
|
108
docs/FAQ
108
docs/FAQ
@@ -1,4 +1,4 @@
|
||||
Updated: March 6, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
||||
Updated: March 13, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
@@ -112,29 +112,30 @@ FAQ
|
||||
|
||||
1.4 When will you make curl do XXXX ?
|
||||
|
||||
I love suggestions of what to change in order to make curl and libcurl
|
||||
better. I do however believe in a few rules when it comes to the future of
|
||||
We love suggestions of what to change in order to make curl and libcurl
|
||||
better. We do however believe in a few rules when it comes to the future of
|
||||
curl:
|
||||
|
||||
* It is to remain a command line tool. If you want GUIs or fancy scripting
|
||||
* Curl is to remain a command line tool. If you want GUIs or fancy scripting
|
||||
capabilities, you're free to write another tool that uses libcurl and that
|
||||
offers this. There's no point in having one single tool that does every
|
||||
offers this. There's no point in having a single tool that does every
|
||||
imaginable thing. That's also one of the great advantages of having the
|
||||
core of curl as a library: libcurl.
|
||||
core of curl as a library.
|
||||
|
||||
* I do not add things to curl that other small and available tools already
|
||||
* We do not add things to curl that other small and available tools already
|
||||
do very fine at the side. Curl's output is fine to pipe into another
|
||||
program or redirect to another file for the next program to interpret.
|
||||
|
||||
* I focus on protocol related issues and improvements. If you wanna do more
|
||||
* We focus on protocol related issues and improvements. If you wanna do more
|
||||
magic with the supported protocols than curl currently does, chances are
|
||||
big I will agree. If you wanna add more protocols, I may very well
|
||||
agree.
|
||||
|
||||
* If you want me to make all the work while you wait for me to implement it
|
||||
for you, that is not a very friendly attitude. I spend a considerable time
|
||||
already on maintaining and developing curl. In order to get more out of
|
||||
me, I trust you will offer some of your time and efforts in return.
|
||||
* If you want someone else to make all the work while you wait for us to
|
||||
implement it for you, that is not a very friendly attitude. We spend a
|
||||
considerable time already on maintaining and developing curl. In order to
|
||||
get more out of us, you should consider trading in some of your time and
|
||||
efforts in return.
|
||||
|
||||
* If you write the code, chances are bigger that it will get into curl
|
||||
faster.
|
||||
@@ -182,23 +183,24 @@ FAQ
|
||||
|
||||
2.2. Does curl work/build with other SSL libraries?
|
||||
|
||||
Curl has been written to use OpenSSL, although I doubt there would be much
|
||||
Curl has been written to use OpenSSL, although there should not be much
|
||||
problems using a different library. If anyone does "port" curl to use a
|
||||
different SSL library, I am of course very interested in getting the patch!
|
||||
different SSL library, we are of course very interested in getting the
|
||||
patch!
|
||||
|
||||
2.3. Where can I find a copy of LIBEAY32.DLL?
|
||||
|
||||
That is an OpenSSL binary built for Windows.
|
||||
|
||||
Curl uses OpenSSL to do the SSL stuff. The LIBEAY32.DLL is what curl needs
|
||||
on a windows machine to do https://. Check out the curl web page to find
|
||||
on a windows machine to do https://. Check out the curl web site to find
|
||||
accurate and up-to-date pointers to recent OpenSSL DDLs and other binary
|
||||
packages.
|
||||
|
||||
2.4. Does cURL support Socks (RFC 1928) ?
|
||||
|
||||
No. Nobody has wanted it that badly yet. I would appriciate patches that
|
||||
brings this functionality.
|
||||
No. Nobody has wanted it that badly yet. We appriciate patches that bring
|
||||
this functionality.
|
||||
|
||||
|
||||
3. Usage problems
|
||||
@@ -220,7 +222,7 @@ FAQ
|
||||
|
||||
3.2. How do I tell curl to resume a transfer?
|
||||
|
||||
Curl supports resume both ways on FTP, download ways on HTTP.
|
||||
Curl supports resumed transfers both ways on both FTP and HTTP.
|
||||
|
||||
Try the -C option.
|
||||
|
||||
@@ -232,10 +234,10 @@ FAQ
|
||||
use the -F type. In all the most common cases, you should use -d which then
|
||||
causes a posting with the type 'application/x-www-form-urlencoded'.
|
||||
|
||||
I have described this in some detail in the README.curl file, and if you
|
||||
don't understand it the first time, read it again before you post questions
|
||||
about this to the mailing list. I would also suggest that you read through
|
||||
the mailing list archives for old postings and questions regarding this.
|
||||
This is described in some detail in the README.curl file, and if you don't
|
||||
understand it the first time, read it again before you post questions about
|
||||
this to the mailing list. Also, try reading through the mailing list
|
||||
archives for old postings and questions regarding this.
|
||||
|
||||
3.4. How do I tell curl to run custom FTP commands?
|
||||
|
||||
@@ -306,9 +308,9 @@ FAQ
|
||||
|
||||
4.1. Problems connecting to SSL servers.
|
||||
|
||||
It took a very long time before I could sort out why curl had problems
|
||||
to connect to certain SSL servers when using SSLeay or OpenSSL v0.9+.
|
||||
The error sometimes showed up similar to:
|
||||
It took a very long time before we could sort out why curl had problems to
|
||||
connect to certain SSL servers when using SSLeay or OpenSSL v0.9+. The
|
||||
error sometimes showed up similar to:
|
||||
|
||||
16570:error:1407D071:SSL routines:SSL2_READ:bad mac decode:s2_pkt.c:233:
|
||||
|
||||
@@ -316,12 +318,12 @@ FAQ
|
||||
requests properly. To correct this problem, tell curl to select SSLv2 from
|
||||
the command line (-2/--sslv2).
|
||||
|
||||
I have also seen examples where the remote server didn't like the SSLv2
|
||||
There has also been examples where the remote server didn't like the SSLv2
|
||||
request and instead you had to force curl to use SSLv3 with -3/--sslv3.
|
||||
|
||||
4.2. Why do I get problems when I use & or % in the URL?
|
||||
|
||||
In general unix shells, the & letter is treated special and when used it
|
||||
In general unix shells, the & letter is treated special and when used, it
|
||||
runs the specified command in the background. To safely send the & as a part
|
||||
of a URL, you should qoute the entire URL by using single (') or double (")
|
||||
quotes around it.
|
||||
@@ -346,8 +348,8 @@ FAQ
|
||||
curl '{curl,www}.haxx.se'
|
||||
|
||||
To be able to use those letters as actual parts of the URL (without using
|
||||
them for the curl URL "globbing" system), use the -g/--globoff option
|
||||
(included in curl 7.6 and later):
|
||||
them for the curl URL "globbing" system), use the -g/--globoff option (curl
|
||||
7.6 and later):
|
||||
|
||||
curl -g 'www.site.com/weirdname[].html'
|
||||
|
||||
@@ -363,8 +365,8 @@ FAQ
|
||||
|
||||
4.5 Why do I get return code XXX from a HTTP server?
|
||||
|
||||
RFC2616 clearly explains the return codes. I'll make a short transcript
|
||||
here. Go read the RFC for exact details:
|
||||
RFC2616 clearly explains the return codes. This is a short transcript. Go
|
||||
read the RFC for exact details:
|
||||
|
||||
4.5.1 "400 Bad Request"
|
||||
|
||||
@@ -400,7 +402,7 @@ FAQ
|
||||
|
||||
4.7. How do I keep usernames and passwords secret in Curl command lines?
|
||||
|
||||
I see this problem as two parts:
|
||||
This problem has two sides:
|
||||
|
||||
The first part is to avoid having clear-text passwords in the command line
|
||||
so that they don't appear in 'ps' outputs and similar. That is easily
|
||||
@@ -447,9 +449,8 @@ FAQ
|
||||
programs. libcurl will use thread-safe functions instead of non-safe ones if
|
||||
your system has such.
|
||||
|
||||
I am very interested in once and for all getting some kind of report or
|
||||
README file from those who have used libcurl in a threaded environment,
|
||||
since I haven't and I get this question more and more frequently!
|
||||
We would appriciate some kind of report or README file from those who have
|
||||
used libcurl in a threaded environment.
|
||||
|
||||
5.2 How can I receive all data into a large memory chunk?
|
||||
|
||||
@@ -487,11 +488,15 @@ FAQ
|
||||
5.3 How do I fetch multiple files with libcurl?
|
||||
|
||||
Starting with version 7.7, curl and libcurl will have excellent support for
|
||||
transferring multiple files.
|
||||
transferring multiple files. You should just repeatedly set new URLs with
|
||||
curl_easy_setopt() and then transfer it with curl_easy_perform(). The handle
|
||||
you get from curl_easy_init() is not only reusable starting with libcurl
|
||||
7.7, but also you're encouraged to reuse it if you can, as that will enable
|
||||
libcurl to use persistant connections.
|
||||
|
||||
The easy interface of libcurl does not support multiple requests using the
|
||||
same connection. The only available way to do multiple requests is to
|
||||
init/perform/cleanup for each request.
|
||||
For libcurl prior to 7.7, there was no multiple file support. The only
|
||||
available way to do multiple requests was to init/perform/cleanup for each
|
||||
transfer.
|
||||
|
||||
5.4 Does libcurl do Winsock initing on win32 systems?
|
||||
|
||||
@@ -517,18 +522,14 @@ FAQ
|
||||
|
||||
Starting with version 7.7, curl and libcurl will have excellent support for
|
||||
persistant connections when transferring several files from the same server.
|
||||
Curl will attempt to reuse connections for all URLs specified on the same
|
||||
command line/config file, and libcurl will reuse connections for all
|
||||
transfers that are made using the same libcurl handle.
|
||||
|
||||
This is closely related to issue 5.3. Since libcurl has no real support
|
||||
for doing multiple file transfers, there's no support for Keep-Alive or
|
||||
persistant connections either.
|
||||
|
||||
This is of course subject to change as soon as libcurl gets support for
|
||||
multiple files. Feel free to join in and make this change happen sooner!
|
||||
Previous versions had no persistant connection support.
|
||||
|
||||
6. License Issues
|
||||
|
||||
NOTE: This section concerns curl 7.5.2 or later!
|
||||
|
||||
Curl and libcurl are released under a MIT/X derivate license *or* the MPL,
|
||||
the Mozilla Public License. To get a really good answer to your license
|
||||
conflict questions, you should study the MPL and MIT/X licenses and the
|
||||
@@ -573,9 +574,10 @@ FAQ
|
||||
|
||||
No.
|
||||
|
||||
We carefully picked this license years ago and a large amount of people have
|
||||
contributed with source code knowing that this is the license we use. This
|
||||
license puts the restrictions we want on curl/libcurl and it does not spread
|
||||
to other programs or libraries that use it. The recent dual license
|
||||
modification should make it possible for everyone to use libcurl or curl in
|
||||
their projects, no matter what license they already have in use.
|
||||
We have carefully picked this license after years of development and
|
||||
discussions and a large amount of people have contributed with source code
|
||||
knowing that this is the license we use. This license puts the restrictions
|
||||
we want on curl/libcurl and it does not spread to other programs or
|
||||
libraries that use it. The recent dual license modification should make it
|
||||
possible for everyone to use libcurl or curl in their projects, no matter
|
||||
what license they already have in use.
|
||||
|
@@ -17,12 +17,14 @@ Misc
|
||||
- progress bar/time specs while downloading
|
||||
- "standard" proxy environment variables support
|
||||
- config file support
|
||||
- compiles on win32
|
||||
- compiles on win32 (reported built on 29 operating systems)
|
||||
- redirectable stderr
|
||||
- use selected network interface for outgoing traffic
|
||||
- IPv6 support
|
||||
- persistant connections
|
||||
|
||||
HTTP
|
||||
- HTTP/1.1 compliant
|
||||
- GET
|
||||
- PUT
|
||||
- HEAD
|
||||
@@ -72,6 +74,7 @@ FTP
|
||||
|
||||
TELNET
|
||||
- connection negotiation
|
||||
- custom telnet options
|
||||
- stdin/stdout I/O
|
||||
|
||||
LDAP (*2)
|
||||
|
102
docs/INTERNALS
102
docs/INTERNALS
@@ -1,4 +1,4 @@
|
||||
Updated for curl 7.6 on January 26, 2001
|
||||
Updated for curl 7.7 on March 13, 2001
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
INTERNALS
|
||||
|
||||
The project is kind of split in two. The library and the client. The client
|
||||
part uses the library, but the library is meant to be designed to allow other
|
||||
applications to use it.
|
||||
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.
|
||||
|
||||
Thus, the largest amount of code and complexity is in the library part.
|
||||
The largest amount of code and complexity is in the library part.
|
||||
|
||||
CVS
|
||||
===
|
||||
@@ -35,13 +35,13 @@ Windows vs Unix
|
||||
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
|
||||
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
|
||||
not easily interchangable as in unix.
|
||||
|
||||
We avoid this by not trying any funny tricks on file descriptors.
|
||||
|
||||
@@ -51,10 +51,10 @@ Windows vs Unix
|
||||
|
||||
We set stdout to binary under windows
|
||||
|
||||
Inside the source code, I do make an effort to avoid '#ifdef WIN32'. All
|
||||
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,
|
||||
I maintain two config-win32.h files (one in / and one in src/) that are
|
||||
we maintain two config-win32.h files (one in / and one in src/) that are
|
||||
supposed to look exactly as a config.h file would have looked like on a
|
||||
Windows machine!
|
||||
|
||||
@@ -64,12 +64,6 @@ Windows vs Unix
|
||||
Library
|
||||
=======
|
||||
|
||||
As described elsewhere, libcurl is meant to get two different "layers" of
|
||||
interfaces. At the present point only the high-level, the "easy", interface
|
||||
has been fully implemented and documented. We assume the easy-interface in
|
||||
this description, the low-level interface will be documented when fully
|
||||
implemented.
|
||||
|
||||
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
|
||||
@@ -103,8 +97,9 @@ Library
|
||||
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. curl_transfer() then calls _Tranfer() in lib/transfer.c that
|
||||
performs the entire file transfer.
|
||||
returns. Curl_perform() then calls Transfer() in lib/transfer.c that performs
|
||||
the entire file transfer. Curl_perform() is what does the main "connect - do
|
||||
- transfer - done" loop. It loops if there's a Location: to follow.
|
||||
|
||||
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
|
||||
@@ -114,6 +109,22 @@ Library
|
||||
When completed, the curl_easy_cleanup() should be called to free up used
|
||||
resources.
|
||||
|
||||
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
|
||||
@@ -129,6 +140,14 @@ Library
|
||||
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
|
||||
@@ -160,7 +179,7 @@ Library
|
||||
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
|
||||
While transfering data in Transfer() a few functions might get
|
||||
used. curl_getdate() in lib/getdate.c is for HTTP date comparisons (and
|
||||
more).
|
||||
|
||||
@@ -182,6 +201,34 @@ Library
|
||||
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.
|
||||
|
||||
Persistant Connections
|
||||
======================
|
||||
|
||||
With curl 7.7, we added persistant connection support to libcurl which has
|
||||
introduced a somewhat different treatmeant of things inside of libcurl.
|
||||
|
||||
o The 'UrlData' 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 'UrlData' struct holds the cache array of pointers to 'connectdata'
|
||||
structs. There's one connectdata struct for each connection that libcurl
|
||||
knows about.
|
||||
o This also enables the 'curl handle' to be reused on subsequent transfers,
|
||||
something that was illegal in pre-7.7 versions.
|
||||
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 tranfer 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
|
||||
persistant connections to work.
|
||||
|
||||
Library Symbols
|
||||
===============
|
||||
|
||||
@@ -236,12 +283,12 @@ Memory Debugging
|
||||
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
|
||||
is then analyzed after a complete session,
|
||||
can then be analyzed after a complete session,
|
||||
|
||||
memanalyze.pl is a perl script present only 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.
|
||||
memanalyze.pl is a 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.
|
||||
|
||||
@@ -256,8 +303,8 @@ Test Suite
|
||||
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 README
|
||||
file in the test directory.
|
||||
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.
|
||||
@@ -269,6 +316,7 @@ Building Releases
|
||||
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.
|
||||
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.
|
||||
|
||||
You must have autoconf installed to build release archives.
|
||||
|
@@ -58,9 +58,16 @@ Portability
|
||||
you to init the winsock stuff before you use the libcurl functions. Details
|
||||
on this are noted on the curl_easy_init() man page.
|
||||
|
||||
(*) = it appears users of the cygwin environment gets this done
|
||||
(*) = it appears as if users of the cygwin environment get this done
|
||||
automatically.
|
||||
|
||||
Threads
|
||||
|
||||
Never *ever* call curl-functions simultaneously using the same handle from
|
||||
several threads. libcurl is thread-safe and can be used in any number of
|
||||
threads, but you must use separate curl handles if you want to use libcurl in
|
||||
more than one thread simultaneously.
|
||||
|
||||
Persistant Connections
|
||||
|
||||
With libcurl 7.7, persistant connections were added. Persistant connections
|
||||
|
45
docs/MANUAL
45
docs/MANUAL
@@ -25,12 +25,16 @@ SIMPLE USAGE
|
||||
|
||||
Get a list of the root directory of an FTP site:
|
||||
|
||||
curl ftp://ftp.fts.frontec.se/
|
||||
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/
|
||||
|
||||
DOWNLOAD TO A FILE
|
||||
|
||||
Get a web page and store in a local file:
|
||||
@@ -43,6 +47,10 @@ DOWNLOAD TO A FILE
|
||||
|
||||
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
|
||||
@@ -455,9 +463,13 @@ EXTRA HEADERS
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
@@ -745,6 +757,25 @@ TELNET
|
||||
to track when the login prompt is received and send the username and
|
||||
password accordingly.
|
||||
|
||||
PERSISTANT 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 persistant 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 persistant 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, practicly
|
||||
all transfers will be persistant.
|
||||
|
||||
Persistant connections were introduced in curl 7.7.
|
||||
|
||||
MAILING LISTS
|
||||
|
||||
For your convenience, we have several open mailing lists to discuss curl,
|
||||
@@ -753,10 +784,10 @@ MAILING LISTS
|
||||
To subscribe to the main curl list, mail curl-request@contactor.se with
|
||||
"subscribe <fill in your email address>" in the body.
|
||||
|
||||
To subscribe to the libcurl users list, follow the instructions at
|
||||
http://curl.haxx.se/mail/
|
||||
To subscribe to the curl-library users/deverlopers list, follow the
|
||||
instructions at http://curl.haxx.se/mail/
|
||||
|
||||
To subscribe to the curl announce list, to only get information about new
|
||||
To subscribe to the curl-announce list, to only get information about new
|
||||
releases, follow the instructions at http://curl.haxx.se/mail/
|
||||
|
||||
To subscribe to the curl-and-PHP list in which curl using with PHP is
|
||||
|
16
docs/TODO
16
docs/TODO
@@ -11,11 +11,6 @@ TODO
|
||||
|
||||
To do for the 7.7 release:
|
||||
|
||||
* Fix the random seeding. Add --egd-socket and --random-file options to the
|
||||
curl client and libcurl curl_easy_setopt() interface.
|
||||
|
||||
* Support persistant connections (fully detailed elsewhere)
|
||||
|
||||
* Add a special connection-timeout that only goes for the connection phase.
|
||||
|
||||
To do for the 7.8 release:
|
||||
@@ -23,7 +18,16 @@ To do for the 7.8 release:
|
||||
* Make SSL session ids get used if multiple HTTPS documents from the same
|
||||
host is requested.
|
||||
|
||||
To do in a future release:
|
||||
To do in a future release (random order):
|
||||
|
||||
* Document the undocumented libcurl functions: the printf clones (like
|
||||
curl_msprintf, curl_mfprintf, curl_msnprintf, curl_maprintf and
|
||||
curl_mvfprintf), the string compare functions (curl_strequal
|
||||
and curl_strnequal) and the URL escape/unescape functions.
|
||||
|
||||
* Add configure options that disables certain protocols in libcurl to
|
||||
decrease footprint. '--disable-[protocol]' where protocol is http, ftp,
|
||||
telnet, ldap, dict or file.
|
||||
|
||||
* Extend the test suite to include telnet and https. The telnet could just do
|
||||
ftp or http operations (for which we have test servers) and the https would
|
||||
|
@@ -2,7 +2,7 @@
|
||||
.\" nroff -man curl.1
|
||||
.\" Written by Daniel Stenberg
|
||||
.\"
|
||||
.TH curl 1 "19 January 2001" "Curl 7.6" "Curl Manual"
|
||||
.TH curl 1 "12 March 2001" "Curl 7.7" "Curl Manual"
|
||||
.SH NAME
|
||||
curl \- get a URL with FTP, TELNET, LDAP, GOPHER, DICT, FILE, HTTP or
|
||||
HTTPS syntax.
|
||||
@@ -41,6 +41,12 @@ supported at the moment:
|
||||
|
||||
Starting with curl 7.6, you can specify any amount of URLs on the command
|
||||
line. They will be fetched in a sequential manner in the specified order.
|
||||
|
||||
Starting with curl 7.7, 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.
|
||||
.SH OPTIONS
|
||||
.IP "-a/--append"
|
||||
(FTP)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
.\" nroff -man [file]
|
||||
.\" Written by daniel@haxx.se
|
||||
.\"
|
||||
.TH curl_easy_setopt 3 "6 March 2001" "libcurl 7.5" "libcurl Manual"
|
||||
.TH curl_easy_setopt 3 "13 March 2001" "libcurl 7.7" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_setopt - Set curl easy-session options
|
||||
.SH SYNOPSIS
|
||||
@@ -26,6 +26,13 @@ NOTE: 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 behaviour or even crashes.
|
||||
|
||||
More note: the options set with this function call are valid for the
|
||||
forthcoming data transfers that are performed when you invoke
|
||||
.I curl_easy_perform .
|
||||
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.
|
||||
|
||||
The
|
||||
.I "handle"
|
||||
is the return code from the
|
||||
@@ -419,6 +426,50 @@ 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. This
|
||||
option only makes sense if the CURLOPT_FOLLOWLOCATION is used at the same
|
||||
time. (Added in 7.5)
|
||||
.TP
|
||||
.B CURLOPT_MAXCONNECTS
|
||||
Pass a long. The set number will be the persistant connection cache size. The
|
||||
set amount will be the maximum amount of simultaneous connections that libcurl
|
||||
may cache between file transfers. 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. Note: if you have already performed transfers
|
||||
with this curl handle, setting a smaller MAXCONNECTS than before may cause
|
||||
open connections to unnecessarily get closed. (Added in 7.7)
|
||||
.TP
|
||||
.B CURLOPT_CLOSEPOLICY
|
||||
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 CURLCLOSEPOLICY_LEAST_RECENTLY_USED to make libcurl close the
|
||||
connection that was least recently used, that connection is also least likely
|
||||
to be capable of re-use. Use CURLCLOSEPOLICY_OLDEST 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. (Added in 7.7)
|
||||
.TP
|
||||
.B CURLOPT_FRESH_CONNECT
|
||||
Pass a long. Set to non-zero to make the next transfer use a new connection by
|
||||
force. If the connection cache is full before this connection, one of the
|
||||
existinf connections will be closed as according to the set policy. This
|
||||
option should be used with caution and only if you understand what it
|
||||
does. Set to 0 to have libcurl attempt re-use of an existing connection.
|
||||
(Added in 7.7)
|
||||
.TP
|
||||
.B CURLOPT_FORBID_REUSE
|
||||
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. (Added in 7.7)
|
||||
.TP
|
||||
.B CURLOPT_RANDOM_FILE
|
||||
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 will the SSL connection become.
|
||||
.TP
|
||||
.B CURLOPT_FORBID_REUSE
|
||||
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.
|
||||
.PP
|
||||
.SH RETURN VALUE
|
||||
0 means the option was set properly, non-zero means an error as
|
||||
|
@@ -398,6 +398,33 @@ typedef enum {
|
||||
/* This points to a linked list of telnet options */
|
||||
CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
|
||||
|
||||
/* Max amount of cached alive connections */
|
||||
CINIT(MAXCONNECTS, LONG, 71),
|
||||
|
||||
/* What policy to use when closing connections when the cache is filled
|
||||
up */
|
||||
CINIT(CLOSEPOLICY, LONG, 72),
|
||||
|
||||
/* Callback to use when CURLCLOSEPOLICY_CALLBACK is set */
|
||||
CINIT(CLOSEFUNCTION, FUNCTIONPOINT, 73),
|
||||
|
||||
/* Set to explicitly use a new connection for the upcoming transfer.
|
||||
Do not use this unless you're absolutely sure of this, as it makes the
|
||||
operation slower and is less friendly for the network. */
|
||||
CINIT(FRESH_CONNECT, LONG, 74),
|
||||
|
||||
/* Set to explicitly forbid the upcoming transfer's connection to be re-used
|
||||
when done. Do not use this unless you're absolutely sure of this, as it
|
||||
makes the operation slower and is less friendly for the network. */
|
||||
CINIT(FORBID_REUSE, LONG, 75),
|
||||
|
||||
/* Set to a file name that contains random data for libcurl to use to
|
||||
seed the random engine when doing SSL connects. */
|
||||
CINIT(RANDOM_FILE, OBJECTPOINT, 76),
|
||||
|
||||
/* Set to the Entropy Gathering Daemon socket pathname */
|
||||
CINIT(EGDSOCKET, OBJECTPOINT, 77),
|
||||
|
||||
CURLOPT_LASTENTRY /* the last unusued */
|
||||
} CURLoption;
|
||||
|
||||
@@ -423,10 +450,10 @@ typedef enum {
|
||||
|
||||
NOTE: they return TRUE if the strings match *case insensitively*.
|
||||
*/
|
||||
extern int (Curl_strequal)(const char *s1, const char *s2);
|
||||
extern int (Curl_strnequal)(const char *s1, const char *s2, size_t n);
|
||||
#define strequal(a,b) Curl_strequal(a,b)
|
||||
#define strnequal(a,b,c) Curl_strnequal(a,b,c)
|
||||
extern int (curl_strequal)(const char *s1, const char *s2);
|
||||
extern int (curl_strnequal)(const char *s1, const char *s2, size_t n);
|
||||
#define strequal(a,b) curl_strequal(a,b)
|
||||
#define strnequal(a,b,c) curl_strnequal(a,b,c)
|
||||
|
||||
/* external form function */
|
||||
int curl_formparse(char *string,
|
||||
@@ -444,7 +471,7 @@ char *curl_getenv(char *variable);
|
||||
char *curl_version(void);
|
||||
|
||||
/* This is the version number */
|
||||
#define LIBCURL_VERSION "7.7-beta1"
|
||||
#define LIBCURL_VERSION "7.7-beta3"
|
||||
#define LIBCURL_VERSION_NUM 0x070700
|
||||
|
||||
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
||||
@@ -502,21 +529,6 @@ typedef enum {
|
||||
before it can be included! */
|
||||
#include <curl/easy.h> /* nothing in curl is fun without the easy stuff */
|
||||
|
||||
/*
|
||||
* NAME curl_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function.
|
||||
* The third argument MUST be a pointer to a long or a pointer to a char *.
|
||||
* The data pointed to will be filled in accordingly and can be relied upon
|
||||
* only if the function returns CURLE_OK.
|
||||
* This function is intended to get used *AFTER* a performed transfer, all
|
||||
* results are undefined before the transfer is completed.
|
||||
*/
|
||||
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
typedef enum {
|
||||
CURLCLOSEPOLICY_NONE, /* first, never use this */
|
||||
|
||||
|
@@ -16,7 +16,7 @@ lib_LTLIBRARIES = libcurl.la
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
|
||||
libcurl_la_LDFLAGS = -version-info 1:0:0
|
||||
libcurl_la_LDFLAGS = -version-info 2:0:0
|
||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||
# 1.
|
||||
|
@@ -33,13 +33,13 @@ libcurl_a_SOURCES = arpa_telnet.h file.c getpass.h netrc.h timeval.c base64.c \
|
||||
urldata.h transfer.c getdate.h ldap.c ssluse.c version.c transfer.h getenv.c \
|
||||
ldap.h ssluse.h escape.c getenv.h mprintf.c telnet.c escape.h getpass.c netrc.c \
|
||||
telnet.h getinfo.c strequal.c strequal.h easy.c security.h \
|
||||
security.c krb4.c
|
||||
security.c krb4.h krb4.c memdebug.h memdebug.c inet_ntoa_r.h http_chunks.h http_chunks.c
|
||||
|
||||
libcurl_a_OBJECTS = file.o timeval.o base64.o hostip.o progress.o \
|
||||
formdata.o cookie.o http.o sendf.o ftp.o url.o dict.o if2ip.o \
|
||||
speedcheck.o getdate.o transfer.o ldap.o ssluse.o version.o \
|
||||
getenv.o escape.o mprintf.o telnet.o getpass.o netrc.o getinfo.o \
|
||||
strequal.o easy.o security.o krb4.o
|
||||
strequal.o easy.o security.o krb4.o memdebug.o http_chunks.o
|
||||
|
||||
LIBRARIES = $(libcurl_a_LIBRARIES)
|
||||
SOURCES = $(libcurl_a_SOURCES)
|
||||
|
19
lib/easy.c
19
lib/easy.c
@@ -83,15 +83,11 @@ CURL *curl_easy_init(void)
|
||||
CURLcode res;
|
||||
struct UrlData *data;
|
||||
|
||||
if(curl_init())
|
||||
return NULL;
|
||||
|
||||
/* We use curl_open() with undefined URL so far */
|
||||
res = curl_open((CURL **)&data, NULL);
|
||||
res = Curl_open((CURL **)&data, NULL);
|
||||
if(res != CURLE_OK)
|
||||
return NULL;
|
||||
|
||||
data->interf = CURLI_EASY; /* mark it as an easy one */
|
||||
/* SAC */
|
||||
data->device = NULL;
|
||||
|
||||
@@ -119,16 +115,16 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
|
||||
if(tag < CURLOPTTYPE_OBJECTPOINT) {
|
||||
/* This is a LONG type */
|
||||
param_long = va_arg(arg, long);
|
||||
curl_setopt(data, tag, param_long);
|
||||
Curl_setopt(data, tag, param_long);
|
||||
}
|
||||
else if(tag < CURLOPTTYPE_FUNCTIONPOINT) {
|
||||
/* This is a object pointer type */
|
||||
param_obj = va_arg(arg, void *);
|
||||
curl_setopt(data, tag, param_obj);
|
||||
Curl_setopt(data, tag, param_obj);
|
||||
}
|
||||
else {
|
||||
param_func = va_arg(arg, func_T );
|
||||
curl_setopt(data, tag, param_func);
|
||||
Curl_setopt(data, tag, param_func);
|
||||
}
|
||||
|
||||
va_end(arg);
|
||||
@@ -137,13 +133,12 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
|
||||
|
||||
CURLcode curl_easy_perform(CURL *curl)
|
||||
{
|
||||
return curl_transfer(curl);
|
||||
return Curl_perform(curl);
|
||||
}
|
||||
|
||||
void curl_easy_cleanup(CURL *curl)
|
||||
{
|
||||
curl_close(curl);
|
||||
curl_free();
|
||||
Curl_close(curl);
|
||||
}
|
||||
|
||||
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
|
||||
@@ -153,5 +148,5 @@ CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
|
||||
va_start(arg, info);
|
||||
paramp = va_arg(arg, void *);
|
||||
|
||||
return curl_getinfo(curl, info, paramp);
|
||||
return Curl_getinfo(curl, info, paramp);
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ char *curl_unescape(char *string, int length)
|
||||
char *ns = malloc(alloc);
|
||||
unsigned char in;
|
||||
int index=0;
|
||||
int hex;
|
||||
unsigned int hex;
|
||||
char querypart=FALSE; /* everything to the right of a '?' letter is
|
||||
the "query part" where '+' should become ' '.
|
||||
RFC 2316, section 3.10 */
|
||||
|
@@ -97,6 +97,9 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
||||
char *actual_path = curl_unescape(conn->path, 0);
|
||||
struct FILE *file;
|
||||
int fd;
|
||||
#if defined(WIN32) || defined(__EMX__)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
file = (struct FILE *)malloc(sizeof(struct FILE));
|
||||
if(!file)
|
||||
@@ -106,8 +109,6 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
||||
conn->proto.file = file;
|
||||
|
||||
#if defined(WIN32) || defined(__EMX__)
|
||||
int i;
|
||||
|
||||
/* change path separators from '/' to '\\' for Windows and OS/2 */
|
||||
for (i=0; actual_path[i] != '\0'; ++i)
|
||||
if (actual_path[i] == '/')
|
||||
|
@@ -119,8 +119,8 @@ static CURLcode AllowServerConnect(struct UrlData *data,
|
||||
size_t size = sizeof(struct sockaddr_in);
|
||||
struct sockaddr_in add;
|
||||
|
||||
getsockname(sock, (struct sockaddr *) &add, (int *)&size);
|
||||
s=accept(sock, (struct sockaddr *) &add, (int *)&size);
|
||||
getsockname(sock, (struct sockaddr *) &add, (socklen_t *)&size);
|
||||
s=accept(sock, (struct sockaddr *) &add, (socklen_t *)&size);
|
||||
|
||||
sclose(sock); /* close the first socket */
|
||||
|
||||
@@ -932,7 +932,7 @@ again:;
|
||||
size = sizeof(add);
|
||||
|
||||
if(getsockname(portsock, (struct sockaddr *) &add,
|
||||
(int *)&size)<0) {
|
||||
(socklen_t *)&size)<0) {
|
||||
failf(data, "getsockname() failed");
|
||||
return CURLE_FTP_PORT_FAILED;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...)
|
||||
CURLcode Curl_getinfo(CURL *curl, CURLINFO info, ...)
|
||||
{
|
||||
va_list arg;
|
||||
long *param_longp;
|
||||
|
12
lib/http.c
12
lib/http.c
@@ -469,10 +469,14 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
|
||||
}
|
||||
|
||||
if(!checkheaders(data, "Host:") &&
|
||||
!conn->allocptr.host) {
|
||||
/* if ptr_host is already set, it is OK since we only re-use connections
|
||||
to the very same host and port */
|
||||
if(!checkheaders(data, "Host:")) {
|
||||
/* if ptr_host is already set, it is almost OK since we only re-use
|
||||
connections to the very same host and port, but when we use a HTTP
|
||||
proxy we have a persistant connect and yet we must change the Host:
|
||||
header! */
|
||||
|
||||
if(conn->allocptr.host)
|
||||
free(conn->allocptr.host);
|
||||
|
||||
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
|
||||
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
|
||||
|
@@ -115,10 +115,15 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
ch->hexindex++;
|
||||
}
|
||||
else {
|
||||
return 1; /* longer hex than we support */
|
||||
return CHUNKE_TOO_LONG_HEX; /* longer hex than we support */
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(0 == ch->hexindex) {
|
||||
/* This is illegal data, we received junk where we expected
|
||||
a hexadecimal digit. */
|
||||
return CHUNKE_ILLEGAL_HEX;
|
||||
}
|
||||
/* length and datap are unmodified */
|
||||
ch->hexbuffer[ch->hexindex]=0;
|
||||
ch->datasize=strtoul(ch->hexbuffer, NULL, 16);
|
||||
@@ -127,7 +132,9 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
break;
|
||||
|
||||
case CHUNK_POSTHEX:
|
||||
/* just a lame state waiting for CRLF to arrive */
|
||||
/* In this state, we're waiting for CRLF to arrive. We support
|
||||
this to allow so called chunk-extensions to show up here
|
||||
before the CRLF comes. */
|
||||
if(*datap == '\r')
|
||||
ch->state = CHUNK_CR;
|
||||
length--;
|
||||
@@ -174,10 +181,34 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
||||
length -= piece; /* decrease space left in this round */
|
||||
|
||||
if(0 == ch->datasize)
|
||||
/* end of data this round, go back to get a new size */
|
||||
Curl_httpchunk_init(conn);
|
||||
|
||||
/* end of data this round, we now expect a trailing CRLF */
|
||||
ch->state = CHUNK_POSTCR;
|
||||
break;
|
||||
|
||||
case CHUNK_POSTCR:
|
||||
if(*datap == '\r') {
|
||||
ch->state = CHUNK_POSTLF;
|
||||
datap++;
|
||||
length--;
|
||||
}
|
||||
else
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
break;
|
||||
|
||||
case CHUNK_POSTLF:
|
||||
if(*datap == '\n') {
|
||||
/*
|
||||
* The last one before we go back to hex state and start all
|
||||
* over.
|
||||
*/
|
||||
Curl_httpchunk_init(conn);
|
||||
datap++;
|
||||
length--;
|
||||
}
|
||||
else
|
||||
return CHUNKE_BAD_CHUNK;
|
||||
break;
|
||||
|
||||
case CHUNK_STOP:
|
||||
/* If we arrive here, there is data left in the end of the buffer
|
||||
even if there's no more chunks to read */
|
||||
|
@@ -24,13 +24,13 @@
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* The longest possible hexadecimal number we support in a chunked transfer.
|
||||
* Weird enoug, RFC2616 doesn't set a maximum size! Since we use strtoul()
|
||||
* Weird enough, RFC2616 doesn't set a maximum size! Since we use strtoul()
|
||||
* to convert it, we "only" support 2^32 bytes chunk data.
|
||||
*/
|
||||
#define MAXNUM_SIZE 16
|
||||
|
||||
typedef enum {
|
||||
CHUNK_LOST, /* never use */
|
||||
CHUNK_FIRST, /* never use */
|
||||
|
||||
/* In this we await and buffer all hexadecimal digits until we get one
|
||||
that isn't a hexadecimal digit. When done, we go POSTHEX */
|
||||
@@ -45,10 +45,17 @@ typedef enum {
|
||||
If the size given was zero, we set state to STOP and return. */
|
||||
CHUNK_CR,
|
||||
|
||||
/* We eat the amount of data specified. When done, we move back to the
|
||||
HEX state. */
|
||||
/* We eat the amount of data specified. When done, we move on to the
|
||||
POST_CR state. */
|
||||
CHUNK_DATA,
|
||||
|
||||
/* POSTCR should get a CR and nothing else, then move to POSTLF */
|
||||
CHUNK_POSTCR,
|
||||
|
||||
/* POSTLF should get a LF and nothing else, then move back to HEX as
|
||||
the CRLF combination marks the end of a chunk */
|
||||
CHUNK_POSTLF,
|
||||
|
||||
/* This is mainly used to really mark that we're out of the game.
|
||||
NOTE: that there's a 'dataleft' field in the struct that will tell how
|
||||
many bytes that were not passed to the client in the end of the last
|
||||
@@ -62,6 +69,8 @@ typedef enum {
|
||||
CHUNKE_STOP = -1,
|
||||
CHUNKE_OK = 0,
|
||||
CHUNKE_TOO_LONG_HEX = 1,
|
||||
CHUNKE_ILLEGAL_HEX,
|
||||
CHUNKE_BAD_CHUNK,
|
||||
CHUNKE_WRITE_ERROR,
|
||||
CHUNKE_STATE_ERROR,
|
||||
CHUNKE_LAST
|
||||
|
@@ -2,41 +2,30 @@
|
||||
; Definition file for the DLL version of the LIBCURL library from curl
|
||||
;
|
||||
|
||||
LIBRARY CURL
|
||||
LIBRARY LIBCURL
|
||||
|
||||
DESCRIPTION 'curl libcurl - http://curl.haxx.se'
|
||||
|
||||
EXPORTS
|
||||
curl_close @ 1 ;
|
||||
curl_connect @ 2 ;
|
||||
curl_disconnect @ 3 ;
|
||||
curl_do @ 4 ;
|
||||
curl_done @ 5 ;
|
||||
curl_easy_cleanup @ 6 ;
|
||||
curl_easy_getinfo @ 7 ;
|
||||
curl_easy_init @ 8 ;
|
||||
curl_easy_perform @ 9 ;
|
||||
curl_easy_setopt @ 10 ;
|
||||
curl_escape @ 11 ;
|
||||
curl_formparse @ 12 ;
|
||||
curl_free @ 13 ;
|
||||
curl_getdate @ 14 ;
|
||||
curl_getenv @ 15 ;
|
||||
curl_init @ 16 ;
|
||||
curl_open @ 17 ;
|
||||
curl_read @ 18 ;
|
||||
curl_setopt @ 19 ;
|
||||
curl_slist_append @ 20 ;
|
||||
curl_slist_free_all @ 21 ;
|
||||
curl_transfer @ 22 ;
|
||||
curl_unescape @ 23 ;
|
||||
curl_version @ 24 ;
|
||||
curl_write @ 25 ;
|
||||
curl_maprintf @ 26 ;
|
||||
curl_mfprintf @ 27 ;
|
||||
curl_mprintf @ 28 ;
|
||||
curl_msprintf @ 29 ;
|
||||
curl_msnprintf @ 30 ;
|
||||
curl_mvfprintf @ 31 ;
|
||||
Curl_strequal @ 32 ;
|
||||
Curl_strnequal @ 33 ;
|
||||
curl_easy_cleanup @ 1 ;
|
||||
curl_easy_getinfo @ 2 ;
|
||||
curl_easy_init @ 3 ;
|
||||
curl_easy_perform @ 4 ;
|
||||
curl_easy_setopt @ 5 ;
|
||||
curl_escape @ 6 ;
|
||||
curl_formparse @ 7 ;
|
||||
curl_formfree @ 8 ;
|
||||
curl_getdate @ 9 ;
|
||||
curl_getenv @ 10 ;
|
||||
curl_slist_append @ 11 ;
|
||||
curl_slist_free_all @ 12 ;
|
||||
curl_unescape @ 13 ;
|
||||
curl_version @ 14 ;
|
||||
curl_maprintf @ 15 ;
|
||||
curl_mfprintf @ 16 ;
|
||||
curl_mprintf @ 17 ;
|
||||
curl_msprintf @ 18 ;
|
||||
curl_msnprintf @ 19 ;
|
||||
curl_mvfprintf @ 20 ;
|
||||
curl_strequal @ 21 ;
|
||||
curl_strnequal @ 22 ;
|
||||
|
@@ -120,7 +120,7 @@ int curl_socket(int domain, int type, int protocol, int line, char *source)
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
int curl_accept(int s, struct sockaddr *addr, int *addrlen,
|
||||
int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
|
||||
int line, char *source)
|
||||
{
|
||||
int sockfd=(accept)(s, addr, addrlen);
|
||||
|
@@ -13,7 +13,7 @@ void curl_memdebug(char *logname);
|
||||
/* file descriptor manipulators */
|
||||
int curl_socket(int domain, int type, int protocol, int, char *);
|
||||
int curl_sclose(int sockfd, int, char *);
|
||||
int curl_accept(int s, struct sockaddr *addr, int *addrlen,
|
||||
int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
|
||||
int line, char *source);
|
||||
|
||||
/* FILE functions */
|
||||
|
39
lib/sendf.c
39
lib/sendf.c
@@ -120,7 +120,7 @@ void curl_slist_free_all(struct curl_slist *list)
|
||||
}
|
||||
|
||||
|
||||
/* infof() is for info message along the way */
|
||||
/* Curl_infof() is for info message along the way */
|
||||
|
||||
void Curl_infof(struct UrlData *data, char *fmt, ...)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ void Curl_infof(struct UrlData *data, char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
/* failf() is for messages stating why we failed, the LAST one will be
|
||||
/* Curl_failf() is for messages stating why we failed, the LAST one will be
|
||||
returned for the user (if requested) */
|
||||
|
||||
void Curl_failf(struct UrlData *data, char *fmt, ...)
|
||||
@@ -142,7 +142,7 @@ void Curl_failf(struct UrlData *data, char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
if(data->errorbuffer)
|
||||
vsnprintf(data->errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
||||
else {
|
||||
else if(!data->bits.mute) {
|
||||
/* no errorbuffer receives this, write to data->err instead */
|
||||
vfprintf(data->err, fmt, ap);
|
||||
fprintf(data->err, "\n");
|
||||
@@ -213,23 +213,6 @@ CURLcode Curl_write(struct connectdata *conn, int sockfd,
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* External write-function, writes to the data-socket.
|
||||
* Takes care of plain sockets, SSL or kerberos transparently.
|
||||
*/
|
||||
CURLcode curl_write(CURLconnect *c_conn, char *buf, size_t amount,
|
||||
size_t *n)
|
||||
{
|
||||
struct connectdata *conn = (struct connectdata *)c_conn;
|
||||
|
||||
if(!n || !conn || (conn->handle != STRUCT_CONNECT))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
return Curl_write(conn, conn->sockfd, buf, amount, n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* client_write() sends data to the write callback(s)
|
||||
|
||||
The bit pattern defines to what "streams" to write to. Body and/or header.
|
||||
@@ -299,19 +282,3 @@ CURLcode Curl_read(struct connectdata *conn, int sockfd,
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* The public read function reads from the 'sockfd' file descriptor only.
|
||||
* Use the Curl_read() internally when you want to specify fd.
|
||||
*/
|
||||
|
||||
CURLcode curl_read(CURLconnect *c_conn, char *buf, size_t buffersize,
|
||||
ssize_t *n)
|
||||
{
|
||||
struct connectdata *conn = (struct connectdata *)c_conn;
|
||||
|
||||
if(!n || !conn || (conn->handle != STRUCT_CONNECT))
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
return Curl_read(conn, conn->sockfd, buf, buffersize, n);
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "setup.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if defined(__MINGW32__)
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
55
lib/ssluse.c
55
lib/ssluse.c
@@ -80,34 +80,39 @@ int random_the_seed(struct connectdata *conn)
|
||||
{
|
||||
char *buf = conn->data->buffer; /* point to the big buffer */
|
||||
int nread=0;
|
||||
struct UrlData *data=conn->data;
|
||||
|
||||
/* Q: should we add support for a random file name as a libcurl option?
|
||||
A: Yes */
|
||||
#if 0
|
||||
/* something like this */
|
||||
nread += RAND_load_file(filename, number_of_bytes);
|
||||
A: Yes, it is here */
|
||||
|
||||
#ifndef RANDOM_FILE
|
||||
/* if RANDOM_FILE isn't defined, we only perform this if an option tells
|
||||
us to! */
|
||||
if(data->ssl.random_file)
|
||||
#define RANDOM_FILE "" /* doesn't matter won't be used */
|
||||
#endif
|
||||
/* generates a default path for the random seed file */
|
||||
buf[0]=0; /* blank it first */
|
||||
RAND_file_name(buf, BUFSIZE);
|
||||
if ( buf[0] ) {
|
||||
/* we got a file name to try */
|
||||
nread += RAND_load_file(buf, 16384);
|
||||
{
|
||||
/* let the option override the define */
|
||||
nread += RAND_load_file((data->ssl.random_file?
|
||||
data->ssl.random_file:RANDOM_FILE),
|
||||
16384);
|
||||
if(seed_enough(conn, nread))
|
||||
return nread;
|
||||
}
|
||||
|
||||
#ifdef RANDOM_FILE
|
||||
nread += RAND_load_file(RANDOM_FILE, 16384);
|
||||
if(seed_enough(conn, nread))
|
||||
return nread;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RAND_EGD) && defined(EGD_SOCKET)
|
||||
#if defined(HAVE_RAND_EGD)
|
||||
/* only available in OpenSSL 0.9.5 and later */
|
||||
/* EGD_SOCKET is set at configure time */
|
||||
/* EGD_SOCKET is set at configure time or not at all */
|
||||
#ifndef EGD_SOCKET
|
||||
/* If we don't have the define set, we only do this if the egd-option
|
||||
is set */
|
||||
if(data->ssl.egdsocket)
|
||||
#define EGD_SOCKET "" /* doesn't matter won't be used */
|
||||
#endif
|
||||
{
|
||||
int ret = RAND_egd(EGD_SOCKET);
|
||||
/* If there's an option and a define, the option overrides the
|
||||
define */
|
||||
int ret = RAND_egd(data->ssl.egdsocket?data->ssl.egdsocket:EGD_SOCKET);
|
||||
if(-1 != ret) {
|
||||
nread += ret;
|
||||
if(seed_enough(conn, nread))
|
||||
@@ -133,7 +138,17 @@ int random_the_seed(struct connectdata *conn)
|
||||
RAND_seed(area, len);
|
||||
|
||||
free(area); /* now remove the random junk */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* generates a default path for the random seed file */
|
||||
buf[0]=0; /* blank it first */
|
||||
RAND_file_name(buf, BUFSIZE);
|
||||
if ( buf[0] ) {
|
||||
/* we got a file name to try */
|
||||
nread += RAND_load_file(buf, 16384);
|
||||
if(seed_enough(conn, nread))
|
||||
return nread;
|
||||
}
|
||||
|
||||
infof(conn->data, "Your connection is using a weak random seed!\n");
|
||||
@@ -343,7 +358,7 @@ Curl_SSLConnect(struct connectdata *conn)
|
||||
X509_free(conn->ssl.server_cert);
|
||||
#else /* USE_SSLEAY */
|
||||
/* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */
|
||||
(void) data;
|
||||
(void) conn;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int Curl_strequal(const char *first, const char *second)
|
||||
int curl_strequal(const char *first, const char *second)
|
||||
{
|
||||
#if defined(HAVE_STRCASECMP)
|
||||
return !strcasecmp(first, second);
|
||||
@@ -45,7 +45,7 @@ int Curl_strequal(const char *first, const char *second)
|
||||
#endif
|
||||
}
|
||||
|
||||
int Curl_strnequal(const char *first, const char *second, size_t max)
|
||||
int curl_strnequal(const char *first, const char *second, size_t max)
|
||||
{
|
||||
#if defined(HAVE_STRCASECMP)
|
||||
return !strncasecmp(first, second, max);
|
||||
|
@@ -22,10 +22,14 @@
|
||||
*
|
||||
* $Id$
|
||||
*****************************************************************************/
|
||||
int Curl_strequal(const char *first, const char *second);
|
||||
int Curl_strnequal(const char *first, const char *second, size_t max);
|
||||
|
||||
#define strequal(a,b) Curl_strequal(a,b)
|
||||
#define strnequal(a,b,c) Curl_strnequal(a,b,c)
|
||||
/*
|
||||
* These two actually are public functions.
|
||||
*/
|
||||
int curl_strequal(const char *first, const char *second);
|
||||
int curl_strnequal(const char *first, const char *second, size_t max);
|
||||
|
||||
#define strequal(a,b) curl_strequal(a,b)
|
||||
#define strnequal(a,b,c) curl_strnequal(a,b,c)
|
||||
|
||||
#endif
|
||||
|
@@ -53,7 +53,7 @@ gettimeofday (struct timeval *tp, void *nothing)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct timeval Curl_tvnow ()
|
||||
struct timeval Curl_tvnow (void)
|
||||
{
|
||||
struct timeval now;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
|
@@ -107,7 +107,7 @@
|
||||
<butlerm@xmission.com>. */
|
||||
|
||||
CURLcode static
|
||||
_Transfer(struct connectdata *c_conn)
|
||||
Transfer(struct connectdata *c_conn)
|
||||
{
|
||||
ssize_t nread; /* number of bytes read */
|
||||
int bytecount = 0; /* total number of bytes read */
|
||||
@@ -142,9 +142,6 @@ _Transfer(struct connectdata *c_conn)
|
||||
char *buf;
|
||||
int maxfd;
|
||||
|
||||
if(!conn || (conn->handle != STRUCT_CONNECT))
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
data = conn->data; /* there's the root struct */
|
||||
buf = data->buffer;
|
||||
maxfd = (conn->sockfd>conn->writesockfd?conn->sockfd:conn->writesockfd)+1;
|
||||
@@ -370,6 +367,12 @@ _Transfer(struct connectdata *c_conn)
|
||||
return CURLE_HTTP_NOT_FOUND;
|
||||
}
|
||||
data->progress.httpcode = code;
|
||||
data->progress.httpversion = httpversion;
|
||||
if(httpversion == 0)
|
||||
/* Default action for HTTP/1.0 must be to close, unless
|
||||
we get one of those fancy headers that tell us the
|
||||
server keeps it open for us! */
|
||||
conn->bits.close = TRUE;
|
||||
}
|
||||
else {
|
||||
header = FALSE; /* this is not a header line */
|
||||
@@ -382,6 +385,19 @@ _Transfer(struct connectdata *c_conn)
|
||||
conn->size = contentlength;
|
||||
Curl_pgrsSetDownloadSize(data, contentlength);
|
||||
}
|
||||
else if((httpversion == 0) &&
|
||||
conn->bits.httpproxy &&
|
||||
strnequal("Proxy-Connection: keep-alive", p,
|
||||
strlen("Proxy-Connection: keep-alive"))) {
|
||||
/*
|
||||
* When a HTTP/1.0 reply comes when using a proxy, the
|
||||
* 'Proxy-Connection: keep-alive' line tells us the
|
||||
* connection will be kept alive for our pleasure.
|
||||
* Default action for 1.0 is to close.
|
||||
*/
|
||||
conn->bits.close = FALSE; /* don't close when done */
|
||||
infof(data, "HTTP/1.0 proxy connection set to keep alive!\n");
|
||||
}
|
||||
else if (strnequal("Connection: close", p,
|
||||
strlen("Connection: close"))) {
|
||||
/*
|
||||
@@ -446,7 +462,7 @@ _Transfer(struct connectdata *c_conn)
|
||||
ptr++;
|
||||
backup = *ptr; /* store the ending letter */
|
||||
*ptr = '\0'; /* zero terminate */
|
||||
data->newurl = strdup(start); /* clone string */
|
||||
conn->newurl = strdup(start); /* clone string */
|
||||
*ptr = backup; /* restore ending letter */
|
||||
}
|
||||
|
||||
@@ -490,9 +506,9 @@ _Transfer(struct connectdata *c_conn)
|
||||
write a piece of the body */
|
||||
if(conn->protocol&PROT_HTTP) {
|
||||
/* HTTP-only checks */
|
||||
if (data->newurl) {
|
||||
if (conn->newurl) {
|
||||
/* abort after the headers if "follow Location" is set */
|
||||
infof (data, "Follow to new URL: %s\n", data->newurl);
|
||||
infof (data, "Follow to new URL: %s\n", conn->newurl);
|
||||
return CURLE_OK;
|
||||
}
|
||||
else if (data->resume_from &&
|
||||
@@ -530,7 +546,8 @@ _Transfer(struct connectdata *c_conn)
|
||||
} /* switch */
|
||||
} /* two valid time strings */
|
||||
} /* we have a time condition */
|
||||
if(!conn->bits.close && (httpversion == 1)) {
|
||||
|
||||
if(!conn->bits.close) {
|
||||
/* If this is not the last request before a close, we must
|
||||
set the maximum download size to the size of the expected
|
||||
document or else, we won't know when to stop reading! */
|
||||
@@ -554,15 +571,17 @@ _Transfer(struct connectdata *c_conn)
|
||||
CHUNKcode res =
|
||||
Curl_httpchunk_read(conn, str, nread, &nread);
|
||||
|
||||
if(CHUNKE_OK < res)
|
||||
if(CHUNKE_OK < res) {
|
||||
failf(data, "Receeived problem in the chunky parser");
|
||||
return CURLE_READ_ERROR;
|
||||
}
|
||||
else if(CHUNKE_STOP == res) {
|
||||
/* we're done reading chunks! */
|
||||
keepon &= ~KEEP_READ; /* read no more */
|
||||
|
||||
/* There are now possibly bytes at the end of the str buffer
|
||||
that weren't written to the client, but we don't care
|
||||
about them right now. */
|
||||
/* There are now possibly N number of bytes at the end of the
|
||||
str buffer that weren't written to the client, but we don't
|
||||
care about them right now. */
|
||||
}
|
||||
/* If it returned OK, we just keep going */
|
||||
}
|
||||
@@ -681,27 +700,27 @@ _Transfer(struct connectdata *c_conn)
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
CURLcode curl_transfer(CURL *curl)
|
||||
CURLcode Curl_perform(CURL *curl)
|
||||
{
|
||||
CURLcode res;
|
||||
struct UrlData *data = curl;
|
||||
struct connectdata *c_connect=NULL;
|
||||
struct UrlData *data = (struct UrlData *)curl;
|
||||
struct connectdata *conn=NULL;
|
||||
bool port=TRUE; /* allow data->use_port to set port to use */
|
||||
|
||||
Curl_pgrsStartNow(data);
|
||||
|
||||
do {
|
||||
Curl_pgrsTime(data, TIMER_STARTSINGLE);
|
||||
res = curl_connect(curl, (CURLconnect **)&c_connect, port);
|
||||
res = Curl_connect(data, &conn, port);
|
||||
if(res == CURLE_OK) {
|
||||
res = curl_do(c_connect);
|
||||
res = Curl_do(conn);
|
||||
if(res == CURLE_OK) {
|
||||
res = _Transfer(c_connect); /* now fetch that URL please */
|
||||
res = Transfer(conn); /* now fetch that URL please */
|
||||
if(res == CURLE_OK)
|
||||
res = curl_done(c_connect);
|
||||
res = Curl_done(conn);
|
||||
}
|
||||
|
||||
if((res == CURLE_OK) && data->newurl) {
|
||||
if((res == CURLE_OK) && conn->newurl) {
|
||||
/* Location: redirect
|
||||
|
||||
This is assumed to happen for HTTP(S) only!
|
||||
@@ -741,7 +760,7 @@ CURLcode curl_transfer(CURL *curl)
|
||||
data->bits.http_set_referer = TRUE; /* might have been false */
|
||||
}
|
||||
|
||||
if(2 != sscanf(data->newurl, "%15[^:]://%c", prot, &letter)) {
|
||||
if(2 != sscanf(conn->newurl, "%15[^:]://%c", prot, &letter)) {
|
||||
/***
|
||||
*DANG* this is an RFC 2068 violation. The URL is supposed
|
||||
to be absolute and this doesn't seem to be that!
|
||||
@@ -766,7 +785,7 @@ CURLcode curl_transfer(CURL *curl)
|
||||
protsep+=2; /* pass the slashes */
|
||||
}
|
||||
|
||||
if('/' != data->newurl[0]) {
|
||||
if('/' != conn->newurl[0]) {
|
||||
/* First we need to find out if there's a ?-letter in the URL,
|
||||
and cut it and the right-side of that off */
|
||||
pathsep = strrchr(protsep, '?');
|
||||
@@ -789,14 +808,14 @@ CURLcode curl_transfer(CURL *curl)
|
||||
|
||||
newest=(char *)malloc( strlen(data->url) +
|
||||
1 + /* possible slash */
|
||||
strlen(data->newurl) + 1/* zero byte */);
|
||||
strlen(conn->newurl) + 1/* zero byte */);
|
||||
|
||||
if(!newest)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
sprintf(newest, "%s%s%s", data->url, ('/' == data->newurl[0])?"":"/",
|
||||
data->newurl);
|
||||
free(data->newurl);
|
||||
data->newurl = newest;
|
||||
sprintf(newest, "%s%s%s", data->url, ('/' == conn->newurl[0])?"":"/",
|
||||
conn->newurl);
|
||||
free(conn->newurl);
|
||||
conn->newurl = newest;
|
||||
}
|
||||
else {
|
||||
/* This is an absolute URL, don't use the custom port number */
|
||||
@@ -807,8 +826,8 @@ CURLcode curl_transfer(CURL *curl)
|
||||
free(data->url);
|
||||
|
||||
/* TBD: set the URL with curl_setopt() */
|
||||
data->url = data->newurl;
|
||||
data->newurl = NULL; /* don't show! */
|
||||
data->url = conn->newurl;
|
||||
conn->newurl = NULL; /* don't show! */
|
||||
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
|
||||
|
||||
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
|
||||
@@ -867,8 +886,10 @@ CURLcode curl_transfer(CURL *curl)
|
||||
|
||||
} while(1); /* loop if Location: */
|
||||
|
||||
if(data->newurl)
|
||||
free(data->newurl);
|
||||
if(conn->newurl) {
|
||||
free(conn->newurl);
|
||||
conn->newurl = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@@ -22,8 +22,9 @@
|
||||
*
|
||||
* $Id$
|
||||
*****************************************************************************/
|
||||
CURLcode curl_transfer(CURL *curl);
|
||||
CURLcode Curl_perform(CURL *curl);
|
||||
|
||||
/* This sets up a forthcoming transfer */
|
||||
CURLcode
|
||||
Curl_Transfer (struct connectdata *data,
|
||||
int sockfd, /* socket to read from or -1 */
|
||||
|
251
lib/urldata.h
251
lib/urldata.h
@@ -98,27 +98,6 @@
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
/* Type of handle. All publicly returned 'handles' in the curl interface
|
||||
have a handle first in the struct that describes what kind of handle it
|
||||
is. Used to detect bad handle usage. */
|
||||
typedef enum {
|
||||
STRUCT_NONE,
|
||||
STRUCT_OPEN,
|
||||
STRUCT_CONNECT,
|
||||
STRUCT_LAST
|
||||
} Handle;
|
||||
|
||||
/* Connecting to a remote server using the curl interface is moving through
|
||||
a state machine, this type is used to store the current state */
|
||||
typedef enum {
|
||||
CONN_NONE, /* illegal state */
|
||||
CONN_INIT, /* curl_connect() has been called */
|
||||
CONN_DO, /* curl_do() has been called successfully */
|
||||
CONN_DONE, /* curl_done() has been called successfully */
|
||||
CONN_ERROR, /* and error has occurred */
|
||||
CONN_LAST /* illegal state */
|
||||
} ConnState;
|
||||
|
||||
#ifdef KRB4
|
||||
/* Types needed for krb4-ftp connections */
|
||||
struct krb4buffer {
|
||||
@@ -152,6 +131,8 @@ struct ssl_config_data {
|
||||
long verifypeer; /* set TRUE if this is desired */
|
||||
char *CApath; /* DOES NOT WORK ON WINDOWS */
|
||||
char *CAfile; /* cerficate to verify peer against */
|
||||
char *random_file; /* path to file containing "random" data */
|
||||
char *egdsocket; /* path to file containing the EGD daemon socket */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -201,6 +182,7 @@ struct ConnectBits {
|
||||
bool close; /* if set, we close the connection after this request */
|
||||
bool reuse; /* if set, this is a re-used connection */
|
||||
bool chunk; /* if set, this is a chunked transfer-encoding */
|
||||
bool httpproxy; /* if set, this transfer is done through a http proxy */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -209,18 +191,10 @@ struct ConnectBits {
|
||||
*/
|
||||
struct connectdata {
|
||||
/**** Fields set when inited and not modified again */
|
||||
|
||||
/* To better see what kind of struct that is passed as input, *ALL* publicly
|
||||
returned handles MUST have this initial 'Handle'. */
|
||||
Handle handle; /* struct identifier */
|
||||
struct UrlData *data; /* link to the root CURL struct */
|
||||
|
||||
int connectindex; /* what index in the connects index this particular
|
||||
struct has */
|
||||
|
||||
/**** curl_connect() phase fields */
|
||||
ConnState state; /* for state dependent actions */
|
||||
|
||||
long protocol; /* PROT_* flags concerning the protocol set */
|
||||
#define PROT_MISSING (1<<0)
|
||||
#define PROT_GOPHER (1<<1)
|
||||
@@ -250,7 +224,11 @@ struct connectdata {
|
||||
not the proxy port! */
|
||||
char *ppath;
|
||||
long bytecount;
|
||||
struct timeval now; /* current time */
|
||||
|
||||
char *proxyhost; /* name of the http proxy host */
|
||||
|
||||
struct timeval now; /* "current" time */
|
||||
struct timeval created; /* creation time */
|
||||
int firstsocket; /* the main socket to use */
|
||||
int secondarysocket; /* for i.e ftp transfers */
|
||||
|
||||
@@ -309,6 +287,9 @@ struct connectdata {
|
||||
char *host; /* free later if not NULL */
|
||||
} allocptr;
|
||||
|
||||
char *newurl; /* This can only be set if a Location: was in the
|
||||
document headers */
|
||||
|
||||
#ifdef KRB4
|
||||
|
||||
enum protection_level command_prot;
|
||||
@@ -366,6 +347,7 @@ struct Progress {
|
||||
double t_connect;
|
||||
double t_pretransfer;
|
||||
int httpcode;
|
||||
int httpversion;
|
||||
time_t filetime; /* If requested, this is might get set. It may be 0 if
|
||||
the time was unretrievable */
|
||||
|
||||
@@ -421,16 +403,12 @@ struct Configbits {
|
||||
bool proxystringalloc; /* the http proxy string is malloc()'ed */
|
||||
bool rangestringalloc; /* the range string is malloc()'ed */
|
||||
bool urlstringalloc; /* the URL string is malloc()'ed */
|
||||
bool reuse_forbid; /* if this is forbidden to be reused, close
|
||||
after use */
|
||||
bool reuse_fresh; /* do not re-use an existing connection for this
|
||||
transfer */
|
||||
};
|
||||
|
||||
/* What type of interface that intiated this struct */
|
||||
typedef enum {
|
||||
CURLI_NONE,
|
||||
CURLI_EASY,
|
||||
CURLI_NORMAL,
|
||||
CURLI_LAST
|
||||
} CurlInterface;
|
||||
|
||||
/*
|
||||
* As of April 11, 2000 we're now trying to split up the urldata struct in
|
||||
* three different parts:
|
||||
@@ -457,9 +435,6 @@ typedef enum {
|
||||
*/
|
||||
|
||||
struct UrlData {
|
||||
Handle handle; /* struct identifier */
|
||||
CurlInterface interf; /* created by WHAT interface? */
|
||||
|
||||
/*************** Global - specific items ************/
|
||||
FILE *err; /* the stderr writes goes here */
|
||||
char *errorbuffer; /* store failure messages in here */
|
||||
@@ -535,9 +510,6 @@ struct UrlData {
|
||||
|
||||
char *cookie; /* HTTP cookie string to send */
|
||||
|
||||
char *newurl; /* This can only be set if a Location: was in the
|
||||
document headers */
|
||||
|
||||
struct curl_slist *headers; /* linked list of extra headers */
|
||||
struct HttpPost *httppost; /* linked list of POST data */
|
||||
|
||||
@@ -597,191 +569,26 @@ struct UrlData {
|
||||
#define LIBCURL_NAME "libcurl"
|
||||
#define LIBCURL_ID LIBCURL_NAME " " LIBCURL_VERSION " " SSL_ID
|
||||
|
||||
CURLcode Curl_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
/*
|
||||
* Here follows function prototypes from what we used to plan to call
|
||||
* the "low level" interface. It is no longer prioritized and it is not likely
|
||||
* to ever be supported to external users.
|
||||
*
|
||||
* I removed all the comments to them as well, as they were no longer accurate
|
||||
* and they're not meant for "public use" anymore.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NAME curl_init()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Inits libcurl globally. This must be used before any libcurl calls can
|
||||
* be used. This may install global plug-ins or whatever. (This does not
|
||||
* do winsock inits in Windows.)
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* curl_init();
|
||||
*
|
||||
*/
|
||||
CURLcode curl_init(void);
|
||||
|
||||
/*
|
||||
* NAME curl_init()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Frees libcurl globally. This must be used after all libcurl calls have
|
||||
* been used. This may remove global plug-ins or whatever. (This does not
|
||||
* do winsock cleanups in Windows.)
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* curl_free(curl);
|
||||
*
|
||||
*/
|
||||
void curl_free(void);
|
||||
|
||||
/*
|
||||
* NAME curl_open()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Opens a general curl session. It does not try to connect or do anything
|
||||
* on the network because of this call. The specified URL is only required
|
||||
* to enable curl to figure out what protocol to "activate".
|
||||
*
|
||||
* A session should be looked upon as a series of requests to a single host. A
|
||||
* session interacts with one host only, using one single protocol.
|
||||
*
|
||||
* The URL is not required. If set to "" or NULL, it can still be set later
|
||||
* using the curl_setopt() function. If the curl_connect() function is called
|
||||
* without the URL being known, it will return error.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURLcode result;
|
||||
* CURL *curl;
|
||||
* result = curl_open(&curl, "http://curl.haxx.nu/libcurl/");
|
||||
* if(result != CURL_OK) {
|
||||
* return result;
|
||||
* }
|
||||
* */
|
||||
CURLcode curl_open(CURL **curl, char *url);
|
||||
|
||||
/*
|
||||
* NAME curl_setopt()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sets a particular option to the specified value.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURL curl;
|
||||
* curl_setopt(curl, CURL_HTTP_FOLLOW_LOCATION, TRUE);
|
||||
*/
|
||||
CURLcode curl_setopt(CURL *handle, CURLoption option, ...);
|
||||
|
||||
/*
|
||||
* NAME curl_close()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Closes a session previously opened with curl_open()
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURL *curl;
|
||||
* CURLcode result;
|
||||
*
|
||||
* result = curl_close(curl);
|
||||
*/
|
||||
CURLcode curl_close(CURL *curl); /* the opposite of curl_open() */
|
||||
|
||||
CURLcode curl_read(CURLconnect *c_conn, char *buf, size_t buffersize,
|
||||
ssize_t *n);
|
||||
CURLcode curl_write(CURLconnect *c_conn, char *buf, size_t amount,
|
||||
size_t *n);
|
||||
|
||||
/*
|
||||
* NAME curl_connect()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Connects to the peer server and performs the initial setup. This function
|
||||
* writes a connect handle to its second argument that is a unique handle for
|
||||
* this connect. This allows multiple connects from the same handle returned
|
||||
* by curl_open().
|
||||
*
|
||||
* By setting 'allow_port' to FALSE, the data->use_port will *NOT* be
|
||||
* respected.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURLCode result;
|
||||
* CURL curl;
|
||||
* CURLconnect connect;
|
||||
* result = curl_connect(curl, &connect); */
|
||||
|
||||
CURLcode curl_connect(CURL *curl,
|
||||
CURLconnect **in_connect,
|
||||
CURLcode Curl_open(CURL **curl, char *url);
|
||||
CURLcode Curl_setopt(CURL *handle, CURLoption option, ...);
|
||||
CURLcode Curl_close(CURL *curl); /* the opposite of curl_open() */
|
||||
CURLcode Curl_connect(struct UrlData *,
|
||||
struct connectdata **,
|
||||
bool allow_port);
|
||||
|
||||
/*
|
||||
* NAME curl_do()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* (Note: May 3rd 2000: this function does not currently allow you to
|
||||
* specify a document, it will use the one set previously)
|
||||
*
|
||||
* This function asks for the particular document, file or resource that
|
||||
* resides on the server we have connected to. You may specify a full URL,
|
||||
* just an absolute path or even a relative path. That means, if you're just
|
||||
* getting one file from the remote site, you can use the same URL as input
|
||||
* for both curl_open() as well as for this function.
|
||||
*
|
||||
* In the even there is a host name, port number, user name or password parts
|
||||
* in the URL, you can use the 'flags' argument to ignore them completely, or
|
||||
* at your choice, make the function fail if you're trying to get a URL from
|
||||
* different host than you connected to with curl_connect().
|
||||
*
|
||||
* You can only get one document at a time using the same connection. When one
|
||||
* document has been received you can although request again.
|
||||
*
|
||||
* When the transfer is done, curl_done() MUST be called.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURLCode result;
|
||||
* char *url;
|
||||
* CURLconnect *connect;
|
||||
* result = curl_do(connect, url, CURL_DO_NONE); */
|
||||
CURLcode curl_do(CURLconnect *in_conn);
|
||||
|
||||
/*
|
||||
* NAME curl_done()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* When the transfer following a curl_do() call is done, this function should
|
||||
* get called.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURLCode result;
|
||||
* char *url;
|
||||
* CURLconnect *connect;
|
||||
* result = curl_done(connect); */
|
||||
CURLcode curl_done(CURLconnect *connect);
|
||||
|
||||
/*
|
||||
* NAME curl_disconnect()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Disconnects from the peer server and performs connection cleanup.
|
||||
*
|
||||
* EXAMPLE
|
||||
*
|
||||
* CURLcode result;
|
||||
* CURLconnect *connect;
|
||||
* result = curl_disconnect(connect); */
|
||||
CURLcode curl_disconnect(CURLconnect *connect);
|
||||
CURLcode Curl_do(struct connectdata *);
|
||||
CURLcode Curl_done(struct connectdata *);
|
||||
CURLcode Curl_disconnect(struct connectdata *);
|
||||
|
||||
|
||||
#endif
|
||||
|
342
src/main.c
342
src/main.c
@@ -29,8 +29,6 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h> /* new for v7 */
|
||||
#include <curl/easy.h> /* new for v7 */
|
||||
|
||||
#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
|
||||
#include <curl/mprintf.h>
|
||||
@@ -242,61 +240,62 @@ static void help(void)
|
||||
" -a/--append Append to target file when uploading (F)\n"
|
||||
" -A/--user-agent <string> User-Agent to send to server (H)\n"
|
||||
" -b/--cookie <name=string/file> Cookie string or file to read cookies from (H)\n"
|
||||
" -B/--use-ascii Use ASCII/text transfer\n"
|
||||
" -C/--continue-at <offset> Specify absolute resume offset\n"
|
||||
" -B/--use-ascii Use ASCII/text transfer\n",
|
||||
curl_version());
|
||||
puts(" -C/--continue-at <offset> Specify absolute resume offset\n"
|
||||
" -d/--data <data> HTTP POST data (H)\n"
|
||||
" --data-ascii <data> HTTP POST ASCII data (H)\n"
|
||||
" --data-binary <data> HTTP POST binary data (H)\n"
|
||||
" -D/--dump-header <file> Write the headers to this file\n"
|
||||
" -e/--referer Referer page (H)\n"
|
||||
" -E/--cert <cert[:passwd]> Specifies your certificate file and password (HTTPS)\n"
|
||||
" -e/--referer Referer page (H)");
|
||||
puts(" -E/--cert <cert[:passwd]> Specifies your certificate file and password (HTTPS)\n"
|
||||
" --cacert <file> CA certifciate to verify peer against (HTTPS)\n"
|
||||
" -f/--fail Fail silently (no output at all) on errors (H)\n"
|
||||
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
||||
" -g/--globoff Disable URL sequences and ranges using {} and []\n"
|
||||
" -h/--help This help text\n"
|
||||
" -H/--header <line> Custom header to pass to server. (H)\n"
|
||||
" -i/--include Include the HTTP-header in the output (H)\n"
|
||||
" -H/--header <line> Custom header to pass to server. (H)");
|
||||
puts(" -i/--include Include the HTTP-header in the output (H)\n"
|
||||
" -I/--head Fetch document info only (HTTP HEAD/FTP SIZE)\n"
|
||||
" --interface <interface> Specify the interface to be used\n"
|
||||
" --krb4 <level> Enable krb4 with specified security level (F)\n"
|
||||
" -K/--config Specify which config file to read\n"
|
||||
" -l/--list-only List only names of an FTP directory (F)\n"
|
||||
" -L/--location Follow Location: hints (H)\n"
|
||||
" -l/--list-only List only names of an FTP directory (F)");
|
||||
puts(" -L/--location Follow Location: hints (H)\n"
|
||||
" -m/--max-time <seconds> Maximum time allowed for the transfer\n"
|
||||
" -M/--manual Display huge help text\n"
|
||||
" -n/--netrc Read .netrc for user name and password\n"
|
||||
" -N/--no-buffer Disables the buffering of the output stream\n"
|
||||
" -o/--output <file> Write output to <file> instead of stdout\n"
|
||||
" -N/--no-buffer Disables the buffering of the output stream");
|
||||
puts(" -o/--output <file> Write output to <file> instead of stdout\n"
|
||||
" -O/--remote-name Write output to a file named as the remote file\n"
|
||||
" -p/--proxytunnel Perform non-HTTP services through a HTTP proxy\n"
|
||||
" -P/--ftpport <address> Use PORT with address instead of PASV when ftping (F)\n"
|
||||
" -q When used as the first parameter disables .curlrc\n"
|
||||
" -Q/--quote <cmd> Send QUOTE command to FTP before file transfer (F)\n"
|
||||
" -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server\n"
|
||||
" -Q/--quote <cmd> Send QUOTE command to FTP before file transfer (F)");
|
||||
puts(" -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server\n"
|
||||
" -s/--silent Silent mode. Don't output anything\n"
|
||||
" -S/--show-error Show error. With -s, make curl show errors when they occur\n"
|
||||
" -t/--telnet-option <OPT=val> Set telnet option\n"
|
||||
" -T/--upload-file <file> Transfer/upload <file> to remote site\n"
|
||||
" --url <URL> Another way to specify URL to work with\n"
|
||||
" -u/--user <user[:password]> Specify user and password to use\n"
|
||||
" --url <URL> Another way to specify URL to work with");
|
||||
puts(" -u/--user <user[:password]> Specify user and password to use\n"
|
||||
" -U/--proxy-user <user[:password]> Specify Proxy authentication\n"
|
||||
" -v/--verbose Makes the operation more talkative\n"
|
||||
" -V/--version Outputs version number then quits\n"
|
||||
" -w/--write-out [format] What to output after completion\n"
|
||||
" -x/--proxy <host[:port]> Use proxy. (Default port is 1080)\n"
|
||||
" -X/--request <command> Specific request command to use\n"
|
||||
" -y/--speed-time Time needed to trig speed-limit abort. Defaults to 30\n"
|
||||
" -X/--request <command> Specific request command to use");
|
||||
puts(" -y/--speed-time Time needed to trig speed-limit abort. Defaults to 30\n"
|
||||
" -Y/--speed-limit Stop transfer if below speed-limit for 'speed-time' secs\n"
|
||||
" -z/--time-cond <time> Includes a time condition to the server (H)\n"
|
||||
" -Z/--max-redirs <num> Set maximum number of redirections allowed (H)\n"
|
||||
" -2/--sslv2 Force usage of SSLv2 (H)\n"
|
||||
" -3/--sslv3 Force usage of SSLv3 (H)\n"
|
||||
" -#/--progress-bar Display transfer progress as a progress bar\n"
|
||||
" -3/--sslv3 Force usage of SSLv3 (H)");
|
||||
puts(" -#/--progress-bar Display transfer progress as a progress bar\n"
|
||||
" --crlf Convert LF to CRLF in upload. Useful for MVS (OS/390)\n"
|
||||
" --stderr <file> Where to redirect stderr. - means stdout.\n",
|
||||
curl_version()
|
||||
);
|
||||
" --stderr <file> Where to redirect stderr. - means stdout.\n"
|
||||
" --random-file <file> File to use for reading random data from (SSL)\n"
|
||||
" --egd-file <file> EGD socket path for random data (SSL)");
|
||||
}
|
||||
|
||||
struct LongShort {
|
||||
@@ -306,6 +305,8 @@ struct LongShort {
|
||||
};
|
||||
|
||||
struct Configurable {
|
||||
char *random_file;
|
||||
char *egd_file;
|
||||
char *useragent;
|
||||
char *cookie;
|
||||
bool use_resume;
|
||||
@@ -525,6 +526,8 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
{"7", "interface", TRUE},
|
||||
{"6", "krb4", TRUE},
|
||||
{"5", "url", TRUE},
|
||||
{"5a", "random-file", TRUE},
|
||||
{"5b", "egd-file", TRUE},
|
||||
|
||||
{"2", "sslv2", FALSE},
|
||||
{"3", "sslv3", FALSE},
|
||||
@@ -674,29 +677,37 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
GetStr(&config->krb4level, nextarg);
|
||||
break;
|
||||
case '5':
|
||||
/* the URL! */
|
||||
{
|
||||
struct getout *url;
|
||||
if(config->url_get || (config->url_get=config->url_list)) {
|
||||
/* there's a node here, if it already is filled-in continue to find
|
||||
an "empty" node */
|
||||
while(config->url_get && (config->url_get->flags&GETOUT_URL))
|
||||
config->url_get = config->url_get->next;
|
||||
}
|
||||
switch(subletter) {
|
||||
case 'a': /* random-file */
|
||||
GetStr(&config->random_file, nextarg);
|
||||
break;
|
||||
case 'b': /* egd-file */
|
||||
GetStr(&config->egd_file, nextarg);
|
||||
break;
|
||||
default: /* the URL! */
|
||||
{
|
||||
struct getout *url;
|
||||
if(config->url_get || (config->url_get=config->url_list)) {
|
||||
/* there's a node here, if it already is filled-in continue to find
|
||||
an "empty" node */
|
||||
while(config->url_get && (config->url_get->flags&GETOUT_URL))
|
||||
config->url_get = config->url_get->next;
|
||||
}
|
||||
|
||||
/* now there might or might not be an available node to fill in! */
|
||||
/* now there might or might not be an available node to fill in! */
|
||||
|
||||
if(config->url_get)
|
||||
/* existing node */
|
||||
url = config->url_get;
|
||||
else
|
||||
/* there was no free node, create one! */
|
||||
url=new_getout(config);
|
||||
|
||||
if(url) {
|
||||
/* fill in the URL */
|
||||
GetStr(&url->url, nextarg);
|
||||
url->flags |= GETOUT_URL;
|
||||
if(config->url_get)
|
||||
/* existing node */
|
||||
url = config->url_get;
|
||||
else
|
||||
/* there was no free node, create one! */
|
||||
url=new_getout(config);
|
||||
|
||||
if(url) {
|
||||
/* fill in the URL */
|
||||
GetStr(&url->url, nextarg);
|
||||
url->flags |= GETOUT_URL;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1368,6 +1379,10 @@ void progressbarinit(struct ProgressData *bar)
|
||||
|
||||
void free_config_fields(struct Configurable *config)
|
||||
{
|
||||
if(config->random_file)
|
||||
free(config->random_file);
|
||||
if(config->egd_file)
|
||||
free(config->egd_file);
|
||||
if(config->userpwd)
|
||||
free(config->userpwd);
|
||||
if(config->postfields)
|
||||
@@ -1441,12 +1456,10 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
curl_memdebug("memdump");
|
||||
#endif
|
||||
|
||||
main_init(); /* inits winsock crap for windows */
|
||||
|
||||
config->showerror=TRUE;
|
||||
config->conf=CONF_DEFAULT;
|
||||
#if 0
|
||||
config->crlf=FALSE;
|
||||
config->quote=NULL;
|
||||
#endif
|
||||
|
||||
if(argc>1 &&
|
||||
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
|
||||
@@ -1455,9 +1468,6 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
* The first flag, that is not a verbose name, but a shortname
|
||||
* and it includes the 'q' flag!
|
||||
*/
|
||||
#if 0
|
||||
fprintf(stderr, "I TURNED OFF THE CRAP\n");
|
||||
#endif
|
||||
;
|
||||
}
|
||||
else {
|
||||
@@ -1537,6 +1547,15 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
else
|
||||
allocuseragent = TRUE;
|
||||
|
||||
/*
|
||||
* Get a curl handle to use for all forthcoming curl transfers. Cleanup
|
||||
* when all transfers are done. This is supported with libcurl 7.7 and
|
||||
* should not be attempted on previous versions.
|
||||
*/
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
urlnode = config->url_list;
|
||||
|
||||
/* loop through the list of given URLs */
|
||||
@@ -1722,121 +1741,113 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
|
||||
main_init();
|
||||
curl_easy_setopt(curl, CURLOPT_FILE, (FILE *)&outs); /* where to store */
|
||||
/* what call to write: */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, infd); /* for uploads */
|
||||
/* size of uploaded file: */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url); /* what to fetch */
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, config->proxy); /* proxy to use */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, config->conf&CONF_VERBOSE);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, config->conf&CONF_HEADER);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, config->conf&CONF_NOPROGRESS);
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, config->conf&CONF_NOBODY);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR,
|
||||
config->conf&CONF_FAILONERROR);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, config->conf&CONF_UPLOAD);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPLISTONLY,
|
||||
config->conf&CONF_FTPLISTONLY);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);
|
||||
curl_easy_setopt(curl, CURLOPT_NETRC, config->conf&CONF_NETRC);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,
|
||||
config->conf&CONF_FOLLOWLOCATION);
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);
|
||||
curl_easy_setopt(curl, CURLOPT_MUTE, config->conf&CONF_MUTE);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, config->userpwd);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
||||
curl_easy_setopt(curl, CURLOPT_RANGE, config->range);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, config->timeout);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields);
|
||||
|
||||
/* new in libcurl 7.2: */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_REFERER, config->referer);
|
||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER,
|
||||
config->conf&CONF_AUTO_REFERER);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, config->useragent);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPPORT, config->ftpport);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, config->low_speed_limit);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, config->low_speed_time);
|
||||
curl_easy_setopt(curl, CURLOPT_RESUME_FROM,
|
||||
config->use_resume?config->resume_from:0);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIE, config->cookie);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, config->headers);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, config->cert_passwd);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_FILE, (FILE *)&outs); /* where to store */
|
||||
/* what call to write: */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, infd); /* for uploads */
|
||||
/* size of uploaded file: */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url); /* what to fetch */
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, config->proxy); /* proxy to use */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, config->conf&CONF_VERBOSE);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, config->conf&CONF_HEADER);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, config->conf&CONF_NOPROGRESS);
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, config->conf&CONF_NOBODY);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR,
|
||||
config->conf&CONF_FAILONERROR);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, config->conf&CONF_UPLOAD);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPLISTONLY,
|
||||
config->conf&CONF_FTPLISTONLY);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);
|
||||
curl_easy_setopt(curl, CURLOPT_NETRC, config->conf&CONF_NETRC);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,
|
||||
config->conf&CONF_FOLLOWLOCATION);
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);
|
||||
curl_easy_setopt(curl, CURLOPT_MUTE, config->conf&CONF_MUTE);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, config->userpwd);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
||||
curl_easy_setopt(curl, CURLOPT_RANGE, config->range);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, config->timeout);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, config->postfields);
|
||||
|
||||
/* new in libcurl 7.2: */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, config->postfieldsize);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_REFERER, config->referer);
|
||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER,
|
||||
config->conf&CONF_AUTO_REFERER);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, config->useragent);
|
||||
curl_easy_setopt(curl, CURLOPT_FTPPORT, config->ftpport);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, config->low_speed_limit);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, config->low_speed_time);
|
||||
curl_easy_setopt(curl, CURLOPT_RESUME_FROM,
|
||||
config->use_resume?config->resume_from:0);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIE, config->cookie);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, config->headers);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, config->cert_passwd);
|
||||
|
||||
if(config->cacert) {
|
||||
/* available from libcurl 7.5: */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, config->cacert);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
}
|
||||
|
||||
if(config->conf&(CONF_NOBODY|CONF_USEREMOTETIME)) {
|
||||
/* no body or use remote time */
|
||||
/* new in 7.5 */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, TRUE);
|
||||
}
|
||||
|
||||
/* 7.5 news: */
|
||||
if (config->maxredirs)
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);
|
||||
else
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, DEFAULT_MAXREDIRS);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_CRLF, config->crlf);
|
||||
curl_easy_setopt(curl, CURLOPT_QUOTE, config->quote);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, config->postquote);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER,
|
||||
config->headerfile?&heads:NULL);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, config->cookiefile);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLVERSION, config->ssl_version);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, config->timecond);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, config->condtime);
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
|
||||
curl_easy_setopt(curl, CURLOPT_STDERR, config->errors);
|
||||
|
||||
/* three new ones in libcurl 7.3: */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel);
|
||||
curl_easy_setopt(curl, CURLOPT_INTERFACE, config->iface);
|
||||
curl_easy_setopt(curl, CURLOPT_KRB4LEVEL, config->krb4level);
|
||||
|
||||
if((config->progressmode == CURL_PROGRESS_BAR) &&
|
||||
!(config->conf&(CONF_NOPROGRESS|CONF_MUTE))) {
|
||||
/* we want the alternative style, then we have to implement it
|
||||
ourselves! */
|
||||
progressbarinit(&progressbar);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, myprogress);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
|
||||
}
|
||||
|
||||
/* new in libcurl 7.6.2: */
|
||||
curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(config->writeout) {
|
||||
ourWriteOut(curl, config->writeout);
|
||||
}
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if((res!=CURLE_OK) && config->showerror)
|
||||
fprintf(config->errors, "curl: (%d) %s\n", res, errorbuffer);
|
||||
if(config->cacert) {
|
||||
/* available from libcurl 7.5: */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, config->cacert);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
|
||||
}
|
||||
else
|
||||
fprintf(config->errors, "curl: failed to init libcurl!\n");
|
||||
|
||||
if(config->conf&(CONF_NOBODY|CONF_USEREMOTETIME)) {
|
||||
/* no body or use remote time */
|
||||
/* new in 7.5 */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, TRUE);
|
||||
}
|
||||
|
||||
/* 7.5 news: */
|
||||
if (config->maxredirs)
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);
|
||||
else
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, DEFAULT_MAXREDIRS);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_CRLF, config->crlf);
|
||||
curl_easy_setopt(curl, CURLOPT_QUOTE, config->quote);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, config->postquote);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER,
|
||||
config->headerfile?&heads:NULL);
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, config->cookiefile);
|
||||
curl_easy_setopt(curl, CURLOPT_SSLVERSION, config->ssl_version);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, config->timecond);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, config->condtime);
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
|
||||
curl_easy_setopt(curl, CURLOPT_STDERR, config->errors);
|
||||
|
||||
/* three new ones in libcurl 7.3: */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel);
|
||||
curl_easy_setopt(curl, CURLOPT_INTERFACE, config->iface);
|
||||
curl_easy_setopt(curl, CURLOPT_KRB4LEVEL, config->krb4level);
|
||||
|
||||
if((config->progressmode == CURL_PROGRESS_BAR) &&
|
||||
!(config->conf&(CONF_NOPROGRESS|CONF_MUTE))) {
|
||||
/* we want the alternative style, then we have to implement it
|
||||
ourselves! */
|
||||
progressbarinit(&progressbar);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, myprogress);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
|
||||
}
|
||||
|
||||
/* new in libcurl 7.6.2: */
|
||||
curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
|
||||
|
||||
main_free();
|
||||
/* new in libcurl 7.7: */
|
||||
curl_easy_setopt(curl, CURLOPT_RANDOM_FILE, config->random_file);
|
||||
curl_easy_setopt(curl, CURLOPT_EGDSOCKET, config->egd_file);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(config->writeout) {
|
||||
ourWriteOut(curl, config->writeout);
|
||||
}
|
||||
|
||||
if((res!=CURLE_OK) && config->showerror)
|
||||
fprintf(config->errors, "curl: (%d) %s\n", res, errorbuffer);
|
||||
|
||||
if((config->errors != stderr) &&
|
||||
(config->errors != stdout))
|
||||
@@ -1884,6 +1895,11 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
if(allocuseragent)
|
||||
free(config->useragent);
|
||||
|
||||
/* cleanup the curl handle! */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
main_free(); /* cleanup the winsock stuff for windows */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -75,18 +75,18 @@ for(@out) {
|
||||
|
||||
$new = $_;
|
||||
|
||||
$outsize += length($new);
|
||||
$outsize += length($new)+1; # one for the newline
|
||||
|
||||
$new =~ s/\\/\\\\/g;
|
||||
$new =~ s/\"/\\\"/g;
|
||||
|
||||
printf("\"%s\\n\"\n", $new);
|
||||
|
||||
if($outsize > 10000) {
|
||||
# gcc 2.96 claims ISO C89 only is required to support 509 letter strings
|
||||
if($outsize > 500) {
|
||||
# terminate and make another puts() call here
|
||||
print ");\n puts(\n";
|
||||
$outsize=0;
|
||||
$outsize=length($new)+1;
|
||||
}
|
||||
printf("\"%s\\n\"\n", $new);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#define CURL_NAME "curl"
|
||||
#define CURL_VERSION "7.7-beta1"
|
||||
#define CURL_VERSION "7.7-beta3"
|
||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||
|
@@ -25,8 +25,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
|
||||
#include <curl/mprintf.h>
|
||||
|
@@ -18,8 +18,10 @@ Run:
|
||||
verbose output. Use -d to run the test servers with debug output enabled as
|
||||
well.
|
||||
|
||||
Use -s fort shorter output, or pass a string with test numbers to run
|
||||
specific tests only (like ./runtests.pl "3 4" to test 3 and 4 only)
|
||||
Use -s for shorter output, or pass test numbers to run specific tests only
|
||||
(like "./runtests.pl 3 4" to test 3 and 4 only). It also supports test case
|
||||
ranges with 'to'. As in "./runtests 3 to 9" which runs the seven tests from
|
||||
3 to 9.
|
||||
|
||||
Memory:
|
||||
The test script will check that all allocated memory is freed properly IF
|
||||
|
@@ -5,53 +5,53 @@ test:
|
||||
[ -f command1.txt ] || ln -s $(srcdir)/*.txt .
|
||||
|
||||
EXTRA_DIST = command1.txt error113.txt name17.txt prot8.txt \
|
||||
command10.txt error114.txt name18.txt prot9.txt \
|
||||
command100.txt error115.txt name19.txt reply1.txt \
|
||||
command101.txt error116.txt name2.txt reply10.txt \
|
||||
command102.txt error117.txt name20.txt reply100.txt \
|
||||
command103.txt error118.txt name200.txt reply101.txt \
|
||||
command104.txt error119.txt name201.txt reply102.txt \
|
||||
command105.txt error19.txt name21.txt reply103.txt \
|
||||
command106.txt error20.txt name22.txt reply104.txt \
|
||||
command107.txt error201.txt name23.txt reply105.txt \
|
||||
command108.txt error21.txt name24.txt reply106.txt \
|
||||
command109.txt error23.txt name25.txt reply11.txt \
|
||||
command11.txt error24.txt name3.txt reply110.txt \
|
||||
command110.txt error25.txt name4.txt reply110001.txt \
|
||||
command111.txt ftpd113.txt name5.txt reply110002.txt \
|
||||
command112.txt ftpd114.txt name6.txt reply12.txt \
|
||||
command113.txt ftpd115.txt name7.txt reply13.txt \
|
||||
command114.txt ftpd116.txt name8.txt reply14.txt \
|
||||
command115.txt ftpd117.txt name9.txt reply15.txt \
|
||||
command116.txt ftpd118.txt prot1.txt reply16.txt \
|
||||
command117.txt name1.txt prot10.txt reply17.txt \
|
||||
command118.txt name10.txt prot100.txt reply2.txt \
|
||||
command119.txt name100.txt prot101.txt reply200.txt \
|
||||
command12.txt name101.txt prot102.txt reply22.txt \
|
||||
command13.txt name102.txt prot103.txt reply24.txt \
|
||||
command14.txt name103.txt prot104.txt reply25.txt \
|
||||
command15.txt name104.txt prot105.txt reply3.txt \
|
||||
command16.txt name105.txt prot106.txt reply4.txt \
|
||||
command17.txt name106.txt prot107.txt reply5.txt \
|
||||
command18.txt name107.txt prot108.txt reply6.txt \
|
||||
command19.txt name108.txt prot109.txt reply7.txt \
|
||||
command2.txt name109.txt prot11.txt reply8.txt \
|
||||
command20.txt name11.txt prot110.txt reply9.txt \
|
||||
command200.txt name110.txt prot112.txt stdin17.txt \
|
||||
command201.txt name111.txt prot12.txt stdout107.txt \
|
||||
command21.txt name112.txt prot13.txt stdout108.txt \
|
||||
command22.txt name113.txt prot14.txt stdout109.txt \
|
||||
command23.txt name114.txt prot15.txt stdout110.txt \
|
||||
command24.txt name115.txt prot16.txt stdout112.txt \
|
||||
command25.txt name116.txt prot17.txt stdout15.txt \
|
||||
command3.txt name117.txt prot18.txt stdout18.txt \
|
||||
command4.txt name118.txt prot2.txt upload107.txt \
|
||||
command5.txt name119.txt prot22.txt upload108.txt \
|
||||
command6.txt name12.txt prot3.txt upload109.txt \
|
||||
command7.txt name13.txt prot4.txt upload112.txt \
|
||||
command8.txt name14.txt prot5.txt \
|
||||
command9.txt name15.txt prot6.txt \
|
||||
error111.txt name16.txt prot7.txt \
|
||||
command10.txt error114.txt name18.txt prot9.txt \
|
||||
command100.txt error115.txt name19.txt reply1.txt \
|
||||
command101.txt error116.txt name2.txt reply10.txt \
|
||||
command102.txt error117.txt name20.txt reply100.txt \
|
||||
command103.txt error118.txt name200.txt reply101.txt \
|
||||
command104.txt error119.txt name201.txt reply102.txt \
|
||||
command105.txt error19.txt name21.txt reply103.txt \
|
||||
command106.txt error20.txt name22.txt reply104.txt \
|
||||
command107.txt error201.txt name23.txt reply105.txt \
|
||||
command108.txt error21.txt name24.txt reply106.txt \
|
||||
command109.txt error23.txt name25.txt reply11.txt \
|
||||
command11.txt error24.txt name3.txt reply110.txt \
|
||||
command110.txt error25.txt name4.txt reply110001.txt \
|
||||
command111.txt ftpd113.txt name5.txt reply110002.txt \
|
||||
command112.txt ftpd114.txt name6.txt reply12.txt \
|
||||
command113.txt ftpd115.txt name7.txt reply13.txt \
|
||||
command114.txt ftpd116.txt name8.txt reply14.txt \
|
||||
command115.txt ftpd117.txt name9.txt reply15.txt \
|
||||
command116.txt ftpd118.txt prot1.txt reply16.txt \
|
||||
command117.txt name1.txt prot10.txt reply17.txt \
|
||||
command118.txt name10.txt prot100.txt reply2.txt \
|
||||
command119.txt name100.txt prot101.txt reply200.txt \
|
||||
command12.txt name101.txt prot102.txt reply22.txt \
|
||||
command13.txt name102.txt prot103.txt reply24.txt \
|
||||
command14.txt name103.txt prot104.txt reply25.txt \
|
||||
command15.txt name104.txt prot105.txt reply3.txt \
|
||||
command16.txt name105.txt prot106.txt reply4.txt \
|
||||
command17.txt name106.txt prot107.txt reply5.txt \
|
||||
command18.txt name107.txt prot108.txt reply6.txt \
|
||||
command19.txt name108.txt prot109.txt reply7.txt \
|
||||
command2.txt name109.txt prot11.txt reply8.txt \
|
||||
command20.txt name11.txt prot110.txt reply9.txt \
|
||||
command200.txt name110.txt prot112.txt stdin17.txt \
|
||||
command201.txt name111.txt prot12.txt stdout107.txt \
|
||||
command21.txt name112.txt prot13.txt stdout108.txt \
|
||||
command22.txt name113.txt prot14.txt stdout109.txt \
|
||||
command23.txt name114.txt prot15.txt stdout110.txt \
|
||||
command24.txt name115.txt prot16.txt stdout112.txt \
|
||||
command25.txt name116.txt prot17.txt stdout15.txt \
|
||||
command3.txt name117.txt prot18.txt stdout18.txt \
|
||||
command4.txt name118.txt prot2.txt upload107.txt \
|
||||
command5.txt name119.txt prot22.txt upload108.txt \
|
||||
command6.txt name12.txt prot3.txt upload109.txt \
|
||||
command7.txt name13.txt prot4.txt upload112.txt \
|
||||
command8.txt name14.txt prot5.txt \
|
||||
command9.txt name15.txt prot6.txt \
|
||||
error111.txt name16.txt prot7.txt \
|
||||
command26.txt prot26.txt command27.txt prot27.txt \
|
||||
name26.txt reply26.txt name27.txt stdout27.txt \
|
||||
command28.txt name28.txt prot28.txt reply28.txt \
|
||||
@@ -64,4 +64,6 @@ command32.txt prot31.txt reply310001.txt reply320001.txt \
|
||||
name31.txt prot32.txt reply310002.txt reply320002.txt \
|
||||
command33.txt extra33.txt name33.txt prot33.txt reply33.txt \
|
||||
command34.txt prot34.txt reply340001.txt name34.txt reply34.txt \
|
||||
command35.txt name35.txt prot35.txt reply35.txt
|
||||
command35.txt name35.txt prot35.txt reply35.txt \
|
||||
command36.txt error36.txt name36.txt reply36.txt \
|
||||
command37.txt name37.txt prot37.txt reply37.txt
|
||||
|
@@ -1,4 +1,4 @@
|
||||
http://%HOSTIP:%HOSTPORT/want/25 -o - -o -
|
||||
http://%HOSTIP:%HOSTPORT/want/26 -o - -o -
|
||||
|
||||
|
||||
|
||||
|
1
tests/data/command36.txt
Normal file
1
tests/data/command36.txt
Normal file
@@ -0,0 +1 @@
|
||||
http://%HOSTIP:%HOSTPORT/36
|
1
tests/data/command37.txt
Normal file
1
tests/data/command37.txt
Normal file
@@ -0,0 +1 @@
|
||||
http://uUsSeErrr:pppasswrd@%HOSTIP:%HOSTPORT/37
|
1
tests/data/error36.txt
Normal file
1
tests/data/error36.txt
Normal file
@@ -0,0 +1 @@
|
||||
26
|
@@ -1 +1 @@
|
||||
looping HTTP Location: following with --max-redirs
|
||||
looping HTTP Location: following with --max-redirs, no persistance
|
||||
|
1
tests/data/name36.txt
Normal file
1
tests/data/name36.txt
Normal file
@@ -0,0 +1 @@
|
||||
HTTP GET with badly formatted chunked Transfer-Encoding
|
1
tests/data/name37.txt
Normal file
1
tests/data/name37.txt
Normal file
@@ -0,0 +1 @@
|
||||
HTTP GET with name+password in the URL
|
@@ -1,4 +1,4 @@
|
||||
GET /want/25 HTTP/1.1
|
||||
GET /want/26 HTTP/1.1
|
||||
User-Agent: curl/7.6-pre1 (sparc-sun-solaris2.7) libcurl 7.5.2 (SSL 0.9.6) (krb4 enabled)
|
||||
Host: 127.0.0.1:8999
|
||||
Pragma: no-cache
|
||||
|
7
tests/data/prot37.txt
Normal file
7
tests/data/prot37.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
GET /37 HTTP/1.1
|
||||
Authorization: Basic dVVzU2VFcnJyOnBwcGFzc3dyZA==
|
||||
User-Agent: curl/7.7-beta1 (i686-pc-linux-gnu) libcurl 7.7-beta1 (SSL 0.9.5)
|
||||
Host: 127.0.0.1:8999
|
||||
Pragma: no-cache
|
||||
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
HTTP/1.1 200 OK
|
||||
HTTP/1.0 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
HTTP/1.1 404 BAD BOY
|
||||
HTTP/1.0 404 BAD BOY
|
||||
Content-Type: text/html
|
||||
|
||||
This silly page doesn't reaaaaaly exist so you should not get it.
|
||||
|
@@ -1,5 +1,7 @@
|
||||
HTTP/1.1 301 This is a weirdo text message
|
||||
Server: test-server/fake
|
||||
Location: data/reply/25
|
||||
Content-Length: 32
|
||||
Connection: close
|
||||
|
||||
Redirect to the same URL again!
|
||||
|
@@ -1,5 +1,6 @@
|
||||
HTTP/1.1 301 This is a weirdo text message
|
||||
Server: test-server/fake
|
||||
Location: data/reply/25
|
||||
Connection: close
|
||||
|
||||
Redirect to the same URL again!
|
||||
|
@@ -1,4 +1,4 @@
|
||||
HTTP/1.1 200 OK
|
||||
HTTP/1.0 200 OK
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
@@ -1,6 +1,7 @@
|
||||
HTTP/1.1 301 Moved Permanently
|
||||
Server: fake
|
||||
Location: /moo/moo/moo/310002
|
||||
Connection: close
|
||||
|
||||
No contents
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
HTTP/1.1 301 Moved Permanently
|
||||
Server: fake
|
||||
Location: /moo/moo/moo/310002
|
||||
Connection: close
|
||||
|
||||
HTTP/1.1 200 Followed here fine
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
|
@@ -1,6 +1,7 @@
|
||||
HTTP/1.1 303 See Other
|
||||
Server: fake
|
||||
Location: /moo/moo/moo/320002
|
||||
Connection: close
|
||||
|
||||
This Location should be fetched with a GET!
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
HTTP/1.1 303 See Other
|
||||
Server: fake
|
||||
Location: /moo/moo/moo/320002
|
||||
Connection: close
|
||||
|
||||
HTTP/1.1 200 Followed here fine
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
|
@@ -4,10 +4,10 @@ Transfer-Encoding: chunked
|
||||
Connection: mooo
|
||||
|
||||
40
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
30
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
20;heresatest=moooo
|
||||
ccccccccccccccccccccccccccccccc
|
||||
cccccccccccccccccccccccccccccccc
|
||||
0
|
||||
muuu
|
||||
muuu
|
||||
|
@@ -3,6 +3,4 @@ Server: fakeit/1.0
|
||||
Transfer-Encoding: chunked
|
||||
Connection: mooo
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
ccccccccccccccccccccccccccccccc
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccc
|
8
tests/data/reply36.txt
Normal file
8
tests/data/reply36.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
HTTP/1.1 200 funky chunky!
|
||||
Server: fakeit/1.0
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
40
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
ILLEGAL
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
3
tests/data/reply37.txt
Normal file
3
tests/data/reply37.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
HTTP/1.0 200 OK
|
||||
|
||||
no headers!
|
@@ -1,5 +1,5 @@
|
||||
--_curl_--127.0.0.1:8999/3
|
||||
HTTP/1.1 200 OK
|
||||
HTTP/1.0 200 OK
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
@@ -8,7 +8,7 @@ this is data even though Content-Length is set to zero
|
||||
|
||||
|
||||
--_curl_--127.0.0.1:8999/10
|
||||
HTTP/1.1 200 OK
|
||||
HTTP/1.0 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
|
||||
|
@@ -1,9 +1,11 @@
|
||||
HTTP/1.1 301 This is a weirdo text message
|
||||
Server: test-server/fake
|
||||
Location: data/reply/25
|
||||
Content-Length: 32
|
||||
Connection: close
|
||||
|
||||
Redirect to the same URL again!
|
||||
HTTP/1.1 404 BAD BOY
|
||||
HTTP/1.0 404 BAD BOY
|
||||
Content-Type: text/html
|
||||
|
||||
This silly page doesn't reaaaaaly exist so you should not get it.
|
||||
|
@@ -63,6 +63,8 @@ for ( $waitedpid = 0;
|
||||
my ($request, $path, $ver, $left, $cl);
|
||||
|
||||
my @headers;
|
||||
|
||||
stdin:
|
||||
while(<STDIN>) {
|
||||
if($_ =~ /([A-Z]*) (.*) HTTP\/1.(\d)/) {
|
||||
$request=$1;
|
||||
@@ -135,13 +137,16 @@ for ( $waitedpid = 0;
|
||||
print "HTTP/1.1 200 OK\r\n",
|
||||
"header: yes\r\n",
|
||||
"\r\n",
|
||||
"You must select a test number to get good data back\r\n";
|
||||
"You must enter a test number to get good data back\r\n";
|
||||
}
|
||||
else {
|
||||
# send a custom reply to the client
|
||||
open(DATA, "<data/reply$testnum.txt");
|
||||
while(<DATA>) {
|
||||
print $_;
|
||||
if($verbose) {
|
||||
print STDERR "OUT: $_";
|
||||
}
|
||||
}
|
||||
close(DATA);
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ sub singletest {
|
||||
if(! -r $CURLCMD) {
|
||||
# this is not a test
|
||||
print "$NUMBER doesn't look like a test case!\n";
|
||||
next;
|
||||
return -1;
|
||||
}
|
||||
|
||||
# remove previous server output logfile
|
||||
@@ -567,6 +567,8 @@ sub singletest {
|
||||
# Check options to this test program
|
||||
#
|
||||
|
||||
my $number=0;
|
||||
my $fromnum=-1;
|
||||
my @testthis;
|
||||
do {
|
||||
if ($ARGV[0] eq "-v") {
|
||||
@@ -605,7 +607,19 @@ EOHELP
|
||||
exit;
|
||||
}
|
||||
elsif($ARGV[0] =~ /^(\d+)/) {
|
||||
push @testthis, $1;
|
||||
$number = $1;
|
||||
if($fromnum >= 0) {
|
||||
for($fromnum .. $number) {
|
||||
push @testthis, $_;
|
||||
}
|
||||
$fromnum = -1;
|
||||
}
|
||||
else {
|
||||
push @testthis, $1;
|
||||
}
|
||||
}
|
||||
elsif($ARGV[0] =~ /^to$/i) {
|
||||
$fromnum = $number+1;
|
||||
}
|
||||
} while(shift @ARGV);
|
||||
|
||||
@@ -665,17 +679,24 @@ open(CMDLOG, ">$CURLLOG") ||
|
||||
# The main test-loop
|
||||
#
|
||||
|
||||
my $failed;
|
||||
my $testnum;
|
||||
my $ok=0;
|
||||
my $total=0;
|
||||
foreach $testnum (split(" ", $TESTCASES)) {
|
||||
|
||||
$total++;
|
||||
my $error = singletest($testnum);
|
||||
if($error && !$anyway) {
|
||||
# a test failed, abort
|
||||
print "\n - abort tests\n";
|
||||
last;
|
||||
if(-1 != $error) {
|
||||
# valid test case number
|
||||
$total++;
|
||||
}
|
||||
if($error>0) {
|
||||
if(!$anyway) {
|
||||
# a test failed, abort
|
||||
print "\n - abort tests\n";
|
||||
last;
|
||||
}
|
||||
$failed.= "$testnum ";
|
||||
}
|
||||
elsif(!$error) {
|
||||
$ok++;
|
||||
@@ -696,4 +717,13 @@ close(CMDLOG);
|
||||
stopserver($FTPPIDFILE);
|
||||
stopserver($PIDFILE);
|
||||
|
||||
print "$ok tests out of $total reported OK\n";
|
||||
if($total) {
|
||||
print "$ok tests out of $total reported OK\n";
|
||||
|
||||
if($ok != $total) {
|
||||
print "These test cases failed: $failed\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "No tests were performed!\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user