Compare commits

..

151 Commits

Author SHA1 Message Date
Daniel Stenberg
bf9b9ca29d 7.10.3 commit 2003-01-14 12:42:26 +00:00
Daniel Stenberg
64f224bb22 more 2003-01-13 12:08:39 +00:00
Daniel Stenberg
285a8fe4d0 there is SOCKS support these days 2003-01-13 06:35:31 +00:00
Daniel Stenberg
3773d76dfd Steve Oliphant pointed out that test case 105 did not work anymore and this
was due to a missing fix for the password prompting
2003-01-10 16:19:32 +00:00
Daniel Stenberg
94c5c7bd6d added test 136 2003-01-09 16:48:51 +00:00
Daniel Stenberg
12cfc4c0b0 verify -u username: with ftp to use a blank password 2003-01-09 16:47:55 +00:00
Daniel Stenberg
9a2de6e6ee if userpwd is "username:", this now implies a blank password while only
"username" will cause libcurl to prompt for password. Bryan Kemp noticed.

test case 136 is added for this
2003-01-09 16:47:09 +00:00
Daniel Stenberg
2ede47b8c8 Wai (Simon) Liu provided the HTTP200ALIASES paragraph. 2003-01-09 15:04:55 +00:00
Daniel Stenberg
76e107506f Philippe Raoult's added note for HTTPHEADER 2003-01-09 14:58:54 +00:00
Daniel Stenberg
6f35ed51dc This fixed yet another connect problem with the multi interface and ipv4
stack. Kjetil Jacobsen reported and verified the fix.
2003-01-09 14:52:51 +00:00
Daniel Stenberg
c94ba66310 removed 2003-01-09 11:57:50 +00:00
Daniel Stenberg
a15133f5cf removed unused code 2003-01-09 11:50:34 +00:00
Daniel Stenberg
cc09e9d4c2 fix 2003-01-09 11:43:08 +00:00
Daniel Stenberg
16e0da2c4b call curl_multi_perform() correctly 2003-01-09 11:42:07 +00:00
Daniel Stenberg
ed22f75241 proper indent 2003-01-09 11:31:49 +00:00
Daniel Stenberg
ba25cad6e2 pass a file name to memanalyze to read from instead of using stdin 2003-01-09 11:26:57 +00:00
Daniel Stenberg
abb01123cb share.h is now a used header file 2003-01-09 11:19:51 +00:00
Daniel Stenberg
e2d249f8c5 fixed to deal with file names that contain colons, as in Windows 2003-01-09 11:03:02 +00:00
Daniel Stenberg
4a2ac166fa 7.10.3-pre4 2003-01-09 10:36:24 +00:00
Daniel Stenberg
5fab55383d rename the curl share error enum prefix 2003-01-09 10:26:29 +00:00
Daniel Stenberg
f152f23a68 Updated more and now looks and and the API possibly works almost like the
design document specifies. There is still no code inside that uses this.
2003-01-09 10:21:03 +00:00
Daniel Stenberg
24e78b3571 7+8 jan 2003 2003-01-09 09:53:08 +00:00
Daniel Stenberg
9a239edb52 updated to use the modified share-types 2003-01-08 15:50:52 +00:00
Daniel Stenberg
abcc5c5a82 cleaned up the share data types and prototypes to be more in line what
the design draft mentioned and what I think is fit
2003-01-08 15:50:06 +00:00
Daniel Stenberg
cb5ba675a7 mkdir() fix for win32 2003-01-08 15:04:42 +00:00
Daniel Stenberg
2288086695 nah, include test.h instead 2003-01-08 09:37:35 +00:00
Daniel Stenberg
61421b7a8f include curl.h without directory 2003-01-08 09:33:19 +00:00
Jean-Philippe Barette-LaPierre
6a7e53a7c7 fixed a very, very rare and very, very little memory leak 2003-01-08 02:27:47 +00:00
Daniel Stenberg
ca134d5522 Philippe Raoult's fix to handle wildcard certificate name checks 2003-01-07 16:33:11 +00:00
Daniel Stenberg
ec24efda74 Simon Liu's HTTP200ALIASES-patch! 2003-01-07 16:15:53 +00:00
Daniel Stenberg
7f0f10e498 stuff 2003-01-07 15:40:01 +00:00
Daniel Stenberg
aa5af100b4 clarified error code 19 2003-01-07 15:39:38 +00:00
Daniel Stenberg
37ae32f688 Only output valid filetime.
Return file-error if 550 is returned when trying MDTM
2003-01-07 11:25:44 +00:00
Daniel Stenberg
d0cffdec5d when sending an error message to the debugfunction, we append a newline so
that the output looks better
2003-01-07 11:23:52 +00:00
Daniel Stenberg
0f34521612 fixed the create_dir_hierarchy() to not use uninited memory, as noticed by
Matthew Blain.
2003-01-07 09:35:57 +00:00
Daniel Stenberg
e69362df22 Matthew Blain's improvements for debug builds 2003-01-07 09:31:45 +00:00
Daniel Stenberg
3de8f6f38e better ignore 2003-01-07 09:30:05 +00:00
Daniel Stenberg
5359bc8083 ignore lib504 too 2003-01-07 09:27:32 +00:00
Daniel Stenberg
eb6a14fe10 updated 2003-01-07 07:54:14 +00:00
Daniel Stenberg
2912537533 indent fix 2003-01-06 12:41:33 +00:00
Sterling Hughes
cfb32da198 fix bug (?) :-)
previously, if you called curl_easy_perform and then set the global dns
cache, the global cache wouldn't be used.  I don't see this really happening
in practice, but this code allows you to do it.
2003-01-06 06:17:15 +00:00
Daniel Stenberg
9b4f92130f return -1 even if SSL_pending() doesn't return non-zero, as we don't really
care how many bytes that is readable NOW. Philippe Raoult reported the
bug in 7.10.3-pre3.
2002-12-29 16:27:31 +00:00
Daniel Stenberg
5a2ab686a6 Marc Herbert's suggstion: mention that insecure is ignored if cacert or capath
is used.
2002-12-29 16:23:52 +00:00
Daniel Stenberg
3b8583b014 example configure command line 2002-12-20 16:00:56 +00:00
Daniel Stenberg
ed29552b1e Use AM_MAINTAINER_MODE which thus makes less maintainer stuff in the default
makefile when --enable-maintainer-mode is not used.
2002-12-20 15:54:24 +00:00
Daniel Stenberg
a2ada3cf96 7.10.3-commit 2002-12-20 09:03:38 +00:00
Daniel Stenberg
88825a1187 fixes 2002-12-19 16:37:07 +00:00
Daniel Stenberg
264e7fc58b removed fruitless attempts to overload some targets 2002-12-19 16:36:35 +00:00
Daniel Stenberg
1698015e3c Curl_base64_decode() fixed by Matthew B 2002-12-19 16:02:51 +00:00
Daniel Stenberg
39dc14c002 Fixed the usage of SSL_read() to properly return -1 if the EWOULDBLOCK
situation occurs, which it previously didn't!

This was reptoed by Evan Jordan in bug report #653022.

Also, if ERROR_SYSCALL is returned from SSL_write(), include the errno number
in the error string for easier error detection.
2002-12-19 15:45:15 +00:00
Daniel Stenberg
04c499a5fc CURLOPT_DNS_USE_GLOBAL_CACHE is not thread-safe 2002-12-19 15:22:36 +00:00
Daniel Stenberg
efbe930a69 CURLE_HTTP_NOT_FOUND => CURLE_HTTP_RETURNED_ERROR 2002-12-18 16:51:02 +00:00
Daniel Stenberg
747f87f61e Removed weird special multi interface condition that caused bug report
#651464.
2002-12-17 10:05:00 +00:00
Daniel Stenberg
5a4c56fc44 don't install the test programs 2002-12-17 09:40:13 +00:00
Daniel Stenberg
81f45ba92a writefunction data is not zero terminated 2002-12-16 17:33:21 +00:00
Daniel Stenberg
a5dc4e32f2 removed junk 2002-12-16 15:32:37 +00:00
Daniel Stenberg
2b839853ec Added test case 504, using multi interface and a local proxy without anything
listening on the port we use.
2002-12-16 15:30:10 +00:00
Daniel Stenberg
66b6cd68ed better desc 2002-12-16 15:05:31 +00:00
Daniel Stenberg
0ef3d90838 mistake, this only requires http 2002-12-16 14:50:10 +00:00
Daniel Stenberg
5cc50f9b27 the hostip.c commit 2002-12-16 11:40:57 +00:00
Daniel Stenberg
e879e26a5b EAGAIN on older (correct) glibc versions indicate a problem and not the need
for a bigger buffer and this is indeed badness for us. Making this work
on both old and new glibc versions require an ugly loop that in its worse
form cause 45 bad loops when using the correct glibc and a non-resolving
host name... :-/

We want a better fix. Badly.
2002-12-16 11:33:44 +00:00
Daniel Stenberg
96d84150e1 changes from last week 2002-12-16 10:55:18 +00:00
Daniel Stenberg
2aa0c6c488 cut off -O properly when building for debug
setup the Makefile in tests/libtest/
2002-12-16 10:31:25 +00:00
Daniel Stenberg
811138386f documented the %-variables 2002-12-13 16:25:39 +00:00
Daniel Stenberg
c433cf7459 fixed another space issue 2002-12-13 16:24:57 +00:00
Daniel Stenberg
e0d6ebc2f2 please mr CVS ignore these 2002-12-13 16:24:04 +00:00
Daniel Stenberg
4938991ab8 set up arg2 to point to argv[2] to be used at will by programs 2002-12-13 16:22:57 +00:00
Daniel Stenberg
13722f536e added 503 2002-12-13 16:22:17 +00:00
Daniel Stenberg
57f0e3292d used this to verify bug report 651460 2002-12-13 16:21:18 +00:00
Daniel Stenberg
da5ae565ab added support for CONNECT, both good and bad 2002-12-13 16:20:07 +00:00
Daniel Stenberg
87c5066242 test case 503 entered the dir 2002-12-13 16:17:27 +00:00
Daniel Stenberg
b528bde470 conn->bits.tcpconnect now keeps track of if this connection is connected
or not
2002-12-13 16:15:19 +00:00
Daniel Stenberg
57572e550f include files without the curl/ to reduce the risk of us including the wrong
set of include files during tests
2002-12-13 14:14:35 +00:00
Daniel Stenberg
3aea0d3d68 Evan Jordan's fix for a memory leak. Bug report 650989. 2002-12-13 14:08:49 +00:00
Daniel Stenberg
9ae920c1b6 make a little work-around for file:// in _is_connected() and voila, now the
multi interface works with file:// URLs fine (previously it crashed). This
won't make it work on Windows though...
2002-12-13 13:47:58 +00:00
Daniel Stenberg
dff406a360 one slash too many 2002-12-13 13:41:28 +00:00
Daniel Stenberg
d346ba5c3c lib502.c for multi interface tests on a single URL without select() 2002-12-13 13:40:25 +00:00
Daniel Stenberg
978541adc2 test 502, multi interface with file:// 2002-12-13 13:39:39 +00:00
Daniel Stenberg
637bce2707 bail out on crap received, makes test case 402 *NOT* ruin the test series
anymore!
2002-12-12 18:07:10 +00:00
Daniel Stenberg
07e3dc2ee2 missing space added, nows run old tests fine again 2002-12-12 16:46:45 +00:00
Daniel Stenberg
ead065d803 remove test piece 2002-12-12 13:44:26 +00:00
Daniel Stenberg
0150bff7b4 make ftps and https invoke both necessary servers 2002-12-12 13:42:21 +00:00
Daniel Stenberg
0f493b6038 fixes 2002-12-12 13:40:16 +00:00
Daniel Stenberg
f26b709c50 link the test tools this way instead 2002-12-12 13:39:02 +00:00
Daniel Stenberg
ae10d9cf22 no more 2002-12-12 13:36:50 +00:00
Daniel Stenberg
81af9674ed corrected 2002-12-12 12:49:29 +00:00
Daniel Stenberg
b63df7991a new subdir added 'libtest' 2002-12-12 12:20:33 +00:00
Daniel Stenberg
a79990465c supports the new 'tool' and 'server' tags 2002-12-12 12:20:06 +00:00
Daniel Stenberg
ad6bd530ac describe the new sections added for (better) libcurl testing 2002-12-12 12:15:02 +00:00
Daniel Stenberg
c1b369fd4c 500 + 501 added 2002-12-12 12:13:18 +00:00
Daniel Stenberg
01fcd3c2d5 run tiny specific libcurl-testing tools 2002-12-12 12:12:01 +00:00
Daniel Stenberg
7196d784d3 The first ever attempts to do pure libcurl test cases 2002-12-12 12:11:16 +00:00
Daniel Stenberg
0f0aaf51e0 Deal with HTML where ' is used instead of "
Cut off name from option
2002-12-12 11:43:59 +00:00
Daniel Stenberg
b5f493c55a moved the includes to outside the extern "C" stuff
decreased the write buffer size to 16KB to perform a lot better on Windows(!)
2002-12-11 11:42:40 +00:00
Daniel Stenberg
0aa031beb9 recent fluff 2002-12-10 13:11:24 +00:00
Daniel Stenberg
db6ff224f8 The initial HTTP request can now be sent in multiple parts, as part of the
regular transfer process. This required some new tweaks, like for example
we need to be able to tell the tranfer loop to not chunky-encode uploads
while we're transferring the rest of the request...
2002-12-10 13:10:00 +00:00
Daniel Stenberg
b3c7cd61f3 send_buffer is no more here 2002-12-10 13:08:22 +00:00
Daniel Stenberg
9ae05c4d91 added test56, nearly 100KB big! 2002-12-10 13:01:05 +00:00
Daniel Stenberg
264e6f6efd Test case for sending insanely big HTTP requests. Mainly done this way to
make sure that it isn't all sent off in one single send() but instead
really tests the multiple-part-send logic.
2002-12-10 13:00:32 +00:00
Daniel Stenberg
ec7bccf671 more logging, now logs the full response too, basic support for dealing
with chunked transfer-encoding uploads added
2002-12-10 12:59:16 +00:00
Daniel Stenberg
49f75ee8ce A normal POST now provides data to the main transfer loop via the usual
read callback, and thus won't put a lot of stress on the request sending
code (which currently does an ugly loop).
2002-12-09 16:05:57 +00:00
Daniel Stenberg
4bcc866c52 The fread() callback pointer and associated pointer is now stored in the
connectdata struct instead, and is no longer modified within the 'set' struct
as previously (which was a really BAAAD thing).
2002-12-09 15:37:54 +00:00
Daniel Stenberg
c65e088caf Added a default headers section and also made some minor details more
up-to-date with recent changes.
2002-12-09 14:39:01 +00:00
Daniel Stenberg
6ca4116555 better errno include and no extern 2002-12-05 19:39:17 +00:00
Daniel Stenberg
f6cdb820af read and write as much as possible until end of data or EWOULDBLOCK before
returning back to the select() loop. Consider this a test so far.
2002-12-05 14:26:30 +00:00
Daniel Stenberg
081e5a82ff deal with spaces in name and value tags a lot better! 2002-12-05 12:54:08 +00:00
Daniel Stenberg
2ad2a4bd9f changed proto for Curl_krb_kauth() 2002-12-05 11:26:20 +00:00
Daniel Stenberg
645e700da3 Solaris needs errno as an extern int. 2002-12-05 11:25:36 +00:00
Daniel Stenberg
92aea29a30 make WIN32 defined for Borland properly, as told by Alexander J. Oss 2002-12-04 11:06:17 +00:00
Daniel Stenberg
e1c01af929 called SSLCERTS now 2002-12-04 09:53:09 +00:00
Daniel Stenberg
7ef749497d 7.10.3-pre2 2002-12-04 09:09:26 +00:00
Daniel Stenberg
d72aa49126 The waiting for the 226 or 250 line expected to come after a transfer is
complete is now only made for 60 seconds and if no data was received during
those 60 seconds, we store a special error message (preparing to make this
a special error code) as this most likely means that the control connection
has died while we were transferring data.
2002-12-04 08:56:55 +00:00
Daniel Stenberg
e92bd312ec missing } 2002-12-03 12:41:10 +00:00
Daniel Stenberg
b097c2cfb0 clarified 2002-12-03 12:40:12 +00:00
Daniel Stenberg
a39cdc80b7 Jeff pointed out this flaw in the example 2002-12-03 12:34:43 +00:00
Daniel Stenberg
a47250810e -@ is no longer an official shortcut for --create-dirs 2002-12-03 11:13:12 +00:00
Daniel Stenberg
1f50f3031f don't officially use -@ for --create-dirs, only use the long form 2002-12-03 11:12:18 +00:00
Daniel Stenberg
75145dd753 clarify the DEBUGFUNCTION data not being zero terminated 2002-12-03 10:37:20 +00:00
Daniel Stenberg
d0b97f7e1f Curl_GetFTPResponse() takes a different set of parameters and now return a
proper CURLcode. The default timeout for reading one response is now also
possible to change while running.
2002-12-03 10:25:31 +00:00
Daniel Stenberg
199a0311e2 updated to reality 2002-12-03 09:32:57 +00:00
Daniel Stenberg
fa446f860f Nicolas Berloquin's fix of his previous dir creation patch 2002-12-03 08:07:52 +00:00
Daniel Stenberg
7a74303f3c Nicolas Berloquin's description of his -@/--create-dirs fix 2002-12-02 14:40:54 +00:00
Daniel Stenberg
7d9eabb981 Nicolas Berloquin's added code for dealing with -@/--create-dirs to create
the necessary directories as specified with -o.
2002-12-02 14:37:59 +00:00
Daniel Stenberg
ff5308a5af if the PWD reply parser failed, we leaked memory 2002-12-02 07:18:24 +00:00
Daniel Stenberg
3f8ba3a986 clarified SSL_VERIFYPEER and SSL_VERIFYHOST a bit, thanks to Soren Spies 2002-12-02 06:47:16 +00:00
Daniel Stenberg
4a555de1b2 wrapped the line for PRIVATE nicer 2002-12-01 11:23:06 +00:00
Daniel Stenberg
d27e4a08f9 more to ignore 2002-12-01 11:21:36 +00:00
Daniel Stenberg
bf678a1ca9 only use Content-Length: header if not transfering data chunked 2002-12-01 11:20:41 +00:00
Daniel Stenberg
13a903de28 mention CVS-INFO for more info when checked out from CVS
removed old section about problems with old autoconfs, I don't think that
happens anymore
2002-11-30 16:00:10 +00:00
Daniel Stenberg
a3c14c031e stuff done since the 7.10.2 release 2002-11-29 08:29:21 +00:00
Daniel Stenberg
e90d528026 let the Curl_FormReader() return 0 when it reaches end of data to that the
chunked transfer work
2002-11-29 08:12:20 +00:00
Daniel Stenberg
d64dd77993 fix the hash init to call the correct dns cleanup function 2002-11-28 15:48:54 +00:00
Daniel Stenberg
113850a748 added compareheader proto 2002-11-28 15:48:23 +00:00
Daniel Stenberg
1c49a00d64 compareheader() was moved over to http.c and got a Curl_ prefix
The chunked transfer upload never stopped due to a silly add before we checked
for >0!
2002-11-28 15:46:22 +00:00
Daniel Stenberg
eef6c83503 Moved the compareheader function into this file and added Curl_ prefix
We now check if the chunked transfer-encoding header has been added "by force"
and if so, we enabled the chunky upload!
2002-11-28 15:45:06 +00:00
Daniel Stenberg
ceb5648eb7 mention how to generate patches 2002-11-28 14:07:14 +00:00
Daniel Stenberg
a0eadb76ea bad use of AM_CONDITIONAL removed and now configure runs better when used
with --disable-ipv6 --without-zlib
2002-11-28 13:29:42 +00:00
Daniel Stenberg
065852e46c execve.net is an official download mirror in HK 2002-11-27 11:59:52 +00:00
Daniel Stenberg
e5e2fb8274 Dan Becker fixed a minor memory leak on persistent connnections using
FOLLOWLOCATION and CURLOPT_USERPWD.
2002-11-26 17:32:15 +00:00
Daniel Stenberg
0210b3c893 removed extra space from trace output 'Send data' 2002-11-26 17:13:30 +00:00
Daniel Stenberg
7df5677b46 fixed Curl_freeaddrinfo() to only free addrinfo, and added Curl_freednsinfo()
for freeing single dns cache entries
2002-11-26 09:41:54 +00:00
sm
2e71876b28 Removed MFC dependency in Release Build when using VC++ IDE 2002-11-26 02:12:27 +00:00
Daniel Stenberg
11576b1142 Nedelcho Stanev's work-around for SFU 3.0 2002-11-24 19:30:21 +00:00
Daniel Stenberg
ce011b8a2d bug fix for the problem Juan Ignacio Hervs discovered today 2002-11-22 16:59:40 +00:00
Daniel Stenberg
12cfb4f7ee this fix seems to make the '305 306' test case combination to run ok finally! 2002-11-22 13:48:24 +00:00
Daniel Stenberg
9e1123debe don't use curl.haxx.se 2002-11-22 07:39:15 +00:00
Daniel Stenberg
c7354142c0 dead code removal 2002-11-21 15:11:26 +00:00
Daniel Stenberg
dee84f448f new name, supports <textarea> and the <option> tags within <select> better 2002-11-21 15:09:04 +00:00
Daniel Stenberg
1607711603 4.12 Why do I get "certificate verify failed" ? 2002-11-20 19:17:43 +00:00
Daniel Stenberg
8bca5e05b8 Kjetil Jacobsen's patch that introduces CURLOPT_PRIVATE and CURLINFO_PRIVATE
for storage and retrieval of private data in the curl handle.
2002-11-20 19:11:22 +00:00
Daniel Stenberg
f68505ee23 Karol Pietrzak pointed out that simply including the include dir in --cflags
is not a good thing, as recent gccs for example complain if it is /usr/include

Right now, we just output "" until we think of something better.
2002-11-20 19:04:34 +00:00
87 changed files with 3430 additions and 2398 deletions

244
CHANGES
View File

@@ -7,6 +7,250 @@
Changelog
Version 7.10.3 (14 Jan 2003)
Daniel (10 Jan 2003)
- Steve Oliphant pointed out that test case 105 did not work anymore and this
was due to a missing fix for the password prompting.
Version 7.10.3-pre6 (10 Jan 2003)
Daniel (9 Jan 2003)
- Bryan Kemp pointed out that curl -u could not provide a blank password
without prompting the user. It can now. -u username: makes the password
empty, while -u username makes curl prompt the user for a password.
- Kjetil Jacobsen found a remaining connect problem in the multi interface on
ipv4 systems (Linux only?), that I fixed and Kjetil verified that it fixed
his problems.
- memanalyze.pl now reads a file name from the command line, and no longer
takes the data on stdin as before.
Version 7.10.3-pre5 (9 Jan 2003)
Daniel (9 Jan 2003)
- Fixed tests/memanalyze.pl to work with file names that contain colons (as on
Windows).
- Kjetil Jacobsen quickly pointed out that lib/share.h was missing...
Version 7.10.3-pre4 (9 Jan 2003)
Daniel (9 Jan 2003)
- Updated lib/share.c quite a bit to match the design document at
http://curl.haxx.se/dev/sharing.txt a lot more.
I'll try to update the document soonish. share.c is still not actually used
by libcurl, but the API is slowly getting there and we can start
implementing code that takes advantage of this system.
Daniel (8 Jan 2003)
- Updated share stuff in curl/curl.h, including data types, structs and
function prototypes. The corresponding files in lib/ were also modified
of course to remain compilable. Based on input from Jean-Philippe and also
to make it more in line with the design document.
- Jean-Philippe Barrette-LaPierre patched a very trivial memory leak in
curl_escape() that would happen when realloc() returns NULL...
- Matthew Blain provided feedback to make the --create-dirs stuff build
properly on Windows.
- Fixed the #include in tests/libtest/first.c as Legoff Vincent pointed out.
Daniel (7 Jan 2003)
- Philippe Raoult provided a patch that now makes libcurl properly support
wildcard checks for certificate names.
- Simon Liu added CURLOPT_HTTP200ALIASES, to let an application set other
strings recognized as "HTTP 200" to allow http-like protocols to get
downloaded fine by curl.
- Now using autoconf 2.57 and automake 1.7.2
- Doing "curl -I ftp://domain/non-existing-file" still outputed a date!
Wayne Haigh reported.
- The error message is now written properly with a newline in the --trace
file.
Daniel (6 Jan 2003)
- Sterling Hughes fixed a possible bug: previously, if you called
curl_easy_perform and then set the global dns cache, the global cache
wouldn't be used. Pointed out by Jean-Philippe Barrette-LaPierre.
- Matthew Blain's fixed the VC6 libcurl makefile to include better debug data
on debug builds.
Daniel (27 Dec 2002)
- Philippe Raoult reported a bug with HTTPS connections which I evidently
added in my 19 dec fix. I corrected it.
Daniel (20 Dec)
- Idea from the Debian latest patch: use AM_MAINTAINER_MODE in the configure
script to make the default makefile less confusing "to the casual
installer".
Version 7.10.3-pre3 (20 Dec)
Daniel (19 Dec)
- Matthew Blain patched the Curl_base64_decode() function.
- Evan Jordan reported in bug report #653022 that the SSL_read() usage was
wrong, and it certainly was. It could lead to curl using too much CPU due to
a stupid loop.
Daniel (18 Dec)
- As suggested by Margus Freudenthal, CURLE_HTTP_NOT_FOUND was renamed to
CURLE_HTTP_RETURNED_ERROR since it is returned on any >= 400 code when
CURLOPT_FAILONERROR is set.
Daniel (17 Dec)
- Bug reported #651464, reported by Christopher Palmer, provided an example
source code using the multi interface that hang when trying to connect to a
proxy on a localhost port where no proxy was listening. This bug was not
repeatable on libcurls that were IPv6-enabled.
Daniel (16 Dec)
- Christopher Palmer also noticed what Vojtech Janota already was
experiencing: The attempted name resolve fix for glibc 2.2.93 caused libcurl
to crash when used on some older glibc versions. The problem is of course
the silliness of the 2.2.93. I committed a fix that hopefully should make
the binary run fine on either one of the versions, even though the solution
is not as nice as I'd like it to be.
Daniel (13 Dec)
- Bug report #651460 by Christopher R. Palmer showed that when using libcurl
to for example go over a proxy on localhost, it would attempt to connect
through the proxy TWICE.
I added test case 503 with which I managed to repeat this problem and I
fixed the code to not re-attempt any connects (which also made it a nicer
fix for the #650941 bug mentioned below).
The sws server was extended to deal with CONNECT in order to make test
case 503 do good.
- Evan Jordan posted bug report #650989 about a memory leak in the public key
retrieving code. He provided a suggested fix and I merely applied it!
- Bug report #650941, posted by Christopher R. Palmer identified a problem
with the multi interface and getting file:// URLs. This was now fixed and
test case 502 was added to verify this.
Daniel (12 Dec)
- Test case 500 and 501 are the first ever libcurl test cases that run.
- Made "configure --enable-debug" cut off all -O* options to the compiler
- Finally fixed the test suite's ftp server so that test case 402 doesn't
cause the following test case to fail anymore!
Daniel (11 Dec)
- CURL_MAX_WRITE_SIZE is now decreased to 16KB since it makes the Windows
version perform uploads much faster!!! RBramante did lots of research on
this topic.
- Fixed the #include in curl/curl.h to include the other files outside the
extern "C" scope.
Daniel (10 Dec)
- Moved around and added more logic:
First, POST data is never sent as part of the request headers in the http.c
code. It is always sent the "normal" read callback then send() way. This now
enables a plain HTTP POST to be sent chunked if we want to. This also
reduces the risk of having very big POSTs causing problems.
Further, sending off the initial HTTP request is not done using a loop
anymore. If it wasn't all sent off in the first send(), the rest of the
request is sent off in the normal transfer select() loop. This makes several
things possible, but mainly it makes libcurl block less when used from the
multi interface and it also reduces the risk of problems with issuing very
large requests.
Daniel (9 Dec)
- Moved the read callback pointer and data within the structs to a more
suitable place. This in preparation for a better HTTP-request sending code
without (a silly) loop.
- The Dodds fix seems not to work.
- Vojtech Janota tests proved that the resolve fix from oct 21st is not good
enough since obviously older glibcs might return EAGAIN without this meaning
that the buffer was too small.
- [the other day] Made libcurl loop on recv() and send() now until done, and
then get back to select(). Previously it went back to select() more often
which really was a slight overhead. This was due to the reported performance
problems on HTTP PUT on Windows. I couldn't see any notable difference on
Linux...
Version 7.10.3-pre2 (4 Dec 2002)
Daniel (4 Dec 2002)
- Lots of work with Malcolm Dodds made me add a temporary code fix that now
shortens the timeout waiting for the 226 or 250 line after a completed
FTP transfer.
If no data is received within 60 seconds, this is taken as a sign of a dead
control connection and we bail out.
Daniel (3 Dec 2002)
- Ralph's bug report #644841 identified a problem in which curl returned a
timeout error code when in fact the problem was not a timeout. The proper
error should now be propagated better when they're detected in the FTP
response reading function.
- Updated the Borland Makefiles.
Daniel (2 Dec 2002)
- Nicolas Berloquin provided a patch that introduced --create-dirs to the
command line tool. When used in combination with -o, it lets curl create
[non-existing] directories used in -o, suitably used with #-combinations
such as:
curl "www.images.com/{flowers,cities,parks,mountains}/pic_[1-100].jpg \
-o "dir_#1/pic#2.jpg" --create-dirs
Version 7.10.3-pre1
Daniel (28 Nov 2002)
- I visited Lars Nordgren and had a go with his problem, which lead me to
implement this fix. If libcurl detects the added custom header
"Transfer-Encoding: chunked", it will now enable a chunked transfer.
Also, chunked transfer didn't quite work before but seems to do so now.
- Kjetil Jacobsen pointed out that ./configure --disable-ipv6 --without-zlib
didn't work on any platform...
Daniel (26 Nov 2002)
- Fixed a bad addrinfo free in the hostip.c code, hardly exposed anywhere
- Dan Becker found and fixed a minor memory leak on persistent connnections
using CURLOPT_USERPWD.
Daniel (22 Nov 2002)
- Based on Ralph Mitchell's excellent analysis I found a bug in the test suite
web server (sws) which now lets test case 306 run fine even in combination
with the other test cases.
- Juan Ignacio Herv<72>s found a crash in the verbose connect message that is
used on persistent connections. This bug was added in 7.10.2 due to the
rearranged name resolve code.
Daniel (20 Nov 2002)
- Kjetil Jacobsen provided a patch that introduces:
CURLOPT_PRIVATE stores a private pointer in the curl handle.
CURLINFO_PRIVATE retrieves the private pointer from the curl handle.
- Karol Pietrzak pointed out how curl-config --cflags didn't output a good
include dir so I've removed that for now.
Version 7.10.2 (18 Nov 2002)
Daniel (11 Nov 2002)

View File

@@ -30,6 +30,11 @@ To build after having extracted everything from CVS, do this:
./configure
make
Daniel uses a ./configure line similar to this for easier development:
./configure --disable-shared --enable-debug --enable-maintainer-mode
REQUIREMENTS
You need the following software installed:

View File

@@ -1,21 +0,0 @@
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1996 - 2002, Daniel Stenberg, <daniel@haxx.se>.
All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.

View File

@@ -1,470 +0,0 @@
MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
``The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
The Original Code is ______________________________________.
The Initial Developer of the Original Code is ________________________.
Portions created by ______________________ are Copyright (C) ______
_______________________. All Rights Reserved.
Contributor(s): ______________________________________.
Alternatively, the contents of this file may be used under the terms
of the _____ license (the "[___] License"), in which case the
provisions of [______] License are applicable instead of those
above. If you wish to allow use of your version of this file only
under the terms of the [____] License and not to allow others to use
your version of this file under the MPL, indicate your decision by
deleting the provisions above and replace them with the notice and
other provisions required by the [___] License. If you do not delete
the provisions above, a recipient may use your version of this file
under either the MPL or the [___] License."
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. You should
use the text of this Exhibit A rather than the text found in the
Original Code Source Code for Your Modifications.]

5
README
View File

@@ -30,8 +30,9 @@ README
Sweden -- ftp://ftp.sunet.se/pub/www/utilities/curl/
Sweden -- http://cool.haxx.se/curl/
Germany -- ftp://ftp.fu-berlin.de/pub/unix/network/curl/
Australia -- http://curl.planetmirror.com/pub/curl/
US -- http://curl.sourceforge.net/download.html
Australia -- http://curl.planetmirror.com/download/
US -- http://curl.sourceforge.net/download/
Hongkong -- http://www.execve.net/curl/
To download the very latest source off the CVS server do this:

34
UPGRADE
View File

@@ -1,34 +0,0 @@
Upgrading to curl/libcurl 7.10 from any previous version
========================================================
libcurl 7.10 performs peer SSL certificate verification by default. This is
done by installing a default CA cert bundle on 'make install' (or similar),
that CA bundle package is used by default on operations against SSL servers.
Alas, if you communicate with HTTPS servers using certifcates that are signed
by CAs present in the bundle, you will not notice any changed behavior and you
will seeminglessly get a higher security level on your SSL connections since
can be sure that the remote server really is the one it claims to be.
If the remote server uses a self-signed certificate, or if you don't install
curl's CA cert bundle or if it uses a certificate signed by a CA that isn't
included in the bundle, then you need to do one of the following:
1. Tell libcurl to *not* verify the peer. With libcurl you disable with with
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
With the curl command tool, you disable this with -k/--insecure.
2. Get a CA certificate that can verify the remote server and use the proper
option to point out this CA cert for verification when connecting. For
libcurl hackers: curl_easy_setopt(curl, CURLOPT_CAPATH, capath);
With the curl command tool: --cacert [file]
This upgrade procedure has been deemed The Right Thing even though it adds
this extra trouble for some users, since it adds security to a majority of the
SSL connections that previously weren't really secure.
It turned out many people were using previous versions of curl/libcurl without
realizing the need for the CA cert options to get truly secure SSL
connections.

View File

@@ -9,6 +9,7 @@ dnl First some basic init macros
AC_INIT
AC_CONFIG_SRCDIR([lib/urldata.h])
AM_CONFIG_HEADER(lib/config.h src/config.h tests/server/config.h lib/ca-bundle.h)
AM_MAINTAINER_MODE
dnl figure out the libcurl version
VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
@@ -543,8 +544,7 @@ case "$OPT_ZLIB" in
AC_CHECK_HEADER(zlib.h,[
AC_CHECK_LIB(z, gzread,
[AM_CONDITIONAL(CONTENT_ENCODING, true)
HAVE_LIBZ="1"
[HAVE_LIBZ="1"
AC_SUBST(HAVE_LIBZ)
LIBS="$LIBS -lz"
AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
@@ -759,7 +759,18 @@ AC_ARG_ENABLE(debug,
CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -pedantic -Wundef -Wpointer-arith -Wcast-align -Wnested-externs"
fi
dnl strip off optimizer flags
CFLAGS=`echo $CFLAGS | sed -e 's/-O[0-9 ]//g'`
NEWFLAGS=""
for flag in $CFLAGS; do
case "$flag" in
-O*)
dnl echo "cut off $flag"
;;
*)
NEWFLAGS="$NEWFLAGS $flag"
;;
esac
done
CFLAGS=$NEWFLAGS
;;
esac ],
AC_MSG_RESULT(no)
@@ -776,6 +787,7 @@ AC_CONFIG_FILES([Makefile \
tests/Makefile \
tests/data/Makefile \
tests/server/Makefile \
tests/libtest/Makefile \
packages/Makefile \
packages/Win32/Makefile \
packages/Win32/cygwin/Makefile \

View File

@@ -107,7 +107,8 @@ while test $# -gt 0; do
;;
--cflags)
echo -I@includedir@
#echo -I@includedir@
echo ""
;;
--libs)

View File

@@ -42,7 +42,8 @@ Naming
understandable and be named according to what they're used for. File-local
functions should be made static. We like lower case names.
See the INTERNALS document on how we name non-exported library-global symbols.
See the INTERNALS document on how we name non-exported library-global
symbols.
Indenting
@@ -55,7 +56,7 @@ Indenting
Commenting
Comment your source code extensively using C comments (/* comment */), do not
Comment your source code extensively using C comments (/* comment */), DO NOT
use C++ comments (// this style). Commented code is quality code and enables
future modifications much more. Uncommented code much more risk being
completely replaced when someone wants to extend things, since other persons'
@@ -64,7 +65,7 @@ Commenting
General Style
Keep your functions small. If they're small you avoid a lot of mistakes and
you don't accidentally mix up variables.
you don't accidentally mix up variables etc.
Non-clobbering All Over
@@ -78,11 +79,11 @@ Non-clobbering All Over
Platform Dependent Code
Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
particular operting systems or hardware in the #ifdef lines. The HAVE_FEATURE
shall be generated by the configure script for unix-like systems and they are
hard-coded in the config-[system].h files for the others.
particular operating systems or hardware in the #ifdef lines. The
HAVE_FEATURE shall be generated by the configure script for unix-like systems
and they are hard-coded in the config-[system].h files for the others.
Separate Patches Doing Different Things
Separate Patches
It is annoying when you get a huge patch from someone that is said to fix 511
odd problems, but discussions and opinions don't agree with 510 of them - or
@@ -128,3 +129,21 @@ Test Cases
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!
How To Make a Patch
Keep a copy of the unmodified curl sources. Make your changes in a separate
source tree. When you think you have something that you want to offer the
curl community, use GNU diff to generate patches.
If you have modified a single file, try something like:
diff -u undmodified-file.c my-changed-one.c > my-fixes.diff
If you have modified several files, possibly in different directories, you
can use diff recursively:
diff -ur curl-original-dir curl-modfied-sources-dir > my-fixes.diff
GNU diff exists for virtually all platforms, including all kinds of unixes
and Windows.

View File

@@ -1,4 +1,4 @@
Updated: November 12, 2002 (http://curl.haxx.se/docs/faq.html)
Updated: January 13, 2003 (http://curl.haxx.se/docs/faq.html)
_ _ ____ _
___| | | | _ \| |
/ __| | | | |_) | |
@@ -59,6 +59,7 @@ FAQ
4.9 Curl can't authenticate to the server that requires NTLM?
4.10 My HTTP request using HEAD, PUT or DELETE doesn't work!
4.11 Why does my HTTP range requests return the full document?
4.12 Why do I get "certificate verify failed" ?
5. libcurl Issues
5.1 Is libcurl thread-safe?
@@ -274,8 +275,8 @@ FAQ
2.4. Does cURL support Socks (RFC 1928) ?
No. Nobody has wanted it that badly yet. We appreciate patches that bring
this functionality.
There is limited support for SOCKS5 for curl built with IPv6 support
disabled.
3. Usage problems
@@ -607,6 +608,30 @@ FAQ
Because the range may not be supported by the server, or the server may
choose to ignore it and return the full document anyway.
4.12 Why do I get "certificate verify failed" ?
You invoke curl 7.10 or later to communicate on a https:// URL and get an
error back looking something similar to this:
curl: (35) SSL: error:14090086:SSL routines:
SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Then it means that curl couldn't verify that the server's certificate was
good. Curl verifies the certificate using the CA cert bundle that comes with
the curl installation.
To disable the verification (which makes it act like curl did before 7.10),
use -k. This does however enable man-in-the-middle attacks.
If you get this failure but are having a CA cert bundle installed and used,
the server's certificate is not signed by one of the CA's in the bundle. It
might for example be self-signed. You then correct this problem by obtaining
a valid CA cert for the server. Or again, decrease the security by disabling
this check.
Details are also in the SSLCERTS file in the release archives, found online
here: http://curl.haxx.se/lxr/source/SSLCERTS
5. libcurl Issues
5.1. Is libcurl thread-safe?

View File

@@ -28,11 +28,22 @@ UNIX
You probably need to be root when doing the last command.
If you have checked out the sources from the CVS repository, read the
CVS-INFO on how to proceed.
If you want to install curl in a different file hierarchy than /usr/local,
you need to specify that already when running configure:
./configure --prefix=/path/to/curl/tree
If you happen to have write permission in that directory, you can do 'make
install' without being root. An example of this would be to make a local
install in your own home directory:
./configure --prefix=$HOME
make
make install
The configure script always tries to find a working SSL library unless
explicitly told not to. If you have OpenSSL installed in the default search
path for your compiler/linker, you don't need to do anything special. If
@@ -71,33 +82,6 @@ UNIX
LIBS=-lRSAglue -lrsaref
(as suggested by Doug Kaufman)
KNOWN PROBLEMS (these ones should not happen anymore)
If you happen to have autoconf installed, but a version older than 2.12
you will get into trouble. Then you can still build curl by issuing these
commands (note that this requires curl to be built staticly): (from Ralph
Beckmann)
./configure [...]
cd lib; make; cd ..
cd src; make; cd ..
cp src/curl elsewhere/bin/
As suggested by David West, you can make a faked version of autoconf and
autoheader:
----start of autoconf----
#!/bin/bash
#fake autoconf for building curl
if [ "$1" = "--version" ] then
echo "Autoconf version 2.13"
fi
----end of autoconf----
Then make autoheader a symbolic link to the same script and make sure
they're executable and set to appear in the path *BEFORE* the actual (but
obsolete) autoconf and autoheader scripts.
MORE OPTIONS
To force configure to use the standard cc compiler if both cc and gcc are

View File

@@ -15,7 +15,8 @@ TODO
* Introduce an interface to libcurl that allows applications to easier get to
know what cookies that are received. Pushing interface that calls a
callback on each received cookie? Querying interface that asks about
existing cookies? We probably need both.
existing cookies? We probably need both. Enable applications to modify
existing cookies as well.
* Make content encoding/decoding internally be made using a filter system.
@@ -23,13 +24,6 @@ TODO
less copy of data and thus a faster operation.
[http://curl.haxx.se/dev/no_copy_callbacks.txt]
* Run-time querying about library characterics. What protocols do this
running libcurl support? What is the version number of the running libcurl
(returning the well-defined version-#define). This could possibly be made
by allowing curl_easy_getinfo() work with a NULL pointer for global info,
but perhaps better would be to introduce a new curl_getinfo() (or similar)
function for global info reading.
* Add asynchronous name resolving (http://daniel.haxx.se/resolver/). This
should be made to work on most of the supported platforms, or otherwise it
isn't really interesting.
@@ -51,12 +45,9 @@ TODO
>4GB all over. Bug reports (and source reviews) indicate that it doesn't
currently work properly.
* Make the built-in progress meter use its own dedicated output stream, and
make it possible to set it. Use stderr by default.
* CURLOPT_MAXFILESIZE. Prevent downloads that are larger than the specified
size. CURLE_FILESIZE_EXCEEDED would then be returned. Gautam Mani
requested. That is, the download should even begin but be aborted
requested. That is, the download should not even begin but be aborted
immediately.
* Allow the http_proxy (and other) environment variables to contain user and
@@ -66,8 +57,7 @@ TODO
LIBCURL - multi interface
* Make sure we don't ever loop because of non-blocking sockets return
EWOULDBLOCK or similar. This concerns the HTTP request sending (and
especially regular HTTP POST), the FTP command sending etc.
EWOULDBLOCK or similar. This FTP command sending etc.
* Make uploads treated better. We need a way to tell libcurl we have data to
write, as the current system expects us to upload data each time the socket
@@ -86,6 +76,9 @@ TODO
receiver will convert the data from the standard form to his own internal
form."
* Since USERPWD always override the user and password specified in URLs, we
might need another way to specify user+password for anonymous ftp logins.
* An option to only download remote FTP files if they're newer than the local
one is a good idea, and it would fit right into the same syntax as the
already working http dito works. It of course requires that 'MDTM' works,
@@ -103,12 +96,6 @@ TODO
also prevents the authentication info from getting sent when following
locations to legitimate other host names.
* "Content-Encoding: compress/gzip/zlib" HTTP 1.1 clearly defines how to get
and decode compressed documents. There is the zlib that is pretty good at
decompressing stuff. This work was started in October 1999 but halted again
since it proved more work than we thought. It is still a good idea to
implement though. This requires the filter system mentioned above.
* Authentication: NTLM. Support for that MS crap called NTLM
authentication. MS proxies and servers sometime require that. Since that
protocol is a proprietary one, it involves reverse engineering and network

View File

@@ -122,6 +122,9 @@ Use "-C -" to tell curl to automatically find out where/how to resume the
transfer. It then uses the given output/input files to figure that out.
If this option is used several times, the last one will be used.
.IP "---create-dirs"
When used in conjunction with the -o option, curl will create the necessary
local directory hierarchy as needed.
.IP "--crlf"
(FTP) Convert LF to CRLF in upload. Useful for MVS (OS/390).
@@ -315,6 +318,8 @@ to be made secure by using the CA certificate bundle installed by
default. This makes all connections considered "insecure" to fail unless
-k/--insecure is used.
This option is ignored if --cacert or --capath is used!
If this option is used twice, the second time will again disable it.
.IP "--krb4 <level>"
(FTP) Enable kerberos4 authentication and use. The level must be entered and
@@ -425,6 +430,8 @@ or use several variables like:
curl http://{site,host}.host[1-5].com -o "#1_#2"
You may use this option as many times as you have number of URLs.
See also the --create-dirs option to create the local directories dynamically.
.IP "-O/--remote-name"
Write output to a local file named like the remote file we get. (Only
the file part of the remote file is used, the path is cut off.)
@@ -820,7 +827,8 @@ FTP couldn't set binary. Couldn't change transfer method to binary.
.IP 18
Partial file. Only a part of the file was transfered.
.IP 19
FTP couldn't RETR file. The RETR command failed.
FTP couldn't download/access the given file, the RETR (or similar) command
failed.
.IP 20
FTP write error. The transfer was reported bad by the server.
.IP 21

View File

@@ -83,7 +83,8 @@ int main(int argc, char **argv)
default:
/* one or more of curl's file descriptors say there's data to read
or write */
curl_multi_perform(multi_handle, &still_running);
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
break;
}
}

View File

@@ -80,7 +80,8 @@ int main(int argc, char **argv)
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &still_running);
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
break;
}
}

View File

@@ -74,7 +74,8 @@ int main(int argc, char **argv)
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &still_running);
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multi_handle, &still_running));
break;
}
}

View File

@@ -66,7 +66,7 @@ int main(int argc, char **argv)
curl = curl_easy_init();
if(curl) {
/* what call to write: */
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://curl.haxx.se");
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
while(1) /* do some ugly short cut... */

View File

@@ -232,6 +232,7 @@ Multi-threading issues
For SIGPIPE info see the UNIX Socket FAQ at
http://www.unixguide.net/network/socketfaq/2.22.shtml
Also, note that CURLOPT_DNS_USE_GLOBAL_CACHE is not thread-safe.
When It Doesn't Work
@@ -255,6 +256,9 @@ When It Doesn't Work
possible of your code that uses libcurl, operating system name and version,
compiler name and version etc.
If CURLOPT_VERBOSE is not enough, you increase the level of debug data your
application receive by using the CURLOPT_DEBUGFUNCTION.
Getting some in-depth knowledge about the protocols involved is never wrong,
and if you're trying to do funny things, you might very well understand
libcurl and how to use it better if you study the appropriate RFC documents
@@ -293,8 +297,8 @@ Upload Data to a Remote Site
curl_easy_setopt(easyhandle, CURLOPT_UPLOAD, TRUE);
A few protocols won't behave properly when uploads are done without any prior
knowledge of the expected file size. HTTP PUT is one example [1]. So, set the
upload file size using the CURLOPT_INFILESIZE like this:
knowledge of the expected file size. So, set the upload file size using the
CURLOPT_INFILESIZE for all known file sizes like this[1]:
curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE, file_size);
@@ -404,7 +408,7 @@ HTTP POSTing
headers = curl_slist_append(headers, "Content-Type: text/xml");
/* post binary data */
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELD, binaryptr);
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, binaryptr);
/* set the size of the postfields data */
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, 23);
@@ -726,6 +730,35 @@ Persistancy Is The Way to Happiness
CURLOPT_FORBID_REUSE to TRUE.
HTTP Headers Used by libcurl
When you use libcurl to do HTTP requeests, it'll pass along a series of
headers automaticly. It might be good for you to know and understand these
ones.
Host
This header is required by HTTP 1.1 and even many 1.0 servers and should
be the name of the server we want to talk to. This includes the port
number if anything but default.
Pragma
"no-cache". Tells a possible proxy to not grap a copy from the cache but
to fetch a fresh one.
Accept:
"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*". Cloned from a
browser once a hundred years ago.
Expect:
When doing multi-part formposts, libcurl will set this header to
"100-continue" to ask the server for an "OK" message before it proceeds
with sending the data part of the post.
Customizing Operations
There is an ongoing development today where more and more protocols are built
@@ -738,101 +771,129 @@ Customizing Operations
libcurl is your friend here too.
If just changing the actual HTTP request keyword is what you want, like when
GET, HEAD or POST is not good enough for you, CURLOPT_CUSTOMREQUEST is there
for you. It is very simple to use:
CUSTOMREQUEST
curl_easy_setopt(easyhandle, CURLOPT_CUSTOMREQUEST, "MYOWNRUQUEST");
If just changing the actual HTTP request keyword is what you want, like
when GET, HEAD or POST is not good enough for you, CURLOPT_CUSTOMREQUEST
is there for you. It is very simple to use:
When using the custom request, you change the request keyword of the actual
request you are performing. Thus, by default you make GET request but you can
also make a POST operation (as described before) and then replace the POST
keyword if you want to. You're the boss.
curl_easy_setopt(easyhandle, CURLOPT_CUSTOMREQUEST, "MYOWNRUQUEST");
HTTP-like protocols pass a series of headers to the server when doing the
request, and you're free to pass any amount of extra headers that you think
fit. Adding headers are this easy:
When using the custom request, you change the request keyword of the
actual request you are performing. Thus, by default you make GET request
but you can also make a POST operation (as described before) and then
replace the POST keyword if you want to. You're the boss.
struct curl_slist *headers=NULL; /* init to NULL is important */
Modify Headers
headers = curl_slist_append(headers, "Hey-server-hey: how are you?");
headers = curl_slist_append(headers, "X-silly-content: yes");
HTTP-like protocols pass a series of headers to the server when doing the
request, and you're free to pass any amount of extra headers that you
think fit. Adding headers are this easy:
/* pass our list of custom made headers */
curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);
struct curl_slist *headers=NULL; /* init to NULL is important */
curl_easy_perform(easyhandle); /* transfer http */
headers = curl_slist_append(headers, "Hey-server-hey: how are you?");
headers = curl_slist_append(headers, "X-silly-content: yes");
curl_slist_free_all(headers); /* free the header list */
/* pass our list of custom made headers */
curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);
... and if you think some of the internally generated headers, such as
User-Agent:, Accept: or Host: don't contain the data you want them to
contain, you can replace them by simply setting them too:
curl_easy_perform(easyhandle); /* transfer http */
headers = curl_slist_append(headers, "User-Agent: 007");
headers = curl_slist_append(headers, "Host: munged.host.line");
curl_slist_free_all(headers); /* free the header list */
If you replace an existing header with one with no contents, you will prevent
the header from being sent. Like if you want to completely prevent the
"Accept:" header to be sent, you can disable it with code similar to this:
... and if you think some of the internally generated headers, such as
Accept: or Host: don't contain the data you want them to contain, you can
replace them by simply setting them too:
headers = curl_slist_append(headers, "Accept:");
headers = curl_slist_append(headers, "Accept: Agent-007");
headers = curl_slist_append(headers, "Host: munged.host.line");
Both replacing and cancelling internal headers should be done with careful
consideration and you should be aware that you may violate the HTTP protocol
when doing so.
Delete Headers
There's only one aspect left in the HTTP requests that we haven't yet
mentioned how to modify: the version field. All HTTP requests includes the
version number to tell the server which version we support. libcurl speak
HTTP 1.1 by default. Some very old servers don't like getting 1.1-requests
and when dealing with stubborn old things like that, you can tell libcurl to
use 1.0 instead by doing something like this:
If you replace an existing header with one with no contents, you will
prevent the header from being sent. Like if you want to completely prevent
the "Accept:" header to be sent, you can disable it with code similar to
this:
curl_easy_setopt(easyhandle, CURLOPT_HTTP_VERSION, CURLHTTP_VERSION_1_0);
headers = curl_slist_append(headers, "Accept:");
Not all protocols are HTTP-like, and thus the above may not help you when you
want to make for example your FTP transfers to behave differently.
Both replacing and cancelling internal headers should be done with careful
consideration and you should be aware that you may violate the HTTP
protocol when doing so.
Sending custom commands to a FTP server means that you need to send the
comands exactly as the FTP server expects them (RFC959 is a good guide here),
and you can only use commands that work on the control-connection alone. All
kinds of commands that requires data interchange and thus needs a
data-connection must be left to libcurl's own judgement. Also be aware that
libcurl will do its very best to change directory to the target directory
before doing any transfer, so if you change directory (with CWD or similar)
you might confuse libcurl and then it might not attempt to transfer the file
in the correct remote directory.
Enforcing chunked transfer-encoding
A little example that deletes a given file before an operation:
By making sure a request uses the custom header "Transfer-Encoding:
chunked" when doing a non-GET HTTP operation, libcurl will switch over to
"chunked" upload, even though the size of the data to upload might be
known. By default, libcurl usually switches over to chunked upload
automaticly if the upload data size is unknown.
headers = curl_slist_append(headers, "DELE file-to-remove");
HTTP Version
/* pass the list of custom commands to the handle */
curl_easy_setopt(easyhandle, CURLOPT_QUOTE, headers);
There's only one aspect left in the HTTP requests that we haven't yet
mentioned how to modify: the version field. All HTTP requests includes the
version number to tell the server which version we support. libcurl speak
HTTP 1.1 by default. Some very old servers don't like getting 1.1-requests
and when dealing with stubborn old things like that, you can tell libcurl
to use 1.0 instead by doing something like this:
curl_easy_perform(easyhandle); /* transfer ftp data! */
curl_easy_setopt(easyhandle, CURLOPT_HTTP_VERSION,
CURLHTTP_VERSION_1_0);
curl_slist_free_all(headers); /* free the header list */
FTP Custom Commands
If you would instead want this operation (or chain of operations) to happen
_after_ the data transfer took place the option to curl_easy_setopt() would
instead be called CURLOPT_POSTQUOTE and used the exact same way.
Not all protocols are HTTP-like, and thus the above may not help you when
you want to make for example your FTP transfers to behave differently.
The custom FTP command will be issued to the server in the same order they
are added to the list, and if a command gets an error code returned back from
the server, no more commands will be issued and libcurl will bail out with an
error code (CURLE_FTP_QUOTE_ERROR). Note that if you use CURLOPT_QUOTE to
send commands before a transfer, no transfer will actually take place when a
quote command has failed.
Sending custom commands to a FTP server means that you need to send the
comands exactly as the FTP server expects them (RFC959 is a good guide
here), and you can only use commands that work on the control-connection
alone. All kinds of commands that requires data interchange and thus needs
a data-connection must be left to libcurl's own judgement. Also be aware
that libcurl will do its very best to change directory to the target
directory before doing any transfer, so if you change directory (with CWD
or similar) you might confuse libcurl and then it might not attempt to
transfer the file in the correct remote directory.
If you set the CURLOPT_HEADER to true, you will tell libcurl to get
information about the target file and output "headers" about it. The headers
will be in "HTTP-style", looking like they do in HTTP.
A little example that deletes a given file before an operation:
The option to enable headers or to run custom FTP commands may be useful to
combine with CURLOPT_NOBODY. If this option is set, no actual file content
transfer will be performed.
headers = curl_slist_append(headers, "DELE file-to-remove");
/* pass the list of custom commands to the handle */
curl_easy_setopt(easyhandle, CURLOPT_QUOTE, headers);
curl_easy_perform(easyhandle); /* transfer ftp data! */
curl_slist_free_all(headers); /* free the header list */
If you would instead want this operation (or chain of operations) to
happen _after_ the data transfer took place the option to
curl_easy_setopt() would instead be called CURLOPT_POSTQUOTE and used the
exact same way.
The custom FTP command will be issued to the server in the same order they
are added to the list, and if a command gets an error code returned back
from the server, no more commands will be issued and libcurl will bail out
with an error code (CURLE_FTP_QUOTE_ERROR). Note that if you use
CURLOPT_QUOTE to send commands before a transfer, no transfer will
actually take place when a quote command has failed.
If you set the CURLOPT_HEADER to true, you will tell libcurl to get
information about the target file and output "headers" about it. The
headers will be in "HTTP-style", looking like they do in HTTP.
The option to enable headers or to run custom FTP commands may be useful
to combine with CURLOPT_NOBODY. If this option is set, no actual file
content transfer will be performed.
FTP Custom CUSTOMREQUEST
If you do what list the contents of a FTP directory using your own defined
FTP command, CURLOPT_CUSTOMREQUEST will do just that. "NLST" is the
default one for listing directories but you're free to pass in your idea
of a good alternative.
Cookies Without Chocolate Chips
@@ -1007,19 +1068,30 @@ SSL, Certificates and Other Tricks
[ seeding, passwords, keys, certificates, ENGINE, ca certs ]
Multiple Transfers Using the multi Interface
The easy interface as described in detail in this document is a synchronous
interface that transfers one file at a time and doesn't return until its
done.
The multi interface on the other hand, allows your program to transfer
multiple files in both directions at the same time, without forcing you to
use multiple threads.
[fill in lots of more multi stuff here]
Future
[ multi interface, sharing between handles, mutexes, pipelining ]
[ sharing between handles, mutexes, pipelining ]
-----
Footnotes:
[1] = HTTP PUT without knowing the size prior to transfer is indeed possible,
but libcurl does not support the chunked transfers on uploading that is
necessary for this feature to work. We'd gratefully appreciate patches
that bring this functionality...
[1] = libcurl 7.10.3 and later have the ability to switch over to chunked
Tranfer-Encoding in cases were HTTP uploads are done with data of an
unknown size.
[2] = This happens on Windows machines when libcurl is built and used as a
DLL. However, you can still do this on Windows if you link with a static

View File

@@ -115,8 +115,12 @@ Pass a pointer to a 'char *' to receive the content-type of the downloaded
object. This is the value read from the Content-Type: field. If you get NULL,
it means that the server didn't send a valid Content-Type header or that the
protocol used doesn't support this. (Added in 7.9.4)
.TP
.B CURLINFO_PRIVATE
Pass a pointer to a 'char *' to receive the pointer to the private data
associated with the curl handle (set with the CURLOPT_PRIVATE option to curl_easy_setopt).
(Added in 7.10.3)
.PP
.SH RETURN VALUE
If the operation was successful, CURLE_OK is returned. Otherwise an
appropriate error code will be returned.

View File

@@ -1,7 +1,7 @@
.\" nroff -man [file]
.\" $Id$
.\"
.TH curl_easy_setopt 3 "13 Nov 2002" "libcurl 7.10" "libcurl Manual"
.TH curl_easy_setopt 3 "3 Dec 2002" "libcurl 7.10.3" "libcurl Manual"
.SH NAME
curl_easy_setopt - set options for a curl easy handle
.SH SYNOPSIS
@@ -70,10 +70,10 @@ Function pointer that should match the following prototype: \fBsize_t
function( void *ptr, size_t size, size_t nmemb, void *stream);\fP This
function gets called by libcurl as soon as there is data reveiced that needs
to be saved. The size of the data pointed to by \fIptr\fP is \fIsize\fP
multiplied with \fInmemb\fP. Return the number of bytes actually taken care
of. If that amount differs from the amount passed to your function, it'll
signal an error to the library and it will abort the transfer and return
\fICURLE_WRITE_ERROR\fP.
multiplied with \fInmemb\fP, it will not be zero terminated. Return the number
of bytes actually taken care of. If that amount differs from the amount passed
to your function, it'll signal an error to the library and it will abort the
transfer and return \fICURLE_WRITE_ERROR\fP.
Set the \fIstream\fP argument with the \fBCURLOPT_FILE\fP option.
@@ -175,6 +175,10 @@ curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);\fP
This function will receive debug information if CURLOPT_VERBOSE is
enabled. The curl_infotype argument specifies what kind of information it
is. This funtion must return 0.
NOTE: the data pointed to by the char * passed to this function WILL NOT be
zero terminated, but will be exactly of the size as told by the size_t
argument.
.TP
.B CURLOPT_DEBUGDATA
Pass a pointer to whatever you want passed in to your CURLOPT_DEBUGFUNCTION in
@@ -401,11 +405,31 @@ list. If you add a header that is otherwise generated and used by libcurl
internally, your added one will be used instead. If you add a header with no
contents as in 'Accept:' (no data on the right side of the colon), the
internally used header will get disabled. Thus, using this option you can add
new headers, replace internal headers and remove internal headers.
new headers, replace internal headers and remove internal headers. The
headers included in the linked list must not be CRLF-terminated, because
curl adds CRLF after each header item. Failure to comply with this will
result in strange bugs because the server will most likely ignore part
of the headers you specified.
\fBNOTE:\fPThe most commonly replaced headers have "shortcuts" in the options
CURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER.
.TP
.B CURLOPT_HTTP200ALIASES
Pass a pointer to a linked list of aliases to be treated as valid HTTP 200
responses. Some servers respond with a custom header response line. For
example, IceCast servers respond with "ICY 200 OK". By including this string
in your list of aliases, the response will be treated as a valid HTTP header
line such as "HTTP/1.0 200 OK". (Added in 7.10.3)
The linked list should be a fully valid list of struct curl_slist structs, and
be properly filled in. Use \fIcurl_slist_append(3)\fP to create the list and
\fIcurl_slist_free_all(3)\fP to clean up an entire list.
\fBNOTE:\fPThe alias itself is not parsed for any version strings. So if your
alias is "MYHTTP/9.9", Libcurl will not treat the server as responding with
HTTP version 9.9. Instead Libcurl will use the value set by option
\fICURLOPT_HTTP_VERSION\fP.
.TP
.B CURLOPT_COOKIE
Pass a pointer to a zero terminated string as parameter. It will be used to
set a cookie in the http request. The format of the string should be
@@ -712,10 +736,13 @@ Pass a long as parameter. Set what version of SSL to attempt to use, 2 or
servers make this difficult why you at times may have to use this option.
.TP
.B CURLOPT_SSL_VERIFYPEER
Pass a long that is set to a non-zero value to make curl verify the peer's
certificate. The certificate to verify against must be specified with the
CURLOPT_CAINFO option (Added in 7.4.2) or a certificate directory must be specified
with the CURLOPT_CAPATH option (Added in 7.9.8).
Pass a long that is set to a zero value to stop curl from verifying the peer's
certificate (7.10 starting setting this option to TRUE by default). Alternate
certificates to verify against can be specified with the CURLOPT_CAINFO option
(Added in 7.4.2) or a certificate directory can be specified with the
CURLOPT_CAPATH option (Added in 7.9.8). As of 7.10, curl installs a default
bundle. CURLOPT_SSL_VERIFYHOST may also need to be set to 1 or 0 if
CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2).
.TP
.B CURLOPT_CAINFO
Pass a char * to a zero terminated string naming a file holding one or more
@@ -742,7 +769,8 @@ socket. It will be used to seed the random engine for SSL.
.B CURLOPT_SSL_VERIFYHOST
Pass a long. Set if we should verify the Common name from the peer certificate
in the SSL handshake, set 1 to check existence, 2 to ensure that it matches
the provided hostname. (Added in 7.8.1)
the provided hostname. This is by default set to 2. (Added in 7.8.1, default
changed in 7.10)
.TP
.B CURLOPT_SSL_CIPHER_LIST
Pass a char *, pointing to a zero terminated string holding the list of
@@ -763,6 +791,13 @@ krb4 awareness. This is a string, 'clear', 'safe', 'confidential' or
will be used. Set the string to NULL to disable kerberos4. The kerberos
support only works for FTP. (Added in 7.3)
.PP
.SH OTHER OPTIONS
.TP 0.4i
.B CURLOPT_PRIVATE
Pass a char * as parameter, pointing to data that should be associated with
the curl handle. The pointer can be subsequently retrieved using the
CURLINFO_PRIVATE options to curl_easy_getinfo. (Added in 7.10.3)
.PP
.SH RETURN VALUE
CURLE_OK (zero) means that the option was set properly, non-zero means an
error occurred as \fI<curl/curl.h>\fP defines. See the \fIlibcurl-errors.3\fP

View File

@@ -19,6 +19,12 @@ integer-pointer.
.SH "RETURN VALUE"
CURLMcode type, general libcurl multi interface error code.
If you receive \fICURLM_CALL_MULTI_PERFORM\fP, this basicly means that you
should call \fIcurl_multi_perform\fP again, before you select() on more
actions. You don't have to do it immediately, but the return code means that
libcurl may have more data available to return or that there may be more data
to send off before it is "satisfied".
NOTE that this only returns errors etc regarding the whole multi stack. There
might still have occurred problems on invidual transfers even when this
function returns OK.

View File

@@ -2,7 +2,7 @@
.\" nroff -man [file]
.\" $Id$
.\"
.TH libcurl-errors 3 "10 April 2002" "libcurl 7.9.6" "libcurl errors"
.TH libcurl-errors 3 "18 Dec 2002" "libcurl 7.10.3" "libcurl errors"
.SH NAME
error codes in libcurl
.SH DESCRIPTION
@@ -104,7 +104,7 @@ After a completed file transfer, the FTP server did not respond a proper
When sending custom "QUOTE" commands to the remote server, one of the commands
returned an error code that was 400 or higher.
.TP
.B CURLE_HTTP_NOT_FOUND (22)
.B CURLE_HTTP_RETURNED_ERROR (22)
This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server
returns an error code that is >= 400.
.TP

View File

@@ -72,9 +72,9 @@ timeout every now and then, should you want that.
A little note here about the return codes from the multi functions, and
especially the \fIcurl_multi_perform\fP: if you receive
\fICURLM_CALL_MULTI_PERFORM\fP, this basicly means that you should call
\fIcurlm_call_multi_perform\fP again, before you select() on more actions. You
don't have to do it immediately, but the return code means that libcurl may
have more data available to return or that there may be more data to send off
\fIcurl_multi_perform\fP again, before you select() on more actions. You don't
have to do it immediately, but the return code means that libcurl may have
more data available to return or that there may be more data to send off
before it is "satisfied".
\fIcurl_multi_perform\fP stores the number of still running transfers in one

View File

@@ -66,9 +66,9 @@ struct curl_httppost {
char *contents; /* pointer to allocated data contents */
long contentslength; /* length of contents field */
/* CMC: Added support for buffer uploads */
char *buffer; /* pointer to allocated buffer contents */
long bufferlength; /* length of buffer field */
/* CMC: Added support for buffer uploads */
char *buffer; /* pointer to allocated buffer contents */
long bufferlength; /* length of buffer field */
char *contenttype; /* Content-Type */
struct curl_slist* contentheader; /* list of extra headers for this form */
@@ -96,7 +96,9 @@ typedef int (*curl_progress_callback)(void *clientp,
double ultotal,
double ulnow);
#define CURL_MAX_WRITE_SIZE 20480
/* Tests have proven that 20K is a very bad buffer size for uploads on
Windows, while 16K for some odd reason performed a lot better. */
#define CURL_MAX_WRITE_SIZE 16384
typedef size_t (*curl_write_callback)(char *buffer,
size_t size,
@@ -160,7 +162,7 @@ typedef enum {
CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
CURLE_FTP_WRITE_ERROR, /* 20 */
CURLE_FTP_QUOTE_ERROR, /* 21 */
CURLE_HTTP_NOT_FOUND, /* 22 */
CURLE_HTTP_RETURNED_ERROR, /* 22 */
CURLE_WRITE_ERROR, /* 23 */
CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */
CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */
@@ -207,6 +209,7 @@ typedef enum {
/* Make a spelling correction for the operation timed-out define */
#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED
#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
typedef enum {
CURLPROXY_HTTP = 0,
@@ -610,6 +613,11 @@ typedef enum {
the response to be compressed. */
CINIT(ENCODING, OBJECTPOINT, 102),
/* Set pointer to private data */
CINIT(PRIVATE, OBJECTPOINT, 103),
/* Set aliases for HTTP 200 in the HTTP Response header */
CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;
@@ -803,8 +811,8 @@ CURLcode curl_global_init(long flags);
void curl_global_cleanup(void);
/* This is the version number */
#define LIBCURL_VERSION "7.10.2"
#define LIBCURL_VERSION_NUM 0x070a02
#define LIBCURL_VERSION "7.10.3"
#define LIBCURL_VERSION_NUM 0x070a03
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
struct curl_slist {
@@ -861,16 +869,13 @@ typedef enum {
CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
CURLINFO_PRIVATE = CURLINFO_STRING + 21,
/* Fill in new entries here! */
CURLINFO_LASTONE = 21
CURLINFO_LASTONE = 22
} CURLINFO;
/* unfortunately, the easy.h and multi.h include files need options and info
stuff before they can be included! */
#include "easy.h" /* nothing in curl is fun without the easy stuff */
#include "multi.h"
typedef enum {
CURLCLOSEPOLICY_NONE, /* first, never use this */
@@ -894,35 +899,56 @@ typedef enum {
* Setup defines, protos etc for the sharing stuff.
*/
/* Different types of locks that a share can aquire */
/* Different data locks for a single share */
typedef enum {
CURL_LOCK_TYPE_NONE = 0,
CURL_LOCK_TYPE_COOKIE = 1<<0,
CURL_LOCK_TYPE_DNS = 1<<1,
CURL_LOCK_TYPE_SSL_SESSION = 2<<1,
CURL_LOCK_TYPE_CONNECT = 2<<2,
CURL_LOCK_TYPE_LAST
} curl_lock_type;
CURL_LOCK_DATA_NONE = 0,
CURL_LOCK_DATA_COOKIE = 1,
CURL_LOCK_DATA_DNS = 2,
CURL_LOCK_DATA_SSL_SESSION = 3,
CURL_LOCK_DATA_CONNECT = 4,
CURL_LOCK_DATA_LAST
} curl_lock_data;
typedef void (*curl_lock_function)(CURL *, curl_lock_type, void *);
typedef void (*curl_unlock_function)(CURL *, curl_lock_type, void *);
/* Different lock access types */
typedef enum {
CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */
CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */
CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */
CURL_LOCK_ACCESS_LAST /* never use */
} curl_lock_access;
typedef struct {
unsigned int specifier;
unsigned int locked;
unsigned int dirty;
curl_lock_function lockfunc;
curl_unlock_function unlockfunc;
void *clientdata;
} curl_share;
typedef void (*curl_lock_function)(CURL *handle,
curl_lock_data data,
curl_lock_access access,
void *userptr);
typedef void (*curl_unlock_function)(CURL *handle,
curl_lock_data data,
void *userptr);
curl_share *curl_share_init (void);
CURLcode curl_share_setopt (curl_share *, curl_lock_type, int);
CURLcode curl_share_set_lock_function (curl_share *, curl_lock_function);
CURLcode curl_share_set_unlock_function (curl_share *, curl_unlock_function);
CURLcode curl_share_set_lock_data (curl_share *, void *);
CURLcode curl_share_destroy (curl_share *);
typedef void CURLSH;
typedef enum {
CURLSHE_OK, /* all is fine */
CURLSHE_BAD_OPTION, /* 1 */
CURLSHE_IN_USE, /* 2 */
CURLSHE_INVALID, /* 3 */
CURLSHE_LAST /* never use */
} CURLSHcode;
typedef enum {
CURLSHOPT_NONE, /* don't use */
CURLSHOPT_SHARE, /* specify a data type to share */
CURLSHOPT_UNSHARE, /* specify shich data type to stop sharing */
CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */
CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */
CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock
callback functions */
CURLSHOPT_LAST /* never use */
} CURLSHoption;
CURLSH *curl_share_init(void);
CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);
CURLSHcode curl_share_cleanup(CURLSH *);
/****************************************************************************
* Structures for querying information about the curl library at runtime.
@@ -965,4 +991,9 @@ curl_version_info_data *curl_version_info(CURLversion);
}
#endif
/* unfortunately, the easy.h and multi.h include files need options and info
stuff before they can be included! */
#include "easy.h" /* nothing in curl is fun without the easy stuff */
#include "multi.h"
#endif /* __CURL_CURL_H */

View File

@@ -5,4 +5,5 @@ Makefile
.deps
.libs
config.h
stamp-h1
stamp-*
ca-bundle.h

View File

@@ -66,7 +66,7 @@ getpass.c netrc.c telnet.h getinfo.c getinfo.h transfer.c strequal.c \
strequal.h easy.c security.h security.c krb4.c krb4.h memdebug.c \
memdebug.h inet_ntoa_r.h http_chunks.c http_chunks.h strtok.c strtok.h \
connect.c connect.h llist.c llist.h hash.c hash.h multi.c \
content_encoding.c content_encoding.h
content_encoding.c content_encoding.h share.h
noinst_HEADERS = setup.h transfer.h

View File

@@ -59,7 +59,11 @@ SOURCES = \
easy.c \
strequal.c \
strtok.c \
connect.c
connect.c \
hash.c \
llist.c \
multi.c \
content_encoding.c
OBJECTS = $(SOURCES:.c=.obj)

View File

@@ -28,4 +28,8 @@
+easy.obj &
+strequal.obj &
+strtok.obj &
+connect.obj
+connect.obj &
+hash.obj &
+llist.obj &
+multi.obj &
+content_encoding.obj

View File

@@ -116,7 +116,7 @@ CFGSET = TRUE
!IF "$(CFG)" == "debug-dll"
TARGET =$(LIB_NAME_DEBUG).dll
DIROBJ =.\$(CFG)
LNK = $(LNKDLL) /out:$(TARGET) /IMPLIB:"$(LIB_NAME_DEBUG).lib"
LNK = $(LNKDLL) /DEBUG /out:$(TARGET) /IMPLIB:"$(LIB_NAME_DEBUG).lib" /PDB:"$(LIB_NAME_DEBUG).pdb"
CC = $(CCDEBUG)
CFGSET = TRUE
!ENDIF
@@ -139,7 +139,8 @@ CFGSET = TRUE
!IF "$(CFG)" == "debug-ssl-dll"
TARGET =$(LIB_NAME_DEBUG).dll
DIROBJ =.\$(CFG)
LNK = $(LNKDLL) $(LFLAGSSSL) /out:$(TARGET) /IMPLIB:"$(LIB_NAME_DEBUG).lib"
LFLAGSSSL = /LIBPATH:$(OPENSSL_PATH)/out32dll
LNK = $(LNKDLL) $(LFLAGSSSL) /DEBUG /out:$(TARGET) /IMPLIB:"$(LIB_NAME_DEBUG).lib" /PDB:"$(LIB_NAME_DEBUG).pdb"
LINKLIBS = $(LINKLIBS) $(SSLLIBS)
CC = $(CCDEBUG) $(CFLAGSSSL)
CFGSET = TRUE

View File

@@ -61,6 +61,8 @@ static void decodeQuantum(unsigned char *dest, char *src)
x = (x << 6) + 62;
else if(src[i] == '/')
x = (x << 6) + 63;
else if(src[i] == '=')
x = (x << 6);
}
dest[2] = (unsigned char)(x & 255); x >>= 8;
@@ -78,6 +80,7 @@ static void base64Decode(unsigned char *dest, char *src, int *rawLength)
int length = 0;
int equalsTerm = 0;
int i;
int numQuantums;
unsigned char lastQuantum[3];
while((src[length] != '=') && src[length])
@@ -85,16 +88,18 @@ static void base64Decode(unsigned char *dest, char *src, int *rawLength)
while(src[length+equalsTerm] == '=')
equalsTerm++;
numQuantums = (length + equalsTerm) / 4;
if(rawLength)
*rawLength = (length * 3 / 4) - equalsTerm;
*rawLength = (numQuantums * 3) - equalsTerm;
for(i = 0; i < length/4 - 1; i++) {
for(i = 0; i < numQuantums - 1; i++) {
decodeQuantum(dest, src);
dest += 3; src += 4;
}
decodeQuantum(lastQuantum, src);
for(i = 0; i < 3 - equalsTerm; i++) dest[i] = lastQuantum[i];
for(i = 0; i < 3 - equalsTerm; i++)
dest[i] = lastQuantum[i];
}
@@ -194,20 +199,21 @@ int Curl_base64_decode(const char *str, void *data)
#define TEST_NEED_SUCK
void *suck(int *);
int main(int argc, char **argv, char **envp) {
char *base64;
int base64Len;
unsigned char *data;
int dataLen;
int main(int argc, char **argv, char **envp)
{
char *base64;
int base64Len;
unsigned char *data;
int dataLen;
data = (unsigned char *)suck(&dataLen);
base64Len = Curl_base64_encode(data, dataLen, &base64);
data = (unsigned char *)suck(&dataLen);
base64Len = Curl_base64_encode(data, dataLen, &base64);
fprintf(stderr, "%d\n", base64Len);
fprintf(stdout, "%s", base64);
free(base64); free(data);
return 0;
fprintf(stderr, "%d\n", base64Len);
fprintf(stdout, "%s", base64);
free(base64); free(data);
return 0;
}
#endif
@@ -220,47 +226,47 @@ int main(int argc, char **argv, char **envp) {
#define TEST_NEED_SUCK
void *suck(int *);
int main(int argc, char **argv, char **envp) {
char *base64;
int base64Len;
unsigned char *data;
int dataLen;
int main(int argc, char **argv, char **envp)
{
char *base64;
int base64Len;
unsigned char *data;
int dataLen;
base64 = (char *)suck(&base64Len);
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
dataLen = Curl_base64_decode(base64, data);
fprintf(stderr, "%d\n", dataLen);
fwrite(data,1,dataLen,stdout);
free(base64); free(data);
return 0;
base64 = (char *)suck(&base64Len);
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
dataLen = Curl_base64_decode(base64, data);
fprintf(stderr, "%d\n", dataLen);
fwrite(data,1,dataLen,stdout);
free(base64); free(data);
return 0;
}
#endif
#ifdef TEST_NEED_SUCK
/* this function 'sucks' in as much as possible from stdin */
void *suck(int *lenptr) {
int cursize = 8192;
unsigned char *buf = NULL;
int lastread;
int len = 0;
void *suck(int *lenptr)
{
int cursize = 8192;
unsigned char *buf = NULL;
int lastread;
int len = 0;
do {
cursize *= 2;
buf = (unsigned char *)realloc(buf, cursize);
memset(buf + len, 0, cursize - len);
lastread = fread(buf + len, 1, cursize - len, stdin);
len += lastread;
} while(!feof(stdin));
lenptr[0] = len;
return (void *)buf;
do {
cursize *= 2;
buf = (unsigned char *)realloc(buf, cursize);
memset(buf + len, 0, cursize - len);
lastread = fread(buf + len, 1, cursize - len, stdin);
len += lastread;
} while(!feof(stdin));
lenptr[0] = len;
return (void *)buf;
}
#endif
/*
* local variables:
* eval: (load-file "../curl-mode.el")

View File

@@ -176,10 +176,9 @@ int waitconnect(int sockfd, /* socket */
/* timeout, no connect today */
return 1;
if(FD_ISSET(sockfd, &errfd)) {
if(FD_ISSET(sockfd, &errfd))
/* error condition caught */
return 2;
}
/* we have a connect! */
return 0;
@@ -380,6 +379,11 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OPERATION_TIMEOUTED;
}
}
if(conn->bits.tcpconnect) {
/* we are connected already! */
*connected = TRUE;
return CURLE_OK;
}
/* check for connect without timeout as we want to return immediately */
rc = waitconnect(sockfd, 0);
@@ -646,6 +650,15 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
}
/* The '1 == rc' comes from the waitconnect(), and not from connect().
We can be sure of this since connect() cannot return 1. */
if((1 == rc) && (data->state.used_interface == Curl_if_multi)) {
/* Timeout when running the multi interface, we return here with a
CURLE_OK return code. */
rc = 0;
break;
}
if(0 == rc) {
int err = socketerror(sockfd);
if ((0 == err) || (EISCONN == err)) {
@@ -658,12 +671,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
if(0 != rc) {
if(data->state.used_interface == Curl_if_multi) {
/* When running the multi interface, we bail out here */
rc = 0;
break;
}
/* get a new timeout for next attempt */
after = Curl_tvnow();
timeout_ms -= Curl_tvdiff(after, before);

View File

@@ -31,19 +31,19 @@ RSC=rc.exe
!IF "$(CFG)" == "curllib - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /FR /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /D "_WINDLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /FR /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /FR /FD /GZ /c
# SUBTRACT CPP /WX /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

View File

@@ -233,15 +233,17 @@ CURLcode curl_easy_perform(CURL *curl)
{
struct SessionHandle *data = (struct SessionHandle *)curl;
if (!data->hostcache) {
if (Curl_global_host_cache_use(data)) {
data->hostcache = Curl_global_host_cache_get();
}
else {
data->hostcache = Curl_hash_alloc(7, Curl_freeaddrinfo);
if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) {
if (data->hostcache) {
Curl_hash_destroy(data->hostcache);
}
data->hostcache = Curl_global_host_cache_get();
}
if (!data->hostcache) {
data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
}
return Curl_perform(data);
}

View File

@@ -41,6 +41,7 @@ char *curl_escape(const char *string, int length)
{
int alloc = (length?length:(int)strlen(string))+1;
char *ns = malloc(alloc);
char *testing_ptr = NULL;
unsigned char in;
int newlen = alloc;
int index=0;
@@ -55,9 +56,14 @@ char *curl_escape(const char *string, int length)
newlen += 2; /* the size grows with two, since this'll become a %XX */
if(newlen > alloc) {
alloc *= 2;
ns = realloc(ns, alloc);
if(!ns)
testing_ptr = realloc(ns, alloc);
if(!testing_ptr) {
free( ns );
return NULL;
}
else {
ns = testing_ptr;
}
}
sprintf(&ns[index], "%%%02X", in);
@@ -80,6 +86,10 @@ char *curl_unescape(const char *string, int length)
unsigned char in;
int index=0;
unsigned int hex;
if( !ns ) {
return NULL;
}
while(--alloc > 0) {
in = *string;
@@ -97,7 +107,6 @@ char *curl_unescape(const char *string, int length)
}
ns[index]=0; /* terminate it */
return ns;
}
void curl_free(void *p)

View File

@@ -1319,7 +1319,7 @@ int Curl_FormReader(char *buffer,
wantedsize = size * nitems;
if(!form->data)
return -1; /* nothing, error, empty */
return 0; /* nothing, error, empty */
do {

247
lib/ftp.c
View File

@@ -173,9 +173,9 @@ static CURLcode AllowServerConnect(struct SessionHandle *data,
* response and extract the relevant return code for the invoking function.
*/
int Curl_GetFTPResponse(char *buf,
struct connectdata *conn,
int *ftpcode)
CURLcode Curl_GetFTPResponse(int *nreadp, /* return number of bytes read */
struct connectdata *conn,
int *ftpcode) /* return the ftp-code */
{
/* Brand new implementation.
* We cannot read just one byte per read() and then go back to select()
@@ -185,28 +185,21 @@ int Curl_GetFTPResponse(char *buf,
* line in a response or continue reading. */
int sockfd = conn->firstsocket;
int nread; /* total size read */
int perline; /* count bytes per line */
bool keepon=TRUE;
ssize_t gotbytes;
char *ptr;
int timeout = 3600; /* default timeout in seconds */
int timeout; /* timeout in seconds */
struct timeval interval;
fd_set rkeepfd;
fd_set readfd;
struct SessionHandle *data = conn->data;
char *line_start;
int code=0; /* default "error code" to return */
#define SELECT_OK 0
#define SELECT_ERROR 1 /* select() problems */
#define SELECT_TIMEOUT 2 /* took too long */
#define SELECT_MEMORY 3 /* no available memory */
#define SELECT_CALLBACK 4 /* aborted by callback */
int error = SELECT_OK;
int code=0; /* default ftp "error code" to return */
char *buf = data->state.buffer;
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->proto.ftp;
struct timeval now = Curl_tvnow();
if (ftpcode)
*ftpcode = 0; /* 0 for errors */
@@ -221,20 +214,25 @@ int Curl_GetFTPResponse(char *buf,
ptr=buf;
line_start = buf;
nread=0;
*nreadp=0;
perline=0;
keepon=TRUE;
while((nread<BUFSIZE) && (keepon && !error)) {
while((*nreadp<BUFSIZE) && (keepon && !result)) {
/* check and reset timeout value every lap */
if(data->set.timeout) {
if(data->set.timeout)
/* if timeout is requested, find out how much remaining time we have */
timeout = data->set.timeout - /* timeout time */
Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */
if(timeout <=0 ) {
failf(data, "Transfer aborted due to timeout");
return -SELECT_TIMEOUT; /* already too little time */
}
else
/* Even without a requested timeout, we only wait response_time
seconds for the full response to arrive before we bail out */
timeout = ftp->response_time -
Curl_tvdiff(Curl_tvnow(), now)/1000; /* spent time */
if(timeout <=0 ) {
failf(data, "Transfer aborted due to timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
if(!ftp->cache) {
@@ -244,19 +242,18 @@ int Curl_GetFTPResponse(char *buf,
switch (select (sockfd+1, &readfd, NULL, NULL, &interval)) {
case -1: /* select() error, stop reading */
error = SELECT_ERROR;
failf(data, "Transfer aborted due to select() error");
result = CURLE_RECV_ERROR;
failf(data, "Transfer aborted due to select() error: %d", errno);
break;
case 0: /* timeout */
error = SELECT_TIMEOUT;
result = CURLE_OPERATION_TIMEDOUT;
failf(data, "Transfer aborted due to timeout");
break;
default:
error = SELECT_OK;
break;
}
}
if(SELECT_OK == error) {
if(CURLE_OK == result) {
/*
* This code previously didn't use the kerberos sec_read() code
* to read, but when we use Curl_read() it may do so. Do confirm
@@ -272,8 +269,7 @@ int Curl_GetFTPResponse(char *buf,
ftp->cache_size = 0; /* zero the size just in case */
}
else {
int res = Curl_read(conn, sockfd, ptr,
BUFSIZE-nread, &gotbytes);
int res = Curl_read(conn, sockfd, ptr, BUFSIZE-*nreadp, &gotbytes);
if(res < 0)
/* EWOULDBLOCK */
continue; /* go looping again */
@@ -286,7 +282,7 @@ int Curl_GetFTPResponse(char *buf,
;
else if(gotbytes <= 0) {
keepon = FALSE;
error = SELECT_ERROR;
result = CURLE_RECV_ERROR;
failf(data, "Connection aborted");
}
else {
@@ -295,7 +291,7 @@ int Curl_GetFTPResponse(char *buf,
* line */
int i;
nread += gotbytes;
*nreadp += gotbytes;
for(i = 0; i < gotbytes; ptr++, i++) {
perline++;
if(*ptr=='\n') {
@@ -315,7 +311,7 @@ int Curl_GetFTPResponse(char *buf,
result = Curl_client_write(data, CLIENTWRITE_HEADER,
line_start, perline);
if(result)
return -SELECT_CALLBACK;
return result;
#define lastline(line) (isdigit((int)line[0]) && isdigit((int)line[1]) && \
isdigit((int)line[2]) && (' ' == line[3]))
@@ -350,13 +346,13 @@ int Curl_GetFTPResponse(char *buf,
if(ftp->cache)
memcpy(ftp->cache, line_start, ftp->cache_size);
else
return -SELECT_MEMORY; /**BANG**/
return CURLE_OUT_OF_MEMORY; /**BANG**/
}
} /* there was data */
} /* if(no error) */
} /* while there's buffer left and loop is requested */
if(!error)
if(!result)
code = atoi(buf);
#ifdef KRB4
@@ -378,13 +374,10 @@ int Curl_GetFTPResponse(char *buf,
}
#endif
if(error)
return -error;
if(ftpcode)
*ftpcode=code; /* return the initial number like this */
return nread; /* total amount of bytes read */
return result;
}
/*
@@ -417,6 +410,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* no need to duplicate them, the data struct won't change */
ftp->user = data->state.user;
ftp->passwd = data->state.passwd;
ftp->response_time = 3600; /* set default response time-out */
if (data->set.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
@@ -436,9 +430,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* The first thing we do is wait for the "220*" line: */
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode != 220) {
failf(data, "This doesn't seem like a nice ftp-server response");
@@ -467,9 +461,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
FTPSENDF(conn, "USER %s", ftp->user);
/* wait for feedback */
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode == 530) {
/* 530 User ... access denied
@@ -481,9 +475,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* 331 Password required for ...
(the server requires to send the user's password too) */
FTPSENDF(conn, "PASS %s", ftp->passwd);
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode == 530) {
/* 530 Login incorrect.
@@ -516,8 +510,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
/* we may need to issue a KAUTH here to have access to the files
* do it if user supplied a password
*/
if(data->state.passwd && *data->state.passwd)
Curl_krb_kauth(conn);
if(data->state.passwd && *data->state.passwd) {
result = Curl_krb_kauth(conn);
if(result)
return result;
}
#endif
}
else {
@@ -529,9 +526,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
FTPSENDF(conn, "PWD", NULL);
/* wait for feedback */
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode == 257) {
char *dir = (char *)malloc(nread+1);
@@ -544,7 +541,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
The directory name can contain any character; embedded double-quotes
should be escaped by double-quotes (the "quote-doubling" convention).
*/
if('\"' == *ptr) {
if(dir && ('\"' == *ptr)) {
/* it started good */
ptr++;
while(ptr && *ptr) {
@@ -570,6 +567,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
}
else {
/* couldn't get the path */
free(dir);
infof(data, "Failed to figure out path\n");
}
}
@@ -594,7 +593,6 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
struct SessionHandle *data = conn->data;
struct FTP *ftp = conn->proto.ftp;
ssize_t nread;
char *buf = data->state.buffer; /* this is our buffer */
int ftpcode;
CURLcode result=CURLE_OK;
@@ -633,11 +631,24 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
conn->secondarysocket = -1;
if(!ftp->no_transfer) {
/* now let's see what the server says about the transfer we just
performed: */
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
/* Let's see what the server says about the transfer we just performed,
but lower the timeout as sometimes this connection has died while
the data has been transfered. This happens when doing through NATs
etc that abandon old silent connections.
*/
ftp->response_time = 60; /* give it only a minute for now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
ftp->response_time = 3600; /* set this back to one hour waits */
if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) {
failf(data, "control connection looks dead");
return result;
}
if(result)
return result;
if(!ftp->dont_check) {
/* 226 Transfer complete, 250 Requested file action okay, completed. */
@@ -680,9 +691,9 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
if (item->data) {
FTPSENDF(conn, "%s", item->data);
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
if (nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if (result)
return result;
if (ftpcode >= 400) {
failf(conn->data, "QUOT string not accepted: %s", item->data);
@@ -711,9 +722,9 @@ CURLcode ftp_cwd(struct connectdata *conn, char *path)
CURLcode result;
FTPSENDF(conn, "CWD %s", path);
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
if (nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if (result)
return result;
if (ftpcode != 250) {
failf(conn->data, "Couldn't cd to %s", path);
@@ -741,26 +752,34 @@ CURLcode ftp_getfiletime(struct connectdata *conn, char *file)
again a grey area as the MDTM is not kosher RFC959 */
FTPSENDF(conn, "MDTM %s", file);
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode == 213) {
/* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
last .sss part is optional and means fractions of a second */
int year, month, day, hour, minute, second;
if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
&year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */
time_t secs=time(NULL);
sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
conn->data->info.filetime = curl_getdate(buf, &secs);
}
else {
infof(conn->data, "unsupported MDTM reply format\n");
switch(ftpcode) {
case 213:
{
/* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
last .sss part is optional and means fractions of a second */
int year, month, day, hour, minute, second;
if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
&year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */
time_t secs=time(NULL);
sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
conn->data->info.filetime = curl_getdate(buf, &secs);
}
}
break;
default:
infof(conn->data, "unsupported MDTM reply format\n");
break;
case 550: /* "No such file or directory" */
failf(conn->data, "Given file does not exist");
result = CURLE_FTP_COULDNT_RETR_FILE;
break;
}
return result;
}
@@ -778,14 +797,13 @@ static CURLcode ftp_transfertype(struct connectdata *conn,
struct SessionHandle *data = conn->data;
int ftpcode;
ssize_t nread;
char *buf=data->state.buffer;
CURLcode result;
FTPSENDF(conn, "TYPE %s", ascii?"A":"I");
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode != 200) {
failf(data, "Couldn't set %s mode",
@@ -814,9 +832,9 @@ CURLcode ftp_getsize(struct connectdata *conn, char *file,
CURLcode result;
FTPSENDF(conn, "SIZE %s", file);
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode == 213) {
/* get the size from the ascii string: */
@@ -975,7 +993,6 @@ CURLcode ftp_use_port(struct connectdata *conn)
struct SessionHandle *data=conn->data;
int portsock=-1;
ssize_t nread;
char *buf = data->state.buffer; /* this is our buffer */
int ftpcode; /* receive FTP response codes in this */
CURLcode result;
@@ -1155,9 +1172,9 @@ CURLcode ftp_use_port(struct connectdata *conn)
return result;
}
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if (ftpcode != 200) {
failf(data, "Server does not grok %s", *modep);
@@ -1301,9 +1318,9 @@ CURLcode ftp_use_port(struct connectdata *conn)
return result;
}
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode != 200) {
failf(data, "Server does not grok PORT, try without it!");
@@ -1375,9 +1392,9 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
result = Curl_ftpsendf(conn, "%s", mode[modeoff]);
if(result)
return result;
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if (ftpcode == results[modeoff])
break;
}
@@ -1522,7 +1539,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
ssize_t nread;
int ftpcode; /* for ftp status */
/* the ftp struct is already inited in ftp_connect() */
/* the ftp struct is already inited in Curl_ftp_connect() */
struct FTP *ftp = conn->proto.ftp;
long *bytecountp = ftp->bytecountp;
@@ -1582,8 +1599,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
readthisamountnow = BUFSIZE;
actuallyread =
data->set.fread(data->state.buffer, 1, readthisamountnow,
data->set.in);
conn->fread(data->state.buffer, 1, readthisamountnow,
conn->fread_in);
passed += actuallyread;
if(actuallyread != readthisamountnow) {
@@ -1614,7 +1631,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
}
}
/* Send everything on data->set.in to the socket */
/* Send everything on data->state.in to the socket */
if(data->set.ftp_append) {
/* we append onto the file instead of rewriting it */
FTPSENDF(conn, "APPE %s", ftp->file);
@@ -1623,9 +1640,9 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
FTPSENDF(conn, "STOR %s", ftp->file);
}
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode>=400) {
failf(data, "Failed FTP upload:%s", buf+3);
@@ -1799,9 +1816,9 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
FTPSENDF(conn, "REST %d", conn->resume_from);
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if(ftpcode != 350) {
failf(data, "Couldn't use REST: %s", buf+4);
@@ -1812,9 +1829,9 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
FTPSENDF(conn, "RETR %s", ftp->file);
}
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
if(nread < 0)
return CURLE_OPERATION_TIMEOUTED;
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
return result;
if((ftpcode == 150) || (ftpcode == 125)) {
@@ -1919,7 +1936,7 @@ CURLcode ftp_perform(struct connectdata *conn,
struct SessionHandle *data=conn->data;
char *buf = data->state.buffer; /* this is our buffer */
/* the ftp struct is already inited in ftp_connect() */
/* the ftp struct is already inited in Curl_ftp_connect() */
struct FTP *ftp = conn->proto.ftp;
/* Send any QUOTE strings? */
@@ -1980,7 +1997,7 @@ CURLcode ftp_perform(struct connectdata *conn,
well, we "emulate" a HTTP-style header in our output. */
#ifdef HAVE_STRFTIME
if(data->set.get_filetime && data->info.filetime) {
if(data->set.get_filetime && (data->info.filetime>=0) ) {
struct tm *tm;
#ifdef HAVE_LOCALTIME_R
struct tm buffer;

View File

@@ -29,8 +29,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn);
CURLcode Curl_ftp_connect(struct connectdata *conn);
CURLcode Curl_ftp_disconnect(struct connectdata *conn);
CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
int Curl_GetFTPResponse(char *buf, struct connectdata *conn,
int *ftpcode);
CURLcode Curl_GetFTPResponse(int *nread, struct connectdata *conn,
int *ftpcode);
CURLcode Curl_ftp_nextconnect(struct connectdata *conn);
#endif

View File

@@ -158,6 +158,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
case CURLINFO_CONTENT_TYPE:
*param_charp = data->info.contenttype;
break;
case CURLINFO_PRIVATE:
*param_charp = data->set.private?data->set.private:(char *)"";
break;
default:
return CURLE_BAD_FUNCTION_ARGUMENT;
}

View File

@@ -88,7 +88,7 @@ static Curl_addrinfo *my_getaddrinfo(struct SessionHandle *data,
void Curl_global_host_cache_init(void)
{
if (!host_cache_initialized) {
Curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo);
Curl_hash_init(&hostname_cache, 7, Curl_freednsinfo);
host_cache_initialized = 1;
}
}
@@ -287,17 +287,25 @@ struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
/*
* This is a wrapper function for freeing name information in a protocol
* independent way. This takes care of using the appropriate underlaying
* proper function.
* function.
*/
void Curl_freeaddrinfo(void *freethis)
void Curl_freeaddrinfo(Curl_addrinfo *p)
{
#ifdef ENABLE_IPV6
freeaddrinfo(p);
#else
free(p);
#endif
}
/*
* Free a cache dns entry.
*/
void Curl_freednsinfo(void *freethis)
{
struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis;
#ifdef ENABLE_IPV6
freeaddrinfo(p->addr);
#else
free(p->addr);
#endif
Curl_freeaddrinfo(p->addr);
free(p);
}
@@ -623,16 +631,28 @@ static Curl_addrinfo *my_getaddrinfo(struct SessionHandle *data,
&h, /* DIFFERENCE */
&h_errnop);
/* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
sudden this function seems to be setting EAGAIN if the given buffer
size is too small. Previous versions are known to return ERANGE for
the same. */
sudden this function returns EAGAIN if the given buffer size is too
small. Previous versions are known to return ERANGE for the same
problem.
This wouldn't be such a big problem if older versions wouldn't
sometimes return EAGAIN on a common failure case. Alas, we can't
assume that EAGAIN *or* ERANGE means ERANGE for any given version of
glibc.
For now, we do that and thus we may call the function repeatedly and
fail for older glibc versions that return EAGAIN, until we run out
of buffer size (step_size grows beyond CURL_NAMELOOKUP_SIZE).
If anyone has a better fix, please tell us!
*/
if((ERANGE == res) || (EAGAIN == res)) {
step_size+=200;
continue;
}
break;
} while(1);
} while(step_size <= CURL_NAMELOOKUP_SIZE);
if(!h) /* failure */
res=1;

View File

@@ -65,7 +65,10 @@ struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
void Curl_scan_cache_used(void *user, void *ptr);
/* free name info */
void Curl_freeaddrinfo(void *freethis);
void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
/* free cached name info */
void Curl_freednsinfo(void *freethis);
#ifdef MALLOCDEBUG
void curl_freeaddrinfo(struct addrinfo *freethis,

View File

@@ -98,12 +98,65 @@
#include "memdebug.h"
#endif
/* fread() emulation to provide POST and/or request data */
static int readmoredata(char *buffer,
size_t size,
size_t nitems,
void *userp)
{
struct connectdata *conn = (struct connectdata *)userp;
struct HTTP *http = conn->proto.http;
int fullsize = size * nitems;
if(0 == http->postsize)
/* nothing to return */
return 0;
/* make sure that a HTTP request is never sent away chunked! */
conn->bits.forbidchunk= (http->sending == HTTPSEND_REQUEST)?TRUE:FALSE;
if(http->postsize <= fullsize) {
memcpy(buffer, http->postdata, http->postsize);
fullsize = http->postsize;
if(http->backup.postsize) {
/* move backup data into focus and continue on that */
http->postdata = http->backup.postdata;
http->postsize = http->backup.postsize;
conn->fread = http->backup.fread;
conn->fread_in = http->backup.fread_in;
http->sending++; /* move one step up */
http->backup.postsize=0;
}
else
http->postsize = 0;
return fullsize;
}
memcpy(buffer, http->postdata, fullsize);
http->postdata += fullsize;
http->postsize -= fullsize;
return fullsize;
}
/* ------------------------------------------------------------------------- */
/*
* The add_buffer series of functions are used to build one large memory chunk
* from repeated function invokes. Used so that the entire HTTP request can
* be sent in one go.
*/
struct send_buffer {
char *buffer;
size_t size_max;
size_t size_used;
};
typedef struct send_buffer send_buffer;
static CURLcode
add_buffer(send_buffer *in, const void *inptr, size_t size);
@@ -126,44 +179,66 @@ send_buffer *add_buffer_init(void)
* add_buffer_send() sends a buffer and frees all associated memory.
*/
static
CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
long *bytes_written)
CURLcode add_buffer_send(send_buffer *in,
int sockfd,
struct connectdata *conn,
long *bytes_written) /* add the number of sent
bytes to this counter */
{
ssize_t amount;
CURLcode res;
char *ptr;
int size;
struct HTTP *http = conn->proto.http;
/* The looping below is required since we use non-blocking sockets, but due
to the circumstances we will just loop and try again and again etc */
ptr = in->buffer;
size = in->size_used;
do {
res = Curl_write(conn, sockfd, ptr, size, &amount);
if(CURLE_OK != res)
break;
res = Curl_write(conn, sockfd, ptr, size, &amount);
if(CURLE_OK == res) {
if(conn->data->set.verbose)
/* this data _may_ contain binary stuff */
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, amount);
*bytes_written += amount;
if(amount != size) {
/* The whole request could not be sent in one system call. We must queue
it up and send it later when we get the chance. We must not loop here
and wait until it might work again. */
size -= amount;
ptr += amount;
/* backup the currently set pointers */
http->backup.fread = conn->fread;
http->backup.fread_in = conn->fread_in;
http->backup.postdata = http->postdata;
http->backup.postsize = http->postsize;
/* set the new pointers for the request-sending */
conn->fread = (curl_read_callback)readmoredata;
conn->fread_in = (void *)conn;
http->postdata = ptr;
http->postsize = size;
http->send_buffer = in;
http->sending = HTTPSEND_REQUEST;
return CURLE_OK;
}
else
break;
} while(1);
/* the full buffer was sent, clean up and return */
}
if(in->buffer)
free(in->buffer);
free(in);
*bytes_written += amount;
return res;
}
@@ -223,21 +298,75 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
/* end of the add_buffer functions */
/* ------------------------------------------------------------------------- */
/*
* Curl_compareheader()
*
* Returns TRUE if 'headerline' contains the 'header' with given 'content'.
* Pass headers WITH the colon.
*/
bool
Curl_compareheader(char *headerline, /* line to check */
const char *header, /* header keyword _with_ colon */
const char *content) /* content string to find */
{
/* RFC2616, section 4.2 says: "Each header field consists of a name followed
* by a colon (":") and the field value. Field names are case-insensitive.
* The field value MAY be preceded by any amount of LWS, though a single SP
* is preferred." */
size_t hlen = strlen(header);
size_t clen;
size_t len;
char *start;
char *end;
if(!strnequal(headerline, header, hlen))
return FALSE; /* doesn't start with header */
/* pass the header */
start = &headerline[hlen];
/* pass all white spaces */
while(*start && isspace((int)*start))
start++;
/* find the end of the header line */
end = strchr(start, '\r'); /* lines end with CRLF */
if(!end) {
/* in case there's a non-standard compliant line here */
end = strchr(start, '\n');
if(!end)
/* hm, there's no line ending here, use the zero byte! */
end = strchr(start, '\0');
}
len = end-start; /* length of the content part of the input line */
clen = strlen(content); /* length of the word to find */
/* find the content string in the rest of the line */
for(;len>=clen;len--, start++) {
if(strnequal(start, content, clen))
return TRUE; /* match! */
}
return FALSE; /* no match */
}
/*
* This function checks the linked list of custom HTTP headers for a particular
* header (prefix).
*/
static bool checkheaders(struct SessionHandle *data, const char *thisheader)
static char *checkheaders(struct SessionHandle *data, const char *thisheader)
{
struct curl_slist *head;
size_t thislen = strlen(thisheader);
for(head = data->set.headers; head; head=head->next) {
if(strnequal(head->data, thisheader, thislen)) {
return TRUE;
}
if(strnequal(head->data, thisheader, thislen))
return head->data;
}
return FALSE;
return NULL;
}
/*
@@ -440,6 +569,10 @@ CURLcode Curl_http_connect(struct connectdata *conn)
if(conn->bits.user_passwd && !data->state.this_is_a_follow) {
/* Authorization: is requested, this is not a followed location, get the
original host name */
if (data->state.auth_host)
/* Free to avoid leaking memory on multiple requests*/
free(data->state.auth_host);
data->state.auth_host = strdup(conn->hostname);
}
@@ -454,13 +587,21 @@ CURLcode Curl_http_done(struct connectdata *conn)
data=conn->data;
http=conn->proto.http;
/* set the proper values (possibly modified on POST) */
conn->fread = data->set.fread; /* restore */
conn->fread_in = data->set.in; /* restore */
if(http->send_buffer) {
send_buffer *buff = http->send_buffer;
free(buff->buffer);
free(buff);
}
if(HTTPREQ_POST_FORM == data->set.httpreq) {
conn->bytecount = http->readbytecount + http->writebytecount;
Curl_formclean(http->sendit); /* Now free that whole lot */
data->set.fread = http->storefread; /* restore */
data->set.in = http->in; /* restore */
}
else if(HTTPREQ_PUT == data->set.httpreq)
conn->bytecount = http->readbytecount + http->writebytecount;
@@ -475,7 +616,6 @@ CURLcode Curl_http_done(struct connectdata *conn)
return CURLE_OK;
}
CURLcode Curl_http(struct connectdata *conn)
{
struct SessionHandle *data=conn->data;
@@ -523,7 +663,7 @@ CURLcode Curl_http(struct connectdata *conn)
host due to a location-follow, we do some weirdo checks here */
if(!data->state.this_is_a_follow ||
!data->state.auth_host ||
strequal(data->state.auth_host, conn->hostname)) {
curl_strequal(data->state.auth_host, conn->hostname)) {
sprintf(data->state.buffer, "%s:%s",
data->state.user, data->state.passwd);
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
@@ -547,12 +687,30 @@ CURLcode Curl_http(struct connectdata *conn)
conn->allocptr.cookie = aprintf("Cookie: %s\015\012", data->set.cookie);
}
if(!conn->bits.upload_chunky && (data->set.httpreq != HTTPREQ_GET)) {
/* not a chunky transfer but data is to be sent */
char *ptr = checkheaders(data, "Transfer-Encoding:");
if(ptr) {
/* Some kind of TE is requested, check if 'chunked' is chosen */
if(Curl_compareheader(ptr, "Transfer-Encoding:", "chunked"))
/* we have been told explicitly to upload chunky so deal with it! */
conn->bits.upload_chunky = TRUE;
}
}
if(conn->bits.upload_chunky) {
/* RFC2616 section 4.4:
Messages MUST NOT include both a Content-Length header field and a
non-identity transfer-coding. If the message does include a non-
identity transfer-coding, the Content-Length MUST be ignored. */
if(!checkheaders(data, "Transfer-Encoding:")) {
te = "Transfer-Encoding: chunked\r\n";
}
/* else
our header was already added, what to do now? */
else {
/* The "Transfer-Encoding:" header was already added. */
te = "";
}
}
if(data->cookies) {
@@ -847,16 +1005,16 @@ CURLcode Curl_http(struct connectdata *conn)
return CURLE_HTTP_POST_ERROR;
}
http->storefread = data->set.fread; /* backup */
http->in = data->set.in; /* backup */
data->set.fread = (curl_read_callback)
Curl_FormReader; /* set the read function to read from the
generated form data */
data->set.in = (FILE *)&http->form;
/* set the read function to read from the generated form data */
conn->fread = (curl_read_callback)Curl_FormReader;
conn->fread_in = &http->form;
add_bufferf(req_buffer,
"Content-Length: %d\r\n", http->postsize);
http->sending = HTTPSEND_BODY;
if(!conn->bits.upload_chunky)
/* only add Content-Length if not uploading chunked */
add_bufferf(req_buffer,
"Content-Length: %d\r\n", http->postsize);
if(!checkheaders(data, "Expect:")) {
/* if not disabled explicitly we add a Expect: 100-continue
@@ -896,7 +1054,7 @@ CURLcode Curl_http(struct connectdata *conn)
Curl_pgrsSetUploadSize(data, http->postsize);
/* fire away the whole request to the server */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
result = add_buffer_send(req_buffer, conn->firstsocket, conn,
&data->info.request_size);
if(result)
failf(data, "Failed sending POST request");
@@ -914,22 +1072,22 @@ CURLcode Curl_http(struct connectdata *conn)
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
if(data->set.infilesize>0) {
if((data->set.infilesize>0) && !conn->bits.upload_chunky)
/* only add Content-Length if not uploading chunked */
add_bufferf(req_buffer,
"Content-Length: %d\r\n\r\n", /* file size */
"Content-Length: %d\r\n", /* file size */
data->set.infilesize );
}
else
add_bufferf(req_buffer, "\015\012");
add_bufferf(req_buffer, "\r\n");
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, data->set.infilesize);
/* this sends the buffer and frees all the buffer resources */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
result = add_buffer_send(req_buffer, conn->firstsocket, conn,
&data->info.request_size);
if(result)
failf(data, "Faied sending POST request");
failf(data, "Failed sending POST request");
else
/* prepare for transfer */
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
@@ -943,14 +1101,20 @@ CURLcode Curl_http(struct connectdata *conn)
case HTTPREQ_POST:
/* this is the simple POST, using x-www-form-urlencoded style */
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
data->set.postfieldsize?
data->set.postfieldsize:
(data->set.postfields?strlen(data->set.postfields):0) );
if(!conn->bits.upload_chunky) {
/* We only set Content-Length and allow a custom Content-Length if
we don't upload data chunked, as RFC2616 forbids us to set both
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
data->set.postfieldsize?
data->set.postfieldsize:
(data->set.postfields?strlen(data->set.postfields):0) );
}
if(!checkheaders(data, "Content-Type:"))
add_bufferf(req_buffer,
@@ -958,18 +1122,28 @@ CURLcode Curl_http(struct connectdata *conn)
add_buffer(req_buffer, "\r\n", 2);
/* and here comes the actual data */
if(data->set.postfieldsize && data->set.postfields) {
add_buffer(req_buffer, data->set.postfields,
data->set.postfieldsize);
}
else if(data->set.postfields)
add_bufferf(req_buffer,
"%s",
data->set.postfields );
/* and here we setup the pointers to the actual data */
if(data->set.postfields) {
if(data->set.postfieldsize)
http->postsize = data->set.postfieldsize;
else
http->postsize = strlen(data->set.postfields);
http->postdata = data->set.postfields;
/* issue the request */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
http->sending = HTTPSEND_BODY;
conn->fread = (curl_read_callback)readmoredata;
conn->fread_in = (void *)conn;
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, http->postsize);
}
else
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, data->set.infilesize);
/* issue the request, headers-only */
result = add_buffer_send(req_buffer, conn->firstsocket, conn,
&data->info.request_size);
if(result)
@@ -978,15 +1152,15 @@ CURLcode Curl_http(struct connectdata *conn)
result =
Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
&http->readbytecount,
data->set.postfields?-1:conn->firstsocket,
data->set.postfields?NULL:&http->writebytecount);
conn->firstsocket,
&http->writebytecount);
break;
default:
add_buffer(req_buffer, "\r\n", 2);
/* issue the request */
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
result = add_buffer_send(req_buffer, conn->firstsocket, conn,
&data->info.request_size);
if(result)
@@ -995,7 +1169,8 @@ CURLcode Curl_http(struct connectdata *conn)
/* HTTP GET/HEAD download: */
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
&http->readbytecount,
-1, NULL); /* nothing to upload */
http->postdata?conn->firstsocket:-1,
http->postdata?&http->writebytecount:NULL);
}
if(result)
return result;

View File

@@ -24,6 +24,10 @@
* $Id$
***************************************************************************/
#ifndef CURL_DISABLE_HTTP
bool Curl_compareheader(char *headerline, /* line to check */
const char *header, /* header keyword _with_ colon */
const char *content); /* content string to find */
/* ftp can use this as well */
CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
int tunnelsocket,

View File

@@ -29,5 +29,40 @@ extern char *Curl_if2ip(char *interface, char *buf, int buf_size);
#else
#define Curl_if2ip(a,b,c) NULL
#endif
#ifdef __INTERIX
/* Nedelcho Stanev's work-around for SFU 3.0 */
struct ifreq {
#define IFNAMSIZ 16
#define IFHWADDRLEN 6
union {
char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
} ifr_ifrn;
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_metric;
int ifru_mtu;
} ifr_ifru;
};
/* This define was added by Daniel to avoid an extra #ifdef INTERIX in the
C code. */
#define ifr_dstaddr ifr_addr
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */
#endif /* interix */
#endif

View File

@@ -202,6 +202,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
ssize_t nread;
int l = sizeof(conn->local_addr);
struct SessionHandle *data = conn->data;
CURLcode result;
if(getsockname(conn->firstsocket,
(struct sockaddr *)LOCAL_ADDR, &l) < 0)
@@ -246,13 +247,15 @@ krb4_auth(void *app_data, struct connectdata *conn)
return AUTH_CONTINUE;
}
if(Curl_ftpsendf(conn, "ADAT %s", p))
result = Curl_ftpsendf(conn, "ADAT %s", p);
free(p);
if(result)
return -2;
nread = Curl_GetFTPResponse(data->state.buffer, conn, NULL);
if(nread < 0)
if(Curl_GetFTPResponse(&nread, conn, NULL))
return -1;
free(p);
if(data->state.buffer[0] != '2'){
Curl_failf(data, "Server didn't accept auth data");
@@ -299,7 +302,7 @@ struct Curl_sec_client_mech Curl_krb4_client_mech = {
krb4_decode
};
void Curl_krb_kauth(struct connectdata *conn)
CURLcode Curl_krb_kauth(struct connectdata *conn)
{
des_cblock key;
des_key_schedule schedule;
@@ -309,18 +312,19 @@ void Curl_krb_kauth(struct connectdata *conn)
char passwd[100];
int tmp;
ssize_t nread;
int save;
CURLcode result;
save = Curl_set_command_prot(conn, prot_private);
if(Curl_ftpsendf(conn, "SITE KAUTH %s", conn->data->state.user))
return;
result = Curl_ftpsendf(conn, "SITE KAUTH %s", conn->data->state.user);
nread = Curl_GetFTPResponse(conn->data->state.buffer,
conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;
if(result)
return result;
result = Curl_GetFTPResponse(&nread, conn, NULL);
if(result)
return result;
if(conn->data->state.buffer[0] != '3'){
Curl_set_command_prot(conn, save);
@@ -331,7 +335,7 @@ void Curl_krb_kauth(struct connectdata *conn)
if(!p) {
Curl_failf(conn->data, "Bad reply from server");
Curl_set_command_prot(conn, save);
return;
return CURLE_FTP_WEIRD_SERVER_REPLY;
}
p += 2;
@@ -339,7 +343,7 @@ void Curl_krb_kauth(struct connectdata *conn)
if(tmp < 0) {
Curl_failf(conn->data, "Failed to decode base64 in reply.\n");
Curl_set_command_prot(conn, save);
return;
return CURLE_FTP_WEIRD_SERVER_REPLY;
}
tkt.length = tmp;
tktcopy.length = tkt.length;
@@ -348,7 +352,7 @@ void Curl_krb_kauth(struct connectdata *conn)
if(!p) {
Curl_failf(conn->data, "Bad reply from server");
Curl_set_command_prot(conn, save);
return;
return CURLE_FTP_WEIRD_SERVER_REPLY;
}
name = p + 2;
for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++);
@@ -376,19 +380,21 @@ void Curl_krb_kauth(struct connectdata *conn)
if(Curl_base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) {
failf(conn->data, "Out of memory base64-encoding.");
Curl_set_command_prot(conn, save);
return;
return CURLE_OUT_OF_MEMORY;
}
memset (tktcopy.dat, 0, tktcopy.length);
if(Curl_ftpsendf(conn, "SITE KAUTH %s %s", name, p))
return;
nread = Curl_GetFTPResponse(conn->data->state.buffer,
conn, NULL);
if(nread < 0)
return /*CURLE_OPERATION_TIMEOUTED*/;
result = Curl_ftpsendf(conn, "SITE KAUTH %s %s", name, p);
free(p);
if(result)
return result;
result = Curl_GetFTPResponse(&nread, conn, NULL);
if(result)
return result;
Curl_set_command_prot(conn, save);
return CURLE_OK;
}
#endif /* KRB4 */

View File

@@ -22,6 +22,6 @@
*
* $Id$
***************************************************************************/
void Curl_krb_kauth(struct connectdata *conn);
CURLcode Curl_krb_kauth(struct connectdata *conn);
#endif

View File

@@ -313,9 +313,8 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
easy->easy_handle->hostcache = Curl_global_host_cache_get();
}
else {
if (multi->hostcache == NULL) {
multi->hostcache = Curl_hash_alloc(7, Curl_freeaddrinfo);
}
if (multi->hostcache == NULL)
multi->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
easy->easy_handle->hostcache = multi->hostcache;
}

View File

@@ -278,32 +278,6 @@ Curl_sec_write(struct connectdata *conn, int fd, char *buffer, int length)
return tx;
}
int
Curl_sec_vfprintf2(struct connectdata *conn, FILE *f, const char *fmt, va_list ap)
{
char *buf;
int ret;
if(conn->data_prot == prot_clear)
return vfprintf(f, fmt, ap);
else {
buf = aprintf(fmt, ap);
ret = buffer_write(&conn->out_buffer, buf, strlen(buf));
free(buf);
return ret;
}
}
int
Curl_sec_fprintf2(struct connectdata *conn, FILE *f, const char *fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = Curl_sec_vfprintf2(conn, f, fmt, ap);
va_end(ap);
return ret;
}
int
Curl_sec_putc(struct connectdata *conn, int c, FILE *F)
{
@@ -313,7 +287,8 @@ Curl_sec_putc(struct connectdata *conn, int c, FILE *F)
buffer_write(&conn->out_buffer, &ch, 1);
if(c == '\n' || conn->out_buffer.index >= 1024 /* XXX */) {
Curl_sec_write(conn, fileno(F), conn->out_buffer.data, conn->out_buffer.index);
Curl_sec_write(conn, fileno(F), conn->out_buffer.data,
conn->out_buffer.index);
conn->out_buffer.index = 0;
}
return c;
@@ -346,53 +321,6 @@ Curl_sec_read_msg(struct connectdata *conn, char *s, int level)
return code;
}
/* modified to return how many bytes written, or -1 on error ***/
int
Curl_sec_vfprintf(struct connectdata *conn, FILE *f, const char *fmt, va_list ap)
{
int ret = 0;
char *buf;
void *enc;
int len;
if(!conn->sec_complete)
return vfprintf(f, fmt, ap);
buf = aprintf(fmt, ap);
len = (conn->mech->encode)(conn->app_data, buf, strlen(buf),
conn->command_prot, &enc,
conn);
free(buf);
if(len < 0) {
failf(conn->data, "Failed to encode command.");
return -1;
}
if(Curl_base64_encode(enc, len, &buf) < 0){
failf(conn->data, "Out of memory base64-encoding.");
return -1;
}
if(conn->command_prot == prot_safe)
ret = fprintf(f, "MIC %s", buf);
else if(conn->command_prot == prot_private)
ret = fprintf(f, "ENC %s", buf);
else if(conn->command_prot == prot_confidential)
ret = fprintf(f, "CONF %s", buf);
free(buf);
return ret;
}
int
Curl_sec_fprintf(struct connectdata *conn, FILE *f, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = Curl_sec_vfprintf(conn, f, fmt, ap);
va_end(ap);
return ret;
}
enum protection_level
Curl_set_command_prot(struct connectdata *conn, enum protection_level level)
{
@@ -414,14 +342,14 @@ sec_prot_internal(struct connectdata *conn, int level)
}
if(level){
int code;
if(Curl_ftpsendf(conn, "PBSZ %u", s))
return -1;
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
if(nread < 0)
if(Curl_GetFTPResponse(&nread, conn, &code))
return -1;
if(conn->data->state.buffer[0] != '2'){
if(code/100 != '2'){
failf(conn->data, "Failed to set protection buffer size.");
return -1;
}
@@ -437,8 +365,7 @@ sec_prot_internal(struct connectdata *conn, int level)
if(Curl_ftpsendf(conn, "PROT %c", level["CSEP"]))
return -1;
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
if(nread < 0)
if(Curl_GetFTPResponse(&nread, conn, NULL))
return -1;
if(conn->data->state.buffer[0] != '2'){
@@ -496,8 +423,7 @@ Curl_sec_login(struct connectdata *conn)
if(Curl_ftpsendf(conn, "AUTH %s", (*m)->name))
return -1;
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
if(nread < 0)
if(Curl_GetFTPResponse(&nread, conn, &ftpcode))
return -1;
if(conn->data->state.buffer[0] != '3'){

View File

@@ -154,9 +154,19 @@ void Curl_failf(struct SessionHandle *data, const char *fmt, ...)
vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap);
data->state.errorbuf = TRUE; /* wrote error string */
if(data->set.verbose)
Curl_debug(data, CURLINFO_TEXT, data->set.errorbuffer,
strlen(data->set.errorbuffer));
if(data->set.verbose) {
int len = strlen(data->set.errorbuffer);
bool doneit=FALSE;
if(len < CURL_ERROR_SIZE) {
doneit = TRUE;
data->set.errorbuffer[len] = '\n';
data->set.errorbuffer[++len] = '\0';
}
Curl_debug(data, CURLINFO_TEXT, data->set.errorbuffer, len);
if(doneit)
/* cut off the newline again */
data->set.errorbuffer[--len]=0;
}
}
va_end(ap);
}
@@ -235,6 +245,9 @@ CURLcode Curl_write(struct connectdata *conn, int sockfd,
/* this is basicly the EWOULDBLOCK equivalent */
*written = 0;
return CURLE_OK;
case SSL_ERROR_SYSCALL:
failf(conn->data, "SSL_write() returned SYSCALL, errno = %d\n", errno);
return CURLE_SEND_ERROR;
}
/* a true error */
failf(conn->data, "SSL_write() return error %d\n", err);
@@ -328,36 +341,29 @@ int Curl_read(struct connectdata *conn,
ssize_t *n)
{
ssize_t nread;
*n=0; /* reset amount to zero */
#ifdef USE_SSLEAY
if (conn->ssl.use) {
bool loop=TRUE;
int err;
do {
nread = SSL_read(conn->ssl.handle, buf, buffersize);
nread = SSL_read(conn->ssl.handle, buf, buffersize);
if(nread >= 0)
/* successful read */
break;
err = SSL_get_error(conn->ssl.handle, nread);
if(nread < 0) {
/* failed SSL_read */
int err = SSL_get_error(conn->ssl.handle, nread);
switch(err) {
case SSL_ERROR_NONE: /* this is not an error */
case SSL_ERROR_ZERO_RETURN: /* no more data */
loop=0; /* get out of loop */
break;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
/* if there's data pending, then we re-invoke SSL_read() */
break;
/* there's data pending, re-invoke SSL_read() */
return -1; /* basicly EWOULDBLOCK */
default:
failf(conn->data, "SSL read error: %d", err);
return CURLE_RECV_ERROR;
}
} while(loop);
if(loop && SSL_pending(conn->ssl.handle))
return -1; /* basicly EWOULDBLOCK */
}
}
else {
#endif

View File

@@ -30,13 +30,6 @@ void Curl_failf(struct SessionHandle *, const char *fmt, ...);
#define infof Curl_infof
#define failf Curl_failf
struct send_buffer {
char *buffer;
size_t size_max;
size_t size_used;
};
typedef struct send_buffer send_buffer;
#define CLIENTWRITE_BODY 1
#define CLIENTWRITE_HEADER 2
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)

View File

@@ -35,9 +35,8 @@
#define CURL_DISABLE_GOPHER
#endif
#if !defined(WIN32) && defined(_WIN32)
/* This _might_ be a good Borland fix. Please report whether this works or
not! */
#if !defined(WIN32) && defined(__WIN32__)
/* This should be a good Borland fix. Alexander J. Oss told us! */
#define WIN32
#endif

View File

@@ -24,142 +24,123 @@
#include "setup.h"
#include <stdlib.h>
#include <curl/curl.h>
#include "share.h"
#include "urldata.h"
#include "share.h"
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
#define CURL_SHARE_SET_LOCKED(__share, __type) ((__share)->locked += (__type))
#define CURL_SHARE_SET_UNLOCKED(__share, __type) ((__share)->locked -= (__type))
#define CURL_SHARE_SET_USED(__share, __type) ((__share)->specifier += (__type))
#define CURL_SHARE_SET_UNUSED(__share, __type) ((__share)->specifier -= (__type))
#define CURL_SHARE_IS_USED(__share, __type) ((__share)->specifier & (__type))
#define CURL_SHARE_IS_LOCKED(__share, __type) ((__share)->locked & (__type))
#define CURL_SHARE_IS_DIRTY(__share) ((__share)->dirty)
#define CURL_SHARE_GET(__handle) (((struct SessionHandle *) (__handle))->share)
curl_share *
curl_share_init (void)
CURLSH *
curl_share_init(void)
{
curl_share *share = (curl_share *) malloc (sizeof (curl_share));
if (share) {
memset (share, 0, sizeof (curl_share));
}
struct Curl_share *share =
(struct Curl_share *)malloc(sizeof(struct Curl_share));
if (share)
memset (share, 0, sizeof(struct Curl_share));
return share;
}
CURLcode
curl_share_setopt (curl_share *share, curl_lock_type option, int enable)
CURLSHcode
curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
{
if (CURL_SHARE_IS_DIRTY(share)) {
return CURLE_SHARE_IN_USE;
struct Curl_share *share = (struct Curl_share *)sh;
va_list param;
int type;
curl_lock_function lockfunc;
curl_unlock_function unlockfunc;
void *ptr;
if (share->dirty)
/* don't allow setting options while one or more handles are already
using this share */
return CURLSHE_IN_USE;
va_start(param, option);
switch(option) {
case CURLSHOPT_SHARE:
/* this is a type this share will share */
type = va_arg(param, int);
share->specifier |= (1<<type);
break;
case CURLSHOPT_UNSHARE:
/* this is a type this share will no longer share */
type = va_arg(param, int);
share->specifier &= ~(1<<type);
break;
case CURLSHOPT_LOCKFUNC:
lockfunc = va_arg(param, curl_lock_function);
share->lockfunc = lockfunc;
break;
case CURLSHOPT_UNLOCKFUNC:
unlockfunc = va_arg(param, curl_unlock_function);
share->unlockfunc = unlockfunc;
break;
case CURLSHOPT_USERDATA:
ptr = va_arg(param, void *);
share->clientdata = ptr;
break;
default:
return CURLSHE_BAD_OPTION;
}
if (enable) {
CURL_SHARE_SET_USED (share, option);
}
else {
CURL_SHARE_SET_UNUSED (share, option);
}
return CURLE_OK;
return CURLSHE_OK;
}
CURLcode
curl_share_set_lock_function (curl_share *share, curl_lock_function lock)
CURLSHcode curl_share_cleanup(CURLSH *sh)
{
if (CURL_SHARE_IS_DIRTY(share)) {
return CURLE_SHARE_IN_USE;
}
share->lockfunc = lock;
return CURLE_OK;
}
CURLcode
curl_share_set_unlock_function (curl_share *share, curl_unlock_function unlock)
{
if (CURL_SHARE_IS_DIRTY(share)) {
return CURLE_SHARE_IN_USE;
}
share->unlockfunc = unlock;
return CURLE_OK;
}
CURLcode
curl_share_set_lock_data (curl_share *share, void *data)
{
if (CURL_SHARE_IS_DIRTY(share)) {
return CURLE_SHARE_IN_USE;
}
share->clientdata = data;
return CURLE_OK;
}
Curl_share_error
Curl_share_acquire_lock (CURL *handle, curl_lock_type type)
{
curl_share *share = CURL_SHARE_GET (handle);
if (share == NULL) {
return SHARE_ERROR_INVALID;
}
if (! (share->specifier & type)) {
return SHARE_ERROR_NOT_REGISTERED;
}
if (CURL_SHARE_IS_LOCKED (share, type)) {
return SHARE_ERROR_OK;
}
share->lockfunc (handle, type, share->clientdata);
CURL_SHARE_SET_LOCKED (share, type);
return SHARE_ERROR_OK;
}
Curl_share_error
Curl_share_release_lock (CURL *handle, curl_lock_type type)
{
curl_share *share = CURL_SHARE_GET(handle);
if (share == NULL) {
return SHARE_ERROR_INVALID;
}
if (! (share->specifier & type)) {
return SHARE_ERROR_NOT_REGISTERED;
}
if (!CURL_SHARE_IS_LOCKED (share, type)) {
return SHARE_ERROR_OK;
}
share->unlockfunc (handle, type, share->clientdata);
CURL_SHARE_SET_UNLOCKED (share, type);
return SHARE_ERROR_OK;
}
CURLcode curl_share_destroy (curl_share *share)
{
if (CURL_SHARE_IS_DIRTY(share)) {
return CURLE_SHARE_IN_USE;
}
struct Curl_share *share = (struct Curl_share *)sh;
if (share->dirty)
return CURLSHE_IN_USE;
free (share);
return CURLE_OK;
return CURLSHE_OK;
}
CURLSHcode
Curl_share_acquire_lock(struct SessionHandle *data, curl_lock_data type)
{
struct Curl_share *share = data->share;
if (share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
share->lockfunc (data, type, CURL_LOCK_ACCESS_SINGLE, share->clientdata);
share->locked |= (1<<type);
}
/* else if we don't share this, pretend successful lock */
return CURLSHE_OK;
}
CURLSHcode
Curl_share_release_lock(struct SessionHandle *data, curl_lock_data type)
{
struct Curl_share *share = data->share;
if (share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
share->unlockfunc (data, type, share->clientdata);
share->locked &= ~(1<<type);
}
return CURLSHE_OK;
}
/*
* local variables:
* eval: (load-file "../curl-mode.el")

View File

@@ -27,15 +27,19 @@
#include "setup.h"
#include <curl/curl.h>
typedef enum {
SHARE_ERROR_OK = 0,
SHARE_ERROR_INVALID,
SHARE_ERROR_NOT_REGISTERED,
SHARE_ERROR_LAST
} Curl_share_error;
/* this struct is libcurl-private, don't export details */
struct Curl_share {
unsigned int specifier;
unsigned int locked;
unsigned int dirty;
curl_lock_function lockfunc;
curl_unlock_function unlockfunc;
void *clientdata;
};
Curl_share_error Curl_share_aquire_lock (CURL *, curl_lock_type);
Curl_share_error Curl_share_release_lock (CURL *, curl_lock_type);
CURLSHcode Curl_share_aquire_lock (struct SessionHandle *, curl_lock_data);
CURLSHcode Curl_share_release_lock (struct SessionHandle *, curl_lock_data);
#endif /* __CURL_SHARE_H */

View File

@@ -275,7 +275,8 @@ int cert_stuff(struct connectdata *conn,
if (SSL_CTX_use_PrivateKey_file(conn->ssl.ctx,
key_file,
file_type) != 1) {
failf(data, "unable to set private key file\n");
failf(data, "unable to set private key file: '%s' type %s\n",
key_file, key_type?key_type:"PEM");
return 0;
}
break;
@@ -324,10 +325,15 @@ int cert_stuff(struct connectdata *conn,
ssl=SSL_new(conn->ssl.ctx);
x509=SSL_get_certificate(ssl);
if (x509 != NULL)
EVP_PKEY_copy_parameters(X509_get_pubkey(x509),
SSL_get_privatekey(ssl));
/* This version was provided by Evan Jordan and is supposed to not
leak memory as the previous version: */
if (x509 != NULL) {
EVP_PKEY *pktmp = X509_get_pubkey(x509);
EVP_PKEY_copy_parameters(pktmp,SSL_get_privatekey(ssl));
EVP_PKEY_free(pktmp);
}
SSL_free(ssl);
/* If we are using DSA, we can copy the parameters from
@@ -666,6 +672,44 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
#endif
/* ====================================================== */
static int
cert_hostcheck(const char *certname, const char *hostname)
{
char *tmp;
const char *certdomain;
if(!certname ||
strlen(certname)<3 ||
!hostname ||
!strlen(hostname)) /* sanity check */
return 0;
if(strequal(certname, hostname)) /* trivial case */
return 1;
certdomain = certname + 1;
if((certname[0] != '*') || (certdomain[0] != '.'))
return 0; /* not a wildcard certificate, check failed */
if(!strchr(certdomain+1, '.'))
return 0; /* the certificate must have at least another dot in its name */
/* find 'certdomain' within 'hostname' */
tmp = strstr(hostname, certdomain);
if(tmp) {
/* ok the certname's domain matches the hostname, let's check that it's a
tail-match */
if(strequal(tmp, certdomain))
/* looks like a match. Just check we havent swallowed a '.' */
return tmp == strchr(hostname, '.');
else
return 0;
}
return 0;
}
/* ====================================================== */
CURLcode
Curl_SSLConnect(struct connectdata *conn)
@@ -904,7 +948,7 @@ Curl_SSLConnect(struct connectdata *conn)
return CURLE_SSL_PEER_CERTIFICATE;
}
if (!strequal(peer_CN, conn->hostname)) {
if (!cert_hostcheck(peer_CN, conn->hostname)) {
if (data->set.ssl.verifyhost > 1) {
failf(data, "SSL: certificate subject name '%s' does not match "
"target host name '%s'",

File diff suppressed because it is too large Load Diff

View File

@@ -101,6 +101,7 @@
#include "strequal.h"
#include "escape.h"
#include "strtok.h"
#include "share.h"
/* And now for the protocols */
#include "ftp.h"
@@ -1071,8 +1072,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
case CURLOPT_SHARE:
{
curl_share *set;
set = va_arg(param, curl_share *);
struct Curl_share *set;
set = va_arg(param, struct Curl_share *);
if(data->share)
data->share->dirty--;
@@ -1088,6 +1089,20 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
data->set.proxytype = va_arg(param, long);
break;
case CURLOPT_PRIVATE:
/*
* Set private data pointer.
*/
data->set.private = va_arg(param, char *);
break;
case CURLOPT_HTTP200ALIASES:
/*
* Set a list of aliases for HTTP 200 in response header
*/
data->set.http200aliases = va_arg(param, struct curl_slist *);
break;
default:
/* unknown tag and its companion, just ignore: */
return CURLE_FAILED_INIT; /* correct this */
@@ -1603,6 +1618,9 @@ static CURLcode ConnectPlease(struct connectdata *conn,
return result;
}
/*
* ALERT! The 'dns' pointer being passed in here might be NULL at times.
*/
static void verboseconnect(struct connectdata *conn,
struct Curl_dns_entry *dns)
{
@@ -1636,7 +1654,7 @@ static void verboseconnect(struct connectdata *conn,
}
#else
{
Curl_addrinfo *hostaddr=dns->addr;
Curl_addrinfo *hostaddr=dns?dns->addr:NULL;
struct in_addr in;
(void) memcpy(&in.s_addr, &conn->serv_addr.sin_addr, sizeof (in.s_addr));
infof(data, "Connected to %s (%s) port %d\n",
@@ -1667,6 +1685,12 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
struct SessionHandle *data = conn->data;
CURLcode result=CURLE_OK;
if(conn->bits.tcpconnect)
/* We already are connected, get back. This may happen when the connect
worked fine in the first call, like when we connect to a local server
or proxy. */
return CURLE_OK;
Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */
if(data->set.verbose)
@@ -1779,6 +1803,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* else, no chunky upload */
FALSE;
conn->fread = data->set.fread;
conn->fread_in = data->set.in;
/***********************************************************
* We need to allocate memory to store the path in. We get the size of the
* full URL to be sure, and we need to make it at least 256 bytes since
@@ -2286,6 +2313,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* Setup a "faked" transfer that'll do nothing */
if(CURLE_OK == result) {
conn->bits.tcpconnect = TRUE; /* we are "connected */
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
-1, NULL); /* no upload */
}
@@ -2463,6 +2491,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* no name given, get the password only */
sscanf(userpass, ":%127[^@]", data->state.passwd);
/* we have set the password */
data->state.passwdgiven = TRUE;
if(data->state.user[0]) {
char *newname=curl_unescape(data->state.user, 0);
if(strlen(newname) < sizeof(data->state.user)) {
@@ -2498,14 +2529,17 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* the name is given, get user+password */
sscanf(data->set.userpwd, "%127[^:]:%127[^\n]",
data->state.user, data->state.passwd);
if(strchr(data->set.userpwd, ':'))
/* a colon means the password was given, even if blank */
data->state.passwdgiven = TRUE;
}
else
/* no name given, get the password only */
/* no name given, starts with a colon, get the password only */
sscanf(data->set.userpwd+1, "%127[^\n]", data->state.passwd);
}
if (data->set.use_netrc != CURL_NETRC_IGNORED &&
data->state.passwd[0] == '\0' ) { /* need passwd */
!data->state.passwdgiven) { /* need passwd */
if(Curl_parsenetrc(conn->hostname,
data->state.user,
data->state.passwd)) {
@@ -2516,8 +2550,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
/* if we have a user but no password, ask for one */
if(conn->bits.user_passwd &&
!data->state.passwd[0] ) {
if(conn->bits.user_passwd && !data->state.passwdgiven ) {
if(data->set.fpasswd(data->set.passwd_client,
"password:", data->state.passwd,
sizeof(data->state.passwd)))
@@ -2528,9 +2561,12 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* If our protocol needs a password and we have none, use the defaults */
if ( (conn->protocol & (PROT_FTP|PROT_HTTP)) &&
!conn->bits.user_passwd) {
!conn->bits.user_passwd &&
!data->state.passwdgiven) {
strcpy(data->state.user, CURL_DEFAULT_USER);
strcpy(data->state.passwd, CURL_DEFAULT_PASSWORD);
/* This is the default password, so DON'T set conn->bits.user_passwd */
}
@@ -2782,14 +2818,21 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* Connect only if not already connected! */
result = ConnectPlease(conn, hostaddr, &connected);
if(connected)
if(connected) {
result = Curl_protocol_connect(conn, hostaddr);
if(CURLE_OK == result)
conn->bits.tcpconnect = TRUE;
}
else
conn->bits.tcpconnect = FALSE;
if(CURLE_OK != result)
return result;
}
else {
Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
conn->bits.tcpconnect = TRUE;
if(data->set.verbose)
verboseconnect(conn, hostaddr);
}

View File

@@ -157,6 +157,8 @@ struct ssl_config_data {
struct HTTP {
struct FormData *sendit;
int postsize;
char *postdata;
const char *p_pragma; /* Pragma: string */
const char *p_accept; /* Accept: string */
long readbytecount;
@@ -164,10 +166,24 @@ struct HTTP {
/* For FORM posting */
struct Form form;
curl_read_callback storefread;
FILE *in;
struct Curl_chunker chunk;
struct back {
curl_read_callback fread; /* backup storage for fread pointer */
void *fread_in; /* backup storage for fread_in pointer */
char *postdata;
int postsize;
} backup;
enum {
HTTPSEND_NADA, /* init */
HTTPSEND_REQUEST, /* sending a request */
HTTPSEND_BODY, /* sending body */
HTTPSEND_LAST /* never use this */
} sending;
void *send_buffer; /* used if the request couldn't be sent in one chunk,
points to an allocated send_buffer struct */
};
/****************************************************************************
@@ -190,7 +206,9 @@ struct FTP {
read the line, just ignore the result. */
bool no_transfer; /* nothing was transfered, (possibly because a resumed
transfer already was complete) */
long response_time; /* When no timeout is given, this is the amount of
seconds we await for an FTP response. Initialized
in Curl_ftp_connect() */
};
/****************************************************************************
@@ -220,8 +238,14 @@ struct ConnectBits {
bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
on upload */
bool getheader; /* TRUE if header parsing is wanted */
bool getheader; /* TRUE if header parsing is wanted */
bool forbidchunk; /* used only to explicitly forbid chunk-upload for
specific upload buffers. See readmoredata() in
http.c for details. */
bool tcpconnect; /* the tcp stream (or simimlar) is connected, this
is set the first time on the first connect function
call */
};
/*
@@ -456,6 +480,9 @@ struct connectdata {
and the 'upload_present' contains the number of bytes available at this
position */
char *upload_fromhere;
curl_read_callback fread; /* function that reads the input */
void *fread_in; /* pointer to pass to the fread() above */
};
/* The end of connectdata. 08/27/02 jhrg */
@@ -543,6 +570,9 @@ struct UrlState {
char proxyuser[MAX_CURL_USER_LENGTH];
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
bool passwdgiven; /* set TRUE if an application-provided password has been
set */
struct timeval keeps_speed; /* for the progress meter really */
/* 'connects' will be an allocated array with pointers. If the pointer is
@@ -631,7 +661,7 @@ struct UserDefined {
bool free_referer; /* set TRUE if 'referer' points to a string we
allocated */
char *useragent; /* User-Agent string */
char *encoding; /* Accept-Encoding string 08/28/02 jhrg */
char *encoding; /* Accept-Encoding string */
char *postfields; /* if POST, set the fields' values here */
size_t postfieldsize; /* if POST, this might have a size to use instead of
strlen(), and then the data *may* be binary (contain
@@ -686,6 +716,10 @@ struct UserDefined {
int dns_cache_timeout; /* DNS cache timeout */
long buffer_size; /* size of receive buffer to use */
char *private; /* Private data */
struct curl_slist *http200aliases; /* linked list of aliases for http200 */
/* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially
@@ -734,7 +768,7 @@ struct UserDefined {
struct SessionHandle {
curl_hash *hostcache;
curl_share *share; /* Share, handles global variable mutexing */
struct Curl_share *share; /* Share, handles global variable mutexing */
struct UserDefined set; /* values set by the libcurl user */
struct DynamicStatic change; /* possibly modified userdefined data */

196
perl/contrib/formfind Executable file
View File

@@ -0,0 +1,196 @@
#!/usr/bin/env perl
# $Id$
#
# formfind.pl
#
# This script gets a HTML page from the specified URL and presents form
# information you may need in order to machine-make a respond to the form.
#
# Written to use 'curl' for URL fetching.
#
# Author: Daniel Stenberg <daniel@haxx.se>
# Version: 0.2 Nov 18, 2002
#
# HISTORY
#
# 0.1 - Nov 12 1998 - Created now!
# 0.2 - Nov 18 2002 - Enhanced. Removed URL support, use only stdin.
#
$in="";
if($ARGV[0] eq "-h") {
print "Usage: $0 < HTML\n";
exit;
}
sub namevalue {
my ($tag)=@_;
my $name=$tag;
if($name =~ /name *=/i) {
if($name =~ /name *= *([^\"\']([^ \">]*))/) {
$name = $1;
}
elsif($name =~ /name *= *(\"|\')([^\"\']*)(\"|\')/) {
$name=$2;
}
else {
# there is a tag but we didn't find the contents
$name="[weird]";
}
}
else {
# no name given
$name="";
}
# get value tag
my $value= $tag;
if($value =~ /[^\.a-zA-Z0-9]value *=/i) {
if($value =~ /[^\.a-zA-Z0-9]value *= *([^\"\']([^ \">]*))/) {
$value = $1;
}
elsif($value =~ /[^\.a-zA-Z0-9]value *= *(\"|\')([^\"\']*)(\"|\')/) {
$value=$2;
}
else {
# there is a tag but we didn't find the contents
$value="[weird]";
}
}
else {
$value="";
}
return ($name, $value);
}
while(<STDIN>) {
$line = $_;
push @indoc, $line;
$line=~ s/\n//g;
$line=~ s/\r//g;
$in=$in.$line;
}
while($in =~ /[^<]*(<[^>]+>)/g ) {
# we have a tag in $1
$tag = $1;
if($tag =~ /^<!--/) {
# this is a comment tag, ignore it
}
else {
if(!$form &&
($tag =~ /^< *form/i )) {
$method= $tag;
if($method =~ /method *=/i) {
$method=~ s/.*method *= *(\"|)([^ \">]*).*/$2/gi;
}
else {
$method="get"; # default method
}
$action= $tag;
$action=~ s/.*action *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
$method=uc($method);
$enctype=$tag;
if ($enctype =~ /enctype *=/) {
$enctype=~ s/.*enctype *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
if($enctype eq "multipart/form-data") {
$enctype="multipart form upload [use -F]"
}
$enctype = "\n--- type: $enctype";
}
else {
$enctype="";
}
print "--- FORM report. Uses $method to URL \"$action\"$enctype\n";
$form=1;
}
elsif($form &&
($tag =~ /< *\/form/i )) {
print "--- end of FORM\n";
$form=0;
if( 0 ) {
print "*** Fill in all or any of these: (default assigns may be shown)\n";
for(@vars) {
$var = $_;
$def = $value{$var};
print "$var=$def\n";
}
print "*** Pick one of these:\n";
for(@alts) {
print "$_\n";
}
}
undef @vars;
undef @alts;
}
elsif($form &&
($tag =~ /^< *(input|select)/i)) {
$mtag = $1;
($name, $value)=namevalue($tag);
if($mtag =~ /select/i) {
print "Select: NAME=\"$name\"\n";
push @vars, "$name";
$select = 1;
}
else {
$type=$tag;
if($type =~ /type *=/i) {
$type =~ s/.*type *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
}
else {
$type="text"; # default type
}
$type=uc($type);
if(lc($type) eq "reset") {
# reset types are for UI only, ignore.
}
elsif($name eq "") {
# let's read the value parameter
print "Button: \"$value\" ($type)\n";
push @alts, "$value";
}
else {
print "Input: NAME=\"$name\"";
if($value ne "") {
print " VALUE=\"$value\"";
}
print " ($type)\n";
push @vars, "$name";
# store default value:
$value{$name}=$value;
}
}
}
elsif($form &&
($tag =~ /^< *textarea/i)) {
my ($name, $value)=namevalue($tag);
print "Textarea: NAME=\"$name\"\n";
}
elsif($select) {
if($tag =~ /^< *\/ *select/i) {
print "[end of select]\n";
$select = 0;
}
elsif($tag =~ /[^\/] *option/i ) {
my ($name, $value)=namevalue($tag);
my $s;
if($tag =~ /selected/i) {
$s= " (SELECTED)";
}
print " Option VALUE=\"$value\"$s\n";
}
}
}
}

View File

@@ -1,273 +0,0 @@
#!@PERL@
#
# formfind.pl
#
# This script gets a HTML page from the specified URL and presents form
# information you may need in order to machine-make a respond to the form.
#
# Written to use 'curl' for URL fetching.
#
# Author: Daniel Stenberg <Daniel.Stenberg@sth.frontec.se>
# Version: 0.1 Nov 12, 1998
#
# HISTORY
#
# 0.1 - Created now!
#
# TODO
# respect file:// URLs for local file fetches!
$in="";
$usestdin = 0;
if($ARGV[0] eq "" ) {
$usestdin = 1;
}
else {
$geturl = $ARGV[0];
}
if(($geturl eq "") && !$usestdin) {
print "Usage: $0 <full source URL>\n",
" Use a traling slash for directory URLs!\n";
exit;
}
# If you need a proxy for web access, edit your .curlrc file to feature
# -x <proxy:port>
# linkchecker, URL will be appended to the right of this command line
# this is the one using HEAD:
$linkcheck = "curl -s -m 20 -I";
# as a second attempt, this will be used. This is not using HEAD but will
# get the whole frigging document!
$linkcheckfull = "curl -s -m 20 -i";
# htmlget, URL will be appended to the right of this command line
$htmlget = "curl -s";
# urlget, URL will be appended to the right of this command line
# this stores the file with the remote file name in the current dir
$urlget = "curl -O -s";
# Parse the input URL and split it into the relevant parts:
sub SplitURL {
my $inurl = $_[0];
if($inurl=~ /^([^:]+):\/\/([^\/]*)\/(.*)\/(.*)/ ) {
$getprotocol = $1;
$getserver = $2;
$getpath = $3;
$getdocument = $4;
}
elsif ($inurl=~ /^([^:]+):\/\/([^\/]*)\/(.*)/ ) {
$getprotocol = $1;
$getserver = $2;
$getpath = $3;
$getdocument = "";
if($getpath !~ /\//) {
$getpath ="";
$getdocument = $3;
}
}
elsif ($inurl=~ /^([^:]+):\/\/(.*)/ ) {
$getprotocol = $1;
$getserver = $2;
$getpath = "";
$getdocument = "";
}
else {
print "Couldn't parse the specified URL, retry please!\n";
exit;
}
}
if(!$usestdin) {
&SplitURL($geturl);
#print "protocol = $getprotocol\n";
#print "server = $getserver\n";
#print "path = $getpath\n";
#print "document = $getdocument\n";
#exit;
open(HEADGET, "$linkcheck $geturl|") ||
die "Couldn't get web page for some reason";
headget:
while(<HEADGET>) {
# print $_;
if($_ =~ /HTTP\/.*3\d\d /) {
$pagemoved=1;
}
elsif($pagemoved &&
($_ =~ /^Location: (.*)/)) {
$geturl = $1;
&SplitURL($geturl);
$pagemoved++;
last headget;
}
}
close(HEADGET);
if($pagemoved == 1) {
print "Page is moved but we don't know where. Did you forget the ",
"traling slash?\n";
exit;
}
open(WEBGET, "$htmlget $geturl|") ||
die "Couldn't get web page for some reason";
while(<WEBGET>) {
$line = $_;
push @indoc, $line;
$line=~ s/\n//g;
$line=~ s/\r//g;
# print $line."\n";
$in=$in.$line;
}
close(WEBGET);
}
else {
while(<STDIN>) {
$line = $_;
push @indoc, $line;
$line=~ s/\n//g;
$line=~ s/\r//g;
$in=$in.$line;
}
}
getlinkloop:
while($in =~ /[^<]*(<[^>]+>)/g ) {
# we have a tag in $1
$tag = $1;
if($tag =~ /^<!--/) {
# this is a comment tag, ignore it
}
else {
if(!$form &&
($tag =~ /^< *form/i )) {
$method= $tag;
if($method =~ /method *=/i) {
$method=~ s/.*method *= *(\"|)([^ \">]*).*/$2/gi;
}
else {
$method="get"; # default method
}
$action= $tag;
$action=~ s/.*action *= *(\"|)([^ \">]*).*/$2/gi;
$method=uc($method);
$enctype=$tag;
if ($enctype =~ /enctype *=/) {
$enctype=~ s/.*enctype *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
if($enctype eq "multipart/form-data") {
$enctype="multipart form upload [use -F]"
}
$enctype = "\n--- type: $enctype";
}
else {
$enctype="";
}
print "--- FORM report. Uses $method to URL \"$action\"$enctype\n";
# print "TAG: $tag\n";
# print "METHOD: $method\n";
# print "ACTION: $action\n";
$form=1;
}
elsif($form &&
($tag =~ /< *\/form/i )) {
# print "TAG: $tag\n";
print "--- end of FORM\n";
$form=0;
if( 0 ) {
print "*** Fill in all or any of these: (default assigns may be shown)\n";
for(@vars) {
$var = $_;
$def = $value{$var};
print "$var=$def\n";
}
print "*** Pick one of these:\n";
for(@alts) {
print "$_\n";
}
}
undef @vars;
undef @alts;
}
elsif($form &&
($tag =~ /^< *(input|select)/i)) {
$mtag = $1;
# print "TAG: $tag\n";
$name=$tag;
if($name =~ /name *=/i) {
$name=~ s/.*name *= *(\"|)([^ \">]*).*/$2/gi;
}
else {
# no name given
$name="";
}
# get value tag
$value= $tag;
if($value =~ /value *=/i) {
$value=~ s/.*value *= *(\"|)([^ \">]*).*/$2/gi;
}
else {
$value="";
}
if($mtag =~ /select/i) {
print "Select: $name\n";
push @vars, "$name";
$select = 1;
}
else {
$type=$tag;
if($type =~ /type *=/i) {
$type =~ s/.*type *= *(\"|)([^ \">]*).*/$2/gi;
}
else {
$type="text"; # default type
}
$type=uc($type);
if(lc($type) eq "reset") {
# reset types are for UI only, ignore.
}
elsif($name eq "") {
# let's read the value parameter
print "Button: \"$value\" ($type)\n";
push @alts, "$value";
}
else {
$info="";
if($value ne "") {
$info="=$value";
}
print "Input: $name$info ($type)\n";
push @vars, "$name";
# store default value:
$value{$name}=$value;
}
}
}
elsif($select &&
($tag =~ /^< *\/ *select/i)) {
$select = 0;
}
}
}

View File

@@ -31,6 +31,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#include <curl/curl.h>
@@ -144,6 +145,12 @@ char *strdup(char *str)
}
#endif
#ifdef WIN32
#include <direct.h>
#define F_OK 0
#define mkdir(x,y) (mkdir)(x)
#endif
#ifdef VMS
int vms_show = 0;
#define FAC_CURL 0xC01
@@ -355,6 +362,7 @@ static void help(void)
" --ciphers <list> What SSL ciphers to use (SSL)\n"
" --compressed Request a compressed response (using deflate).");
puts(" --connect-timeout <seconds> Maximum time allowed for connection\n"
" --create-dirs Create the necessary local directory hierarchy\n"
" --crlf Convert LF to CRLF in upload. Useful for MVS (OS/390)\n"
" -f/--fail Fail silently (no output at all) on errors (H)\n"
" -F/--form <name=content> Specify HTTP POST data (H)\n"
@@ -484,6 +492,7 @@ struct Configurable {
bool globoff;
bool use_httpget;
bool insecure_ok; /* set TRUE to allow insecure SSL connects */
bool create_dirs;
char *writeout; /* %-styled format string to output */
bool writeenv; /* write results to environment, if available */
@@ -523,6 +532,7 @@ struct Configurable {
static int parseconfig(const char *filename,
struct Configurable *config);
static char *my_get_line(FILE *fp);
static int create_dir_hierarchy(char *outfile);
static void GetStr(char **string,
char *value)
@@ -1069,6 +1079,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
{"z", "time-cond", TRUE},
{"Z", "max-redirs", TRUE},
{"#", "progress-bar",FALSE},
{"@", "create-dirs", FALSE},
};
if(('-' != flag[0]) ||
@@ -1704,6 +1715,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->maxredirs = atoi(nextarg);
break;
case '@':
config->create_dirs = TRUE;
break;
default: /* unknown flag */
return PARAM_OPTION_UNKNOWN;
}
@@ -2186,7 +2201,7 @@ int my_trace(CURL *handle, curl_infotype type,
text = "=> Send header";
break;
case CURLINFO_DATA_OUT:
text = "=> Send data ";
text = "=> Send data";
break;
case CURLINFO_HEADER_IN:
text = "<= Recv header";
@@ -2333,6 +2348,7 @@ operate(struct Configurable *config, int argc, char *argv[])
config->showerror=TRUE;
config->conf=CONF_DEFAULT;
config->use_httpget=FALSE;
config->create_dirs=FALSE;
if(argc>1 &&
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
@@ -2555,13 +2571,20 @@ operate(struct Configurable *config, int argc, char *argv[])
free(storefile);
}
/* Create the directory hierarchy, if not pre-existant to a multiple
file output call */
if(config->create_dirs)
if (-1 == create_dir_hierarchy(outfile))
return CURLE_WRITE_ERROR;
if(config->resume_from_current) {
/* we're told to continue where we are now, then we get the size of
the file as it is now and open it for append instead */
/* We're told to continue from where we are now. Get the
size of the file as it is now and open it for append instead */
struct stat fileinfo;
/*VMS?? -- Danger, the filesize is only valid for stream files */
/*VMS?? -- Danger, the filesize is only valid for stream files */
if(0 == stat(outfile, &fileinfo))
/* set offset to current file size: */
config->resume_from = fileinfo.st_size;
@@ -2569,7 +2592,7 @@ operate(struct Configurable *config, int argc, char *argv[])
/* let offset be 0 */
config->resume_from = 0;
}
if(config->resume_from) {
/* open file for output: */
outs.stream=(FILE *) fopen(outfile, config->resume_from?"ab":"wb");
@@ -3020,3 +3043,89 @@ static char *my_get_line(FILE *fp)
return retval;
}
/* Create the needed directory hierarchy recursively in order to save
multi-GETs in file output, ie:
curl "http://my.site/dir[1-5]/file[1-5].txt" -o "dir#1/file#2.txt"
should create all the dir* automagically
*/
static int create_dir_hierarchy(char *outfile)
{
char *tempdir;
char *tempdir2;
char *outdup;
char *dirbuildup;
int result=0;
outdup = strdup(outfile);
dirbuildup = malloc(sizeof(char) * strlen(outfile));
if(!dirbuildup)
return -1;
dirbuildup[0] = '\0';
tempdir = strtok(outdup, DIR_CHAR);
while (tempdir != NULL) {
tempdir2 = strtok(NULL, DIR_CHAR);
/* since strtok returns a token for the last word even
if not ending with DIR_CHAR, we need to prune it */
if (tempdir2 != NULL) {
if (strlen(dirbuildup) > 0)
sprintf(dirbuildup,"%s%s%s",dirbuildup, DIR_CHAR, tempdir);
else {
if (0 != strncmp(outdup, DIR_CHAR, 1))
sprintf(dirbuildup,"%s",tempdir);
else
sprintf(dirbuildup,"%s%s", DIR_CHAR, tempdir);
}
if (access(dirbuildup, F_OK) == -1) {
result = mkdir(dirbuildup,(mode_t)0000750);
if (-1 == result) {
switch (errno) {
#ifdef EACCES
case EACCES:
fprintf(stderr,"You don't have permission to create %s.\n",
dirbuildup);
break;
#endif
#ifdef ENAMETOOLONG
case ENAMETOOLONG:
fprintf(stderr,"The directory name %s is too long.\n",
dirbuildup);
break;
#endif
#ifdef EROFS
case EROFS:
fprintf(stderr,"%s resides on a read-only file system.\n",
dirbuildup);
break;
#endif
#ifdef ENOSPC
case ENOSPC:
fprintf(stderr,"No space left on the file system that will "
"contain the directory %s.\n", dirbuildup);
break;
#endif
#ifdef EDQUOT
case EDQUOT:
fprintf(stderr,"Cannot create directory %s because you "
"exceeded your quota.\n", dirbuildup);
break;
#endif
default :
fprintf(stderr,"Error creating directory %s.\n", dirbuildup);
break;
}
break; /* get out of loop */
}
}
}
tempdir = tempdir2;
}
free(dirbuildup);
free(outdup);
return result; /* 0 is fine, -1 is badness */
}

View File

@@ -25,9 +25,8 @@
#include <stdio.h>
#if !defined(WIN32) && defined(_WIN32)
/* This _might_ be a good Borland fix. Please report whether this works or
not! */
#if !defined(WIN32) && defined(__WIN32__)
/* Borland fix */
#define WIN32
#endif

View File

@@ -1,3 +1,3 @@
#define CURL_NAME "curl"
#define CURL_VERSION "7.10.2"
#define CURL_VERSION "7.10.3"
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "

View File

@@ -1,2 +1,4 @@
Makefile
Makefile.in
memdump
log

View File

@@ -38,6 +38,16 @@ reply is sent
</reply>
<client>
<server>
protocols as in 'http' 'ftp' etc. Give only one per line. Used for test cases
500+ (at this point) to specify which servers the test case requires. In the
future all test cases should use this. Makes us independent of the test
case number.
</server
<tool>
Name of tool to use instead of "curl". This tool must be built and exist
in the libtest/ directory.
</tool>
<name>
test case description
</name>
@@ -48,6 +58,15 @@ accordingly. more about them elsewhere
Set 'option=no-output' to prevent the test script to slap on the --output
argument that directs the output to a file. The --output is also not added if
the client/stdout section is used.
Available substitute variables include:
%HOSTIP - IP address of the host running this test
%HOSTPORT - Port number of the HTTP server
%HTTPSPORT - Port number of the HTTPS server
%FTPPORT - Port number of the FTP server
%FTPSPORT - Port number of the FTPS server
%SRCDIR - Full path to the source dir
%PWD - Current directory
</command>
<file name="log/filename">
this creates the named file with this content before the test case is run

View File

@@ -2,13 +2,10 @@ EXTRA_DIST = ftpserver.pl httpserver.pl httpsserver.pl runtests.pl \
ftpsserver.pl stunnel.pm getpart.pm FILEFORMAT README \
stunnel.pem memanalyze.pl
SUBDIRS = data server
SUBDIRS = data server libtest
PERLFLAGS = -I$(srcdir)
all:
install:
curl:
@(cd ..; make)
@@ -20,9 +17,5 @@ quiet-test: server/sws
@cd data && exec $(MAKE) test
srcdir=$(srcdir) $(PERL) $(PERLFLAGS) $(srcdir)/runtests.pl -s -a
clean:
rm -rf log
find . -name "*~" | xargs rm -f
server/sws:
cd server; make sws

View File

@@ -1,4 +1,4 @@
all:
iall:
install:
test:
@@ -17,4 +17,5 @@ test106 test115 test124 test190 test25 test303 test44 test38 \
test107 test116 test125 test2 test26 test33 test45 test126 \
test304 test39 test32 test128 test48 test306 \
test130 test131 test132 test133 test134 test135 test403 test305 \
test49 test50 test51 test52 test53 test54 test55
test49 test50 test51 test52 test53 test54 test55 test56 \
test500 test501 test502 test503 test504 test136

29
tests/data/test136 Normal file
View File

@@ -0,0 +1,29 @@
# Server-side
<reply>
<data>
0123456789abcdef
</data>
</reply>
# Client-side
<client>
<name>
FTP with user and no password
</name>
<command>
-u user: ftp://%HOSTIP:%FTPPORT/136
</command>
</test>
# Verify data after the test has been "shot"
<verify>
<protocol>
USER user
PASS
PWD
EPSV
TYPE I
SIZE 136
RETR 136
</protocol>
</verify>

View File

@@ -1,6 +1,7 @@
#
# Server-side
<reply>
MOOOOO
</reply>
#
@@ -10,7 +11,7 @@
HTTPS GET over HTTP proxy fails
</name>
<command>
-k -U fake:user -x %HOSTIP:%HOSTPORT https://ssl.fakeurl-to.test/slash/302
-k -U fake:user -x %HOSTIP:%HOSTPORT https://bad.fakeurl-to.test/slash/302
</command>
</test>

48
tests/data/test500 Normal file
View File

@@ -0,0 +1,48 @@
#
# Server-side
<reply name="1">
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
Accept-Ranges: bytes
Content-Length: 6
Connection: close
Content-Type: text/html
Funny-head: yesyes
<foo>
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
# tool is what to use instead of 'curl'
<tool>
lib500
</tool>
<name>
simple libcurl HTTP GET tool
</name>
<command>
http://%HOSTIP:%HOSTPORT/500
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /500 HTTP/1.1
Host: 127.0.0.1:8999
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
</protocol>
</verify>

30
tests/data/test501 Normal file
View File

@@ -0,0 +1,30 @@
#
# Server-side
<reply name="1">
</reply>
# Client-side
<client>
<server>
file
</server>
# tool is what to use instead of 'curl'
<tool>
lib501
</tool>
<name>
simple libcurl attempt operation without URL set
</name>
<command>
http://%HOSTIP:%HOSTPORT/501
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<errorcode>
3
</errorcode>
</verify>

40
tests/data/test502 Normal file
View File

@@ -0,0 +1,40 @@
#
# Server-side
<reply>
<data>
foo
bar
bar
foo
moo
</data>
</reply>
# Client-side
<client>
<server>
file
</server>
# tool is what to use instead of 'curl'
<tool>
lib502
</tool>
<name>
simple multi file:// get
</name>
<command>
file://%PWD/log/test502.txt
</command>
<file name="log/test502.txt">
foo
bar
bar
foo
moo
</file>
</client>
# Verify data after the test has been "shot"
<verify>
</verify>

52
tests/data/test503 Normal file
View File

@@ -0,0 +1,52 @@
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
# tool is what to use instead of 'curl'
<tool>
lib503
</tool>
<name>
simple multi https:// through proxy with authentication info
</name>
<command>
http://%HOSTIP:%HTTPSPORT/503 localhost:%HOSTPORT
</command>
<file name="log/test502.txt">
foo
bar
bar
foo
moo
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
CONNECT 127.0.0.1:8433 HTTP/1.0
Proxy-authorization: Basic dGVzdDppbmc=
GET /503 HTTP/1.1
Proxy-authorization: Basic dGVzdDppbmc=
Authorization: Basic dGVzdDppbmc=
Host: 127.0.0.1:8433
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
</protocol>
</verify>

28
tests/data/test504 Normal file
View File

@@ -0,0 +1,28 @@
# Server-side
<reply>
</reply>
# Client-side
<client>
<server>
file
</server>
# tool is what to use instead of 'curl'
<tool>
lib504
</tool>
<name>
simple multi through local proxy without listener
</name>
<command>
http://%HOSTIP:%HTTPSPORT/504 localhost:55555
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<errorcode>
100
</errorcode>
</verify>

49
tests/data/test56 Normal file

File diff suppressed because one or more lines are too long

View File

@@ -439,7 +439,8 @@ for ( $waitedpid = 0;
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
print "500 '$_': command not understood.\r\n";
next;
logmsg "unknown crap received, bailing out hard\n";
last;
}
my $FTPCMD=$1;
my $FTPARG=$2;

9
tests/libtest/.cvsignore Normal file
View File

@@ -0,0 +1,9 @@
lib500
lib501
lib502
lib503
.libs
.deps
Makefile
Makefile.in
lib504

33
tests/libtest/Makefile.am Normal file
View File

@@ -0,0 +1,33 @@
#
# $Id$
#
AUTOMAKE_OPTIONS = foreign nostdinc
INCLUDES = -I$(top_srcdir)/include/curl
LIBDIR = ../../lib
# here are all tools used for running libcurl tests
noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504
lib500_SOURCES = lib500.c first.c test.h
lib500_LDADD = $(LIBDIR)/libcurl.la
lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib501_SOURCES = lib501.c first.c test.h
lib501_LDADD = $(LIBDIR)/libcurl.la
lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib502_SOURCES = lib502.c first.c test.h
lib502_LDADD = $(LIBDIR)/libcurl.la
lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib503_SOURCES = lib503.c first.c test.h
lib503_LDADD = $(LIBDIR)/libcurl.la
lib503_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib504_SOURCES = lib504.c first.c test.h
lib504_LDADD = $(LIBDIR)/libcurl.la
lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la

31
tests/libtest/first.c Normal file
View File

@@ -0,0 +1,31 @@
#include "test.h"
#ifdef MALLOCDEBUG
/* provide a proto for this debug function */
extern void curl_memdebug(const char *);
#endif
/* test is provided in the test code file */
CURLcode test(char *url);
char *arg2=NULL;
int main(int argc, char **argv)
{
char *URL;
if(argc< 2 ) {
fprintf(stderr, "Pass URL as argument please\n");
return 1;
}
if(argc>2)
arg2=argv[2];
URL = argv[1]; /* provide this to the rest */
fprintf(stderr, "URL: %s\n", URL);
#ifdef MALLOCDEBUG
curl_memdebug("memdump");
#endif
return test(URL);
}

13
tests/libtest/lib500.c Normal file
View File

@@ -0,0 +1,13 @@
#include "test.h"
CURLcode test(char *URL)
{
CURLcode res;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, TRUE);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
return res;
}

14
tests/libtest/lib501.c Normal file
View File

@@ -0,0 +1,14 @@
#include "test.h"
CURLcode test(char *URL)
{
CURLcode res;
CURL *curl = curl_easy_init();
(void)URL; /* we don't use this */
curl_easy_setopt(curl, CURLOPT_HEADER, TRUE);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
return res;
}

33
tests/libtest/lib502.c Normal file
View File

@@ -0,0 +1,33 @@
#include "test.h"
/*
* Get a single URL without select().
*/
CURLcode test(char *URL)
{
CURL *c;
CURLM *m;
CURLMcode res;
int running=1;
curl_global_init(CURL_GLOBAL_ALL);
c = curl_easy_init();
curl_easy_setopt(c, CURLOPT_URL, URL);
m = curl_multi_init();
res = curl_multi_add_handle(m, c);
while (running) {
res = curl_multi_perform(m, &running);
if (running <= 0) {
fprintf(stderr, "nothing left running.\n");
break;
}
}
curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
return 0;
}

77
tests/libtest/lib503.c Normal file
View File

@@ -0,0 +1,77 @@
#include "test.h"
/*
* Source code in here hugely as reported in bug report 651460 by
* Christopher R. Palmer.
*
* Use multi interface to get HTTPS document over proxy, and provide
* auth info.
*/
CURLcode test(char *URL)
{
CURL *c;
CURLM *m;
curl_global_init(CURL_GLOBAL_ALL);
c = curl_easy_init();
curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */
curl_easy_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_easy_setopt(c, CURLOPT_HEADER, 1);
{
CURLMcode res;
int running;
char done=FALSE;
m = curl_multi_init();
res = curl_multi_add_handle(m, c);
while(!done) {
fd_set rd, wr, exc;
int max_fd;
while (res == CURLM_CALL_MULTI_PERFORM) {
res = curl_multi_perform(m, &running);
if (running <= 0) {
done = TRUE;
break;
}
}
if(done)
break;
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
return 80;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
return 89;
}
if (select(max_fd+1, &rd, &wr, &exc, NULL) == -1) {
fprintf(stderr, "bad select??\n");
return 95;
}
res = CURLM_CALL_MULTI_PERFORM;
}
}
curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
return 0;
}

76
tests/libtest/lib504.c Normal file
View File

@@ -0,0 +1,76 @@
#include "test.h"
/*
* Source code in here hugely as reported in bug report 651464 by
* Christopher R. Palmer.
*
* Use multi interface to get document over proxy with bad port number.
* This caused the interface to "hang" in libcurl 7.10.2.
*/
CURLcode test(char *URL)
{
CURL *c;
CURLcode ret=CURLE_OK;
CURLM *m;
fd_set rd, wr, exc;
CURLMcode res;
int running;
int max_fd;
curl_global_init(CURL_GLOBAL_ALL);
c = curl_easy_init();
/* the point here being that there must not run anything on the given
proxy port */
curl_easy_setopt(c, CURLOPT_PROXY, arg2);
curl_easy_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_VERBOSE, 1);
m = curl_multi_init();
do {
res = curl_multi_add_handle(m, c);
while (res == CURLM_CALL_MULTI_PERFORM)
res = curl_multi_perform(m, &running);
if(!running) {
/* This is where this code is expected to reach */
int numleft;
CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Not running\n");
if(msg && !numleft)
ret = 100; /* this is where we should be */
else
ret = 99; /* not correct */
break;
}
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
ret = 2;
break;
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
max_fd = 0;
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n");
ret = 3;
break;
}
select(max_fd+1, &rd, &wr, &exc, NULL);
fprintf(stderr, "not reached!\n");
} while(0);
curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
return ret;
}

5
tests/libtest/test.h Normal file
View File

@@ -0,0 +1,5 @@
#include <curl.h>
#include <stdio.h>
extern char *arg2; /* set by first.c to the argv[2] or NULL */

View File

@@ -6,14 +6,17 @@
# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
# MEM sendf.c:232 free(f6520)
do {
while(1) {
if($ARGV[0] eq "-v") {
$verbose=1;
shift @ARGV;
}
elsif($ARGV[0] eq "-t") {
$trace=1;
shift @ARGV;
}
} while (shift @ARGV);
last;
}
my $maxmem;
@@ -26,11 +29,23 @@ sub newtotal {
}
}
while(<STDIN>) {
my $file = $ARGV[0];
if(! -f $file) {
print "Usage: memanalyze.pl [options] <dump file>\n",
"Options:\n",
" -v Verbose\n",
" -t Trace\n";
exit;
}
open(FILE, "<$file");
while(<FILE>) {
chomp $_;
$line = $_;
if($line =~ /^MEM ([^:]*):(\d*) (.*)/) {
if($line =~ /^MEM ([^ ]*):(\d*) (.*)/) {
# generic match for the filename+linenumber
$source = $1;
$linenum = $2;
@@ -130,7 +145,7 @@ while(<STDIN>) {
}
}
# FD url.c:1282 socket() = 5
elsif($_ =~ /^FD ([^:]*):(\d*) (.*)/) {
elsif($_ =~ /^FD ([^ ]*):(\d*) (.*)/) {
# generic match for the filename+linenumber
$source = $1;
$linenum = $2;
@@ -157,7 +172,7 @@ while(<STDIN>) {
}
}
# FILE url.c:1282 fopen("blabla") = 0x5ddd
elsif($_ =~ /^FILE ([^:]*):(\d*) (.*)/) {
elsif($_ =~ /^FILE ([^ ]*):(\d*) (.*)/) {
# generic match for the filename+linenumber
$source = $1;
$linenum = $2;
@@ -185,7 +200,7 @@ while(<STDIN>) {
}
}
# ADDR url.c:1282 getaddrinfo() = 0x5ddd
elsif($_ =~ /^ADDR ([^:]*):(\d*) (.*)/) {
elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) {
# generic match for the filename+linenumber
$source = $1;
$linenum = $2;
@@ -219,6 +234,7 @@ while(<STDIN>) {
print "Not recognized prefix line: $line\n";
}
}
close(FILE);
if($totalmem) {
print "Leak detected: memory still allocated: $totalmem bytes\n";

View File

@@ -24,6 +24,7 @@ my $CURL="../src/curl"; # what curl executable to run on the tests
my $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging
my $LOGDIR="log";
my $TESTDIR="data";
my $LIBDIR="./libtest";
my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
@@ -517,6 +518,14 @@ sub singletest {
return 0; # look successful
}
my @codepieces = getpart("client", "tool");
my $tool="";
if(@codepieces) {
$tool = $codepieces[0];
chomp $tool;
}
# remove previous server output logfile
unlink($SERVERIN);
@@ -575,12 +584,19 @@ sub singletest {
}
else {
if (!@validstdout) {
$out="--output $CURLOUT ";
$out=" --output $CURLOUT ";
}
}
# run curl, add -v for debug information output
my $cmdargs="$out--include -v $cmd";
my $cmdargs;
if(!$tool) {
# run curl, add -v for debug information output
$cmdargs ="$out --include -v $cmd";
}
else {
$cmdargs = " $cmd"; # $cmd is the command line for the test file
$CURLOUT = $STDOUT; # sends received data to stdout
}
my @stdintest = getpart("client", "stdin");
@@ -590,11 +606,21 @@ sub singletest {
$cmdargs .= " <$stdinfile";
}
my $CMDLINE="$CURL $cmdargs >$STDOUT 2>$STDERR";
my $CMDLINE;
if(!$tool) {
$CMDLINE="$CURL";
}
else {
$CMDLINE="$LIBDIR/$tool";
$DBGCURL=$CMDLINE;
}
$CMDLINE .= "$cmdargs >$STDOUT 2>$STDERR";
if($verbose) {
print "$CMDLINE\n";
}
print "$CMDLINE\n";
}
print CMDLOG "$CMDLINE\n";
@@ -653,8 +679,7 @@ sub singletest {
}
my %replyattr = getpartattr("reply", "data");
if(!$replyattr{'nocheck'} &&
@reply) {
if(!$replyattr{'nocheck'} && @reply) {
# verify the received data
my @out = loadarray($CURLOUT);
$res = compare(\@out, \@reply);
@@ -752,7 +777,7 @@ sub singletest {
print "\n** ALERT! memory debuggin without any output file?\n";
}
else {
my @memdata=`$memanalyze < $memdump`;
my @memdata=`$memanalyze $memdump`;
my $leak=0;
for(@memdata) {
if($_ ne "") {
@@ -790,63 +815,96 @@ my %run;
sub serverfortest {
my ($testnum)=@_;
my @what;
if($testnum< 100) {
# 0 - 99 is for HTTP
if(!$run{'http'}) {
runhttpserver($verbose);
$run{'http'}=$HTTPPIDFILE;
}
push @what, "http";
}
elsif($testnum< 200) {
# 100 - 199 is for FTP
if(!$run{'ftp'}) {
runftpserver($verbose);
$run{'ftp'}=$FTPPIDFILE;
}
push @what, "ftp";
}
elsif($testnum< 300) {
# 200 - 299 is for FILE, no server!
$run{'file'}="moo";
push @what, "file";
}
elsif($testnum< 400) {
# 300 - 399 is for HTTPS, two servers!
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
}
if(!$run{'http'}) {
runhttpserver($verbose);
$run{'http'}=$HTTPPIDFILE;
}
if(!$run{'https'}) {
runhttpsserver($verbose);
$run{'https'}=$HTTPSPIDFILE;
}
# 300 - 399 is for HTTPS
push @what, "https";
}
elsif($testnum< 500) {
# 400 - 499 is for FTPS, also two servers
# 400 - 499 is for FTPS
push @what, "ftps";
}
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
if(!@what) {
# load the test case file definition
if(loadtest("${TESTDIR}/test${testnum}")) {
if($verbose) {
# this is not a test
print "$testnum doesn't look like a test case!\n";
}
return 100;
}
if(!$run{'ftp'}) {
runftpserver($verbose);
$run{'ftp'}=$FTPPIDFILE;
}
if(!$run{'ftps'}) {
runftpsserver($verbose);
$run{'ftps'}=$FTPSPIDFILE;
@what = getpart("client", "server");
if(!$what[0]) {
warn "Test case $testnum has no server(s) specified!";
return 100;
}
}
else {
print "Bad test number, no server available\n";
return 100;
for(@what) {
my $what = lc($_);
$what =~ s/[^a-z]//g;
if($what eq "ftp") {
if(!$run{'ftp'}) {
runftpserver($verbose);
$run{'ftp'}=$FTPPIDFILE;
}
}
elsif($what eq "http") {
if(!$run{'http'}) {
runhttpserver($verbose);
$run{'http'}=$HTTPPIDFILE;
}
}
elsif($what eq "ftps") {
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
}
if(!$run{'ftp'}) {
runftpserver($verbose);
$run{'ftp'}=$FTPPIDFILE;
}
if(!$run{'ftps'}) {
runftpsserver($verbose);
$run{'ftps'}=$FTPSPIDFILE;
}
}
elsif($what eq "file") {
# we support it but have no server!
}
elsif($what eq "https") {
if(!$checkstunnel || !$ssl_version) {
# we can't run https tests without stunnel
# or if libcurl is SSL-less
return 1;
}
if(!$run{'http'}) {
runhttpserver($verbose);
$run{'http'}=$HTTPPIDFILE;
}
if(!$run{'https'}) {
runhttpsserver($verbose);
$run{'https'}=$HTTPSPIDFILE;
}
}
else {
warn "we don't support a server for $what";
}
}
sleep 1; # give a second for the server(s) to startup
return 0; # ok

View File

@@ -1,8 +1,7 @@
.libs
Makefile.in
stamp-h3.in
sws
.deps
stamp-h3
stamp-h*
config.h
Makefile

View File

@@ -23,9 +23,9 @@
/* sws.c: simple (silly?) web server
This code was originally graciously donated to the project Juergen
This code was originally graciously donated to the project by Juergen
Wilke. Thanks a bunch!
*/
#include <stdio.h>
@@ -41,6 +41,13 @@
#include <netinet/in.h>
#include <netdb.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
const char *
spitout(FILE *stream,
const char *main,
@@ -54,11 +61,34 @@ spitout(FILE *stream,
#define VERSION "cURL test suite HTTP server/0.1"
#define REQUEST_DUMP "log/server.input"
#define REQUEST_DUMP "log/server.input"
#define RESPONSE_DUMP "log/server.response"
#define TEST_DATA_PATH "data/test%d"
enum {
DOCNUMBER_BADCONNECT = -5,
DOCNUMBER_INTERNAL= -4,
DOCNUMBER_CONNECT = -3,
DOCNUMBER_WERULEZ = -2,
DOCNUMBER_404 = -1
};
/* sent as reply to a CONNECT */
static const char *docconnect =
"HTTP/1.1 200 Mighty fine indeed\r\n"
"\r\n";
/* sent as reply to a "bad" CONNECT */
static const char *docbadconnect =
"HTTP/1.1 501 Forbidden you fool\r\n"
"\r\n";
/* sent as reply to the magic to find out if we are the test server or
not */
static const char *docfriends = "HTTP/1.1 200 Mighty fine indeed\r\n\r\nWE ROOLZ\r\n";
/* send back this on 404 file not found */
static const char *doc404 = "HTTP/1.1 404 Not Found\n"
"Server: " VERSION "\n"
"Connection: close\n"
@@ -86,10 +116,7 @@ static void logmsg(const char *msg)
strcpy(loctime, asctime(curr_time));
loctime[strlen(loctime) - 1] = '\0';
fprintf(logfp, "%s: pid %d: %s\n", loctime, (int)getpid(), msg);
#ifdef DEBUG
fprintf(stderr, "%s: pid %d: %s\n", loctime, (int)getpid(), msg);
#endif
fprintf(logfp, "%s: %d: %s\n", loctime, (int)getpid(), msg);
fflush(logfp);
}
@@ -106,6 +133,7 @@ int ProcessRequest(char *request)
{
char *line=request;
unsigned long contentlength=0;
char chunked=FALSE;
#define END_OF_HEADERS "\r\n\r\n"
@@ -128,8 +156,23 @@ int ProcessRequest(char *request)
*/
do {
if(!strncasecmp("Content-Length:", line, 15))
if(!strncasecmp("Content-Length:", line, 15)) {
contentlength = strtol(line+15, &line, 10);
break;
}
else if(!strncasecmp("Transfer-Encoding: chunked", line,
strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
if(chunked) {
if(strstr(request, "\r\n0\r\n"))
/* end of chunks reached */
return 1; /* done */
else
return 0; /* not done */
}
line = strchr(line, '\n');
if(line)
@@ -183,10 +226,10 @@ static int get_request(int sock, int *part)
if (got <= 0) {
if (got < 0) {
perror("recv");
return -1;
return DOCNUMBER_INTERNAL;
}
logmsg("Connection closed by client");
return -1;
return DOCNUMBER_INTERNAL;
}
offset += got;
@@ -198,20 +241,18 @@ static int get_request(int sock, int *part)
if (offset >= REQBUFSIZ) {
logmsg("Request buffer overflow, closing connection");
return -1;
return DOCNUMBER_INTERNAL;
}
reqbuf[offset]=0;
logmsg("Received a request");
/* dump the request to an external file */
storerequest(reqbuf);
if (sscanf(reqbuf, "%" REQBUFSIZ_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
request,
doc,
&prot_major,
&prot_minor) == 4) {
if(sscanf(reqbuf, "%" REQBUFSIZ_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
request,
doc,
&prot_major,
&prot_minor) == 4) {
char *ptr;
int test_no=0;
@@ -231,7 +272,7 @@ static int get_request(int sock, int *part)
if(!strncmp("/verifiedserver", ptr, 15)) {
logmsg("Are-we-friendly question received");
return -2;
return DOCNUMBER_WERULEZ;
}
ptr++; /* skip the slash */
@@ -247,8 +288,23 @@ static int get_request(int sock, int *part)
logmsg(logbuf);
}
else {
if(sscanf(reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
doc,
&prot_major, &prot_minor) == 3) {
sprintf(logbuf, "Receiced a CONNECT %s HTTP/%d.%d request",
doc, prot_major, prot_minor);
logmsg(logbuf);
logmsg("Did not find test number in PATH");
if(!strncmp(doc, "bad", 3))
/* if the host name starts with bad, we fake an error here */
test_no = DOCNUMBER_BADCONNECT;
else
test_no = DOCNUMBER_CONNECT;
}
else {
logmsg("Did not find test number in PATH");
test_no = DOCNUMBER_404;
}
}
return test_no;
@@ -268,27 +324,46 @@ static int send_doc(int sock, int doc, int part_no)
char *ptr;
FILE *stream;
char *cmd=NULL;
int cmdsize;
int cmdsize=0;
FILE *dump;
char filename[256];
char partbuf[80]="data";
if(doc < 0) {
if(-2 == doc)
switch(doc) {
case DOCNUMBER_WERULEZ:
/* we got a "friends?" question, reply back that we sure are */
logmsg("Identifying ourselves as friends");
buffer = docfriends;
else
break;
case DOCNUMBER_INTERNAL:
logmsg("Bailing out due to internal error");
return -1;
case DOCNUMBER_CONNECT:
logmsg("Replying to CONNECT");
buffer = docconnect;
break;
case DOCNUMBER_BADCONNECT:
logmsg("Replying to a bad CONNECT");
buffer = docbadconnect;
break;
case DOCNUMBER_404:
default:
logmsg("Replying to with a 404");
buffer = doc404;
break;
}
ptr = NULL;
stream=NULL;
count = strlen(buffer);
}
else {
if(0 != part_no) {
sprintf(partbuf, "data%d", part_no);
}
logmsg("Fetch response data");
if(0 != part_no)
sprintf(partbuf, "data%d", part_no);
sprintf(filename, TEST_DATA_PATH, doc);
@@ -316,15 +391,29 @@ static int send_doc(int sock, int doc, int part_no)
}
}
dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */
if(!dump) {
logmsg("couldn't create logfile: " RESPONSE_DUMP);
return -1;
}
do {
written = send(sock, buffer, count, 0);
if (written < 0) {
logmsg("Sending response failed and we bailed out!");
return -1;
}
/* write to file as well */
fwrite(buffer, 1, written, dump);
count -= written;
buffer += written;
} while(count>0);
fclose(dump);
logmsg("Response sent!");
if(ptr)
free(ptr);
@@ -336,9 +425,8 @@ static int send_doc(int sock, int doc, int part_no)
if(2 == sscanf(ptr, "%31s %d", command, &num)) {
if(!strcmp("wait", command))
sleep(num); /* wait this many seconds */
else {
else
logmsg("Unknown command in reply command section");
}
}
ptr = strchr(ptr, '\n');
if(ptr)
@@ -365,8 +453,6 @@ int main(int argc, char *argv[])
if(argc>1)
port = atoi(argv[1]);
/* FIX: write our pid to a file name */
logfp = fopen(logfile, "a");
if (!logfp) {
perror(logfile);
@@ -374,9 +460,7 @@ int main(int argc, char *argv[])
}
#ifdef HAVE_SIGNAL
/* FIX: make a more portable signal handler */
signal(SIGPIPE, sigpipe_handler);
siginterrupt(SIGPIPE, 1);
#endif
@@ -428,9 +512,16 @@ int main(int argc, char *argv[])
logmsg("New client connected");
doc = get_request(msgsock, &part_no);
send_doc(msgsock, doc, part_no);
do {
doc = get_request(msgsock, &part_no);
logmsg("Received request, now send response");
send_doc(msgsock, doc, part_no);
/* if we got a CONNECT, loop and get another request as well! */
} while(doc == DOCNUMBER_CONNECT);
logmsg("Closing client connection");
close(msgsock);
}