Compare commits
151 Commits
curl-7_10_
...
curl-7_10_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bf9b9ca29d | ||
![]() |
64f224bb22 | ||
![]() |
285a8fe4d0 | ||
![]() |
3773d76dfd | ||
![]() |
94c5c7bd6d | ||
![]() |
12cfc4c0b0 | ||
![]() |
9a2de6e6ee | ||
![]() |
2ede47b8c8 | ||
![]() |
76e107506f | ||
![]() |
6f35ed51dc | ||
![]() |
c94ba66310 | ||
![]() |
a15133f5cf | ||
![]() |
cc09e9d4c2 | ||
![]() |
16e0da2c4b | ||
![]() |
ed22f75241 | ||
![]() |
ba25cad6e2 | ||
![]() |
abb01123cb | ||
![]() |
e2d249f8c5 | ||
![]() |
4a2ac166fa | ||
![]() |
5fab55383d | ||
![]() |
f152f23a68 | ||
![]() |
24e78b3571 | ||
![]() |
9a239edb52 | ||
![]() |
abcc5c5a82 | ||
![]() |
cb5ba675a7 | ||
![]() |
2288086695 | ||
![]() |
61421b7a8f | ||
![]() |
6a7e53a7c7 | ||
![]() |
ca134d5522 | ||
![]() |
ec24efda74 | ||
![]() |
7f0f10e498 | ||
![]() |
aa5af100b4 | ||
![]() |
37ae32f688 | ||
![]() |
d0cffdec5d | ||
![]() |
0f34521612 | ||
![]() |
e69362df22 | ||
![]() |
3de8f6f38e | ||
![]() |
5359bc8083 | ||
![]() |
eb6a14fe10 | ||
![]() |
2912537533 | ||
![]() |
cfb32da198 | ||
![]() |
9b4f92130f | ||
![]() |
5a2ab686a6 | ||
![]() |
3b8583b014 | ||
![]() |
ed29552b1e | ||
![]() |
a2ada3cf96 | ||
![]() |
88825a1187 | ||
![]() |
264e7fc58b | ||
![]() |
1698015e3c | ||
![]() |
39dc14c002 | ||
![]() |
04c499a5fc | ||
![]() |
efbe930a69 | ||
![]() |
747f87f61e | ||
![]() |
5a4c56fc44 | ||
![]() |
81f45ba92a | ||
![]() |
a5dc4e32f2 | ||
![]() |
2b839853ec | ||
![]() |
66b6cd68ed | ||
![]() |
0ef3d90838 | ||
![]() |
5cc50f9b27 | ||
![]() |
e879e26a5b | ||
![]() |
96d84150e1 | ||
![]() |
2aa0c6c488 | ||
![]() |
811138386f | ||
![]() |
c433cf7459 | ||
![]() |
e0d6ebc2f2 | ||
![]() |
4938991ab8 | ||
![]() |
13722f536e | ||
![]() |
57f0e3292d | ||
![]() |
da5ae565ab | ||
![]() |
87c5066242 | ||
![]() |
b528bde470 | ||
![]() |
57572e550f | ||
![]() |
3aea0d3d68 | ||
![]() |
9ae920c1b6 | ||
![]() |
dff406a360 | ||
![]() |
d346ba5c3c | ||
![]() |
978541adc2 | ||
![]() |
637bce2707 | ||
![]() |
07e3dc2ee2 | ||
![]() |
ead065d803 | ||
![]() |
0150bff7b4 | ||
![]() |
0f493b6038 | ||
![]() |
f26b709c50 | ||
![]() |
ae10d9cf22 | ||
![]() |
81af9674ed | ||
![]() |
b63df7991a | ||
![]() |
a79990465c | ||
![]() |
ad6bd530ac | ||
![]() |
c1b369fd4c | ||
![]() |
01fcd3c2d5 | ||
![]() |
7196d784d3 | ||
![]() |
0f0aaf51e0 | ||
![]() |
b5f493c55a | ||
![]() |
0aa031beb9 | ||
![]() |
db6ff224f8 | ||
![]() |
b3c7cd61f3 | ||
![]() |
9ae05c4d91 | ||
![]() |
264e6f6efd | ||
![]() |
ec7bccf671 | ||
![]() |
49f75ee8ce | ||
![]() |
4bcc866c52 | ||
![]() |
c65e088caf | ||
![]() |
6ca4116555 | ||
![]() |
f6cdb820af | ||
![]() |
081e5a82ff | ||
![]() |
2ad2a4bd9f | ||
![]() |
645e700da3 | ||
![]() |
92aea29a30 | ||
![]() |
e1c01af929 | ||
![]() |
7ef749497d | ||
![]() |
d72aa49126 | ||
![]() |
e92bd312ec | ||
![]() |
b097c2cfb0 | ||
![]() |
a39cdc80b7 | ||
![]() |
a47250810e | ||
![]() |
1f50f3031f | ||
![]() |
75145dd753 | ||
![]() |
d0b97f7e1f | ||
![]() |
199a0311e2 | ||
![]() |
fa446f860f | ||
![]() |
7a74303f3c | ||
![]() |
7d9eabb981 | ||
![]() |
ff5308a5af | ||
![]() |
3f8ba3a986 | ||
![]() |
4a555de1b2 | ||
![]() |
d27e4a08f9 | ||
![]() |
bf678a1ca9 | ||
![]() |
13a903de28 | ||
![]() |
a3c14c031e | ||
![]() |
e90d528026 | ||
![]() |
d64dd77993 | ||
![]() |
113850a748 | ||
![]() |
1c49a00d64 | ||
![]() |
eef6c83503 | ||
![]() |
ceb5648eb7 | ||
![]() |
a0eadb76ea | ||
![]() |
065852e46c | ||
![]() |
e5e2fb8274 | ||
![]() |
0210b3c893 | ||
![]() |
7df5677b46 | ||
![]() |
2e71876b28 | ||
![]() |
11576b1142 | ||
![]() |
ce011b8a2d | ||
![]() |
12cfb4f7ee | ||
![]() |
9e1123debe | ||
![]() |
c7354142c0 | ||
![]() |
dee84f448f | ||
![]() |
1607711603 | ||
![]() |
8bca5e05b8 | ||
![]() |
f68505ee23 |
244
CHANGES
244
CHANGES
@@ -7,6 +7,250 @@
|
|||||||
Changelog
|
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)
|
Version 7.10.2 (18 Nov 2002)
|
||||||
|
|
||||||
Daniel (11 Nov 2002)
|
Daniel (11 Nov 2002)
|
||||||
|
5
CVS-INFO
5
CVS-INFO
@@ -30,6 +30,11 @@ To build after having extracted everything from CVS, do this:
|
|||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
|
|
||||||
|
Daniel uses a ./configure line similar to this for easier development:
|
||||||
|
|
||||||
|
./configure --disable-shared --enable-debug --enable-maintainer-mode
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS
|
REQUIREMENTS
|
||||||
|
|
||||||
You need the following software installed:
|
You need the following software installed:
|
||||||
|
21
MITX.txt
21
MITX.txt
@@ -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.
|
|
470
MPL-1.1.txt
470
MPL-1.1.txt
@@ -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
5
README
@@ -30,8 +30,9 @@ README
|
|||||||
Sweden -- ftp://ftp.sunet.se/pub/www/utilities/curl/
|
Sweden -- ftp://ftp.sunet.se/pub/www/utilities/curl/
|
||||||
Sweden -- http://cool.haxx.se/curl/
|
Sweden -- http://cool.haxx.se/curl/
|
||||||
Germany -- ftp://ftp.fu-berlin.de/pub/unix/network/curl/
|
Germany -- ftp://ftp.fu-berlin.de/pub/unix/network/curl/
|
||||||
Australia -- http://curl.planetmirror.com/pub/curl/
|
Australia -- http://curl.planetmirror.com/download/
|
||||||
US -- http://curl.sourceforge.net/download.html
|
US -- http://curl.sourceforge.net/download/
|
||||||
|
Hongkong -- http://www.execve.net/curl/
|
||||||
|
|
||||||
To download the very latest source off the CVS server do this:
|
To download the very latest source off the CVS server do this:
|
||||||
|
|
||||||
|
34
UPGRADE
34
UPGRADE
@@ -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.
|
|
18
configure.in
18
configure.in
@@ -9,6 +9,7 @@ dnl First some basic init macros
|
|||||||
AC_INIT
|
AC_INIT
|
||||||
AC_CONFIG_SRCDIR([lib/urldata.h])
|
AC_CONFIG_SRCDIR([lib/urldata.h])
|
||||||
AM_CONFIG_HEADER(lib/config.h src/config.h tests/server/config.h lib/ca-bundle.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
|
dnl figure out the libcurl version
|
||||||
VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
|
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_HEADER(zlib.h,[
|
||||||
AC_CHECK_LIB(z, gzread,
|
AC_CHECK_LIB(z, gzread,
|
||||||
[AM_CONDITIONAL(CONTENT_ENCODING, true)
|
[HAVE_LIBZ="1"
|
||||||
HAVE_LIBZ="1"
|
|
||||||
AC_SUBST(HAVE_LIBZ)
|
AC_SUBST(HAVE_LIBZ)
|
||||||
LIBS="$LIBS -lz"
|
LIBS="$LIBS -lz"
|
||||||
AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
|
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"
|
CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -pedantic -Wundef -Wpointer-arith -Wcast-align -Wnested-externs"
|
||||||
fi
|
fi
|
||||||
dnl strip off optimizer flags
|
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 ],
|
esac ],
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
@@ -776,6 +787,7 @@ AC_CONFIG_FILES([Makefile \
|
|||||||
tests/Makefile \
|
tests/Makefile \
|
||||||
tests/data/Makefile \
|
tests/data/Makefile \
|
||||||
tests/server/Makefile \
|
tests/server/Makefile \
|
||||||
|
tests/libtest/Makefile \
|
||||||
packages/Makefile \
|
packages/Makefile \
|
||||||
packages/Win32/Makefile \
|
packages/Win32/Makefile \
|
||||||
packages/Win32/cygwin/Makefile \
|
packages/Win32/cygwin/Makefile \
|
||||||
|
@@ -107,7 +107,8 @@ while test $# -gt 0; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
--cflags)
|
--cflags)
|
||||||
echo -I@includedir@
|
#echo -I@includedir@
|
||||||
|
echo ""
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--libs)
|
--libs)
|
||||||
|
@@ -42,7 +42,8 @@ Naming
|
|||||||
understandable and be named according to what they're used for. File-local
|
understandable and be named according to what they're used for. File-local
|
||||||
functions should be made static. We like lower case names.
|
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
|
Indenting
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ Indenting
|
|||||||
|
|
||||||
Commenting
|
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
|
use C++ comments (// this style). Commented code is quality code and enables
|
||||||
future modifications much more. Uncommented code much more risk being
|
future modifications much more. Uncommented code much more risk being
|
||||||
completely replaced when someone wants to extend things, since other persons'
|
completely replaced when someone wants to extend things, since other persons'
|
||||||
@@ -64,7 +65,7 @@ Commenting
|
|||||||
General Style
|
General Style
|
||||||
|
|
||||||
Keep your functions small. If they're small you avoid a lot of mistakes and
|
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
|
Non-clobbering All Over
|
||||||
|
|
||||||
@@ -78,11 +79,11 @@ Non-clobbering All Over
|
|||||||
Platform Dependent Code
|
Platform Dependent Code
|
||||||
|
|
||||||
Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
|
Use #ifdef HAVE_FEATURE to do conditional code. We avoid checking for
|
||||||
particular operting systems or hardware in the #ifdef lines. The HAVE_FEATURE
|
particular operating systems or hardware in the #ifdef lines. The
|
||||||
shall be generated by the configure script for unix-like systems and they are
|
HAVE_FEATURE shall be generated by the configure script for unix-like systems
|
||||||
hard-coded in the config-[system].h files for the others.
|
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
|
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
|
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
|
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
|
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!
|
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.
|
||||||
|
31
docs/FAQ
31
docs/FAQ
@@ -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.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.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.11 Why does my HTTP range requests return the full document?
|
||||||
|
4.12 Why do I get "certificate verify failed" ?
|
||||||
|
|
||||||
5. libcurl Issues
|
5. libcurl Issues
|
||||||
5.1 Is libcurl thread-safe?
|
5.1 Is libcurl thread-safe?
|
||||||
@@ -274,8 +275,8 @@ FAQ
|
|||||||
|
|
||||||
2.4. Does cURL support Socks (RFC 1928) ?
|
2.4. Does cURL support Socks (RFC 1928) ?
|
||||||
|
|
||||||
No. Nobody has wanted it that badly yet. We appreciate patches that bring
|
There is limited support for SOCKS5 for curl built with IPv6 support
|
||||||
this functionality.
|
disabled.
|
||||||
|
|
||||||
|
|
||||||
3. Usage problems
|
3. Usage problems
|
||||||
@@ -607,6 +608,30 @@ FAQ
|
|||||||
Because the range may not be supported by the server, or the server may
|
Because the range may not be supported by the server, or the server may
|
||||||
choose to ignore it and return the full document anyway.
|
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. libcurl Issues
|
||||||
|
|
||||||
5.1. Is libcurl thread-safe?
|
5.1. Is libcurl thread-safe?
|
||||||
|
38
docs/INSTALL
38
docs/INSTALL
@@ -28,11 +28,22 @@ UNIX
|
|||||||
|
|
||||||
You probably need to be root when doing the last command.
|
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,
|
If you want to install curl in a different file hierarchy than /usr/local,
|
||||||
you need to specify that already when running configure:
|
you need to specify that already when running configure:
|
||||||
|
|
||||||
./configure --prefix=/path/to/curl/tree
|
./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
|
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
|
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
|
path for your compiler/linker, you don't need to do anything special. If
|
||||||
@@ -71,33 +82,6 @@ UNIX
|
|||||||
LIBS=-lRSAglue -lrsaref
|
LIBS=-lRSAglue -lrsaref
|
||||||
(as suggested by Doug Kaufman)
|
(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
|
MORE OPTIONS
|
||||||
|
|
||||||
To force configure to use the standard cc compiler if both cc and gcc are
|
To force configure to use the standard cc compiler if both cc and gcc are
|
||||||
|
27
docs/TODO
27
docs/TODO
@@ -15,7 +15,8 @@ TODO
|
|||||||
* Introduce an interface to libcurl that allows applications to easier get to
|
* Introduce an interface to libcurl that allows applications to easier get to
|
||||||
know what cookies that are received. Pushing interface that calls a
|
know what cookies that are received. Pushing interface that calls a
|
||||||
callback on each received cookie? Querying interface that asks about
|
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.
|
* 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.
|
less copy of data and thus a faster operation.
|
||||||
[http://curl.haxx.se/dev/no_copy_callbacks.txt]
|
[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
|
* Add asynchronous name resolving (http://daniel.haxx.se/resolver/). This
|
||||||
should be made to work on most of the supported platforms, or otherwise it
|
should be made to work on most of the supported platforms, or otherwise it
|
||||||
isn't really interesting.
|
isn't really interesting.
|
||||||
@@ -51,12 +45,9 @@ TODO
|
|||||||
>4GB all over. Bug reports (and source reviews) indicate that it doesn't
|
>4GB all over. Bug reports (and source reviews) indicate that it doesn't
|
||||||
currently work properly.
|
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
|
* CURLOPT_MAXFILESIZE. Prevent downloads that are larger than the specified
|
||||||
size. CURLE_FILESIZE_EXCEEDED would then be returned. Gautam Mani
|
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.
|
immediately.
|
||||||
|
|
||||||
* Allow the http_proxy (and other) environment variables to contain user and
|
* Allow the http_proxy (and other) environment variables to contain user and
|
||||||
@@ -66,8 +57,7 @@ TODO
|
|||||||
LIBCURL - multi interface
|
LIBCURL - multi interface
|
||||||
|
|
||||||
* Make sure we don't ever loop because of non-blocking sockets return
|
* Make sure we don't ever loop because of non-blocking sockets return
|
||||||
EWOULDBLOCK or similar. This concerns the HTTP request sending (and
|
EWOULDBLOCK or similar. This FTP command sending etc.
|
||||||
especially regular HTTP POST), the FTP command sending etc.
|
|
||||||
|
|
||||||
* Make uploads treated better. We need a way to tell libcurl we have data to
|
* 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
|
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
|
receiver will convert the data from the standard form to his own internal
|
||||||
form."
|
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
|
* 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
|
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,
|
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
|
also prevents the authentication info from getting sent when following
|
||||||
locations to legitimate other host names.
|
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: NTLM. Support for that MS crap called NTLM
|
||||||
authentication. MS proxies and servers sometime require that. Since that
|
authentication. MS proxies and servers sometime require that. Since that
|
||||||
protocol is a proprietary one, it involves reverse engineering and network
|
protocol is a proprietary one, it involves reverse engineering and network
|
||||||
|
10
docs/curl.1
10
docs/curl.1
@@ -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.
|
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.
|
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"
|
.IP "--crlf"
|
||||||
(FTP) Convert LF to CRLF in upload. Useful for MVS (OS/390).
|
(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
|
default. This makes all connections considered "insecure" to fail unless
|
||||||
-k/--insecure is used.
|
-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.
|
If this option is used twice, the second time will again disable it.
|
||||||
.IP "--krb4 <level>"
|
.IP "--krb4 <level>"
|
||||||
(FTP) Enable kerberos4 authentication and use. The level must be entered and
|
(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"
|
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.
|
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"
|
.IP "-O/--remote-name"
|
||||||
Write output to a local file named like the remote file we get. (Only
|
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.)
|
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
|
.IP 18
|
||||||
Partial file. Only a part of the file was transfered.
|
Partial file. Only a part of the file was transfered.
|
||||||
.IP 19
|
.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
|
.IP 20
|
||||||
FTP write error. The transfer was reported bad by the server.
|
FTP write error. The transfer was reported bad by the server.
|
||||||
.IP 21
|
.IP 21
|
||||||
|
@@ -83,7 +83,8 @@ int main(int argc, char **argv)
|
|||||||
default:
|
default:
|
||||||
/* one or more of curl's file descriptors say there's data to read
|
/* one or more of curl's file descriptors say there's data to read
|
||||||
or write */
|
or write */
|
||||||
curl_multi_perform(multi_handle, &still_running);
|
while(CURLM_CALL_MULTI_PERFORM ==
|
||||||
|
curl_multi_perform(multi_handle, &still_running));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,8 @@ int main(int argc, char **argv)
|
|||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
/* timeout or readable/writable sockets */
|
/* 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,8 @@ int main(int argc, char **argv)
|
|||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
/* timeout or readable/writable sockets */
|
/* 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
|
|||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(curl) {
|
if(curl) {
|
||||||
/* what call to write: */
|
/* 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);
|
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
|
||||||
|
|
||||||
while(1) /* do some ugly short cut... */
|
while(1) /* do some ugly short cut... */
|
||||||
|
@@ -232,6 +232,7 @@ Multi-threading issues
|
|||||||
For SIGPIPE info see the UNIX Socket FAQ at
|
For SIGPIPE info see the UNIX Socket FAQ at
|
||||||
http://www.unixguide.net/network/socketfaq/2.22.shtml
|
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
|
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,
|
possible of your code that uses libcurl, operating system name and version,
|
||||||
compiler name and version etc.
|
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,
|
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
|
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
|
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);
|
curl_easy_setopt(easyhandle, CURLOPT_UPLOAD, TRUE);
|
||||||
|
|
||||||
A few protocols won't behave properly when uploads are done without any prior
|
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
|
knowledge of the expected file size. So, set the upload file size using the
|
||||||
upload file size using the CURLOPT_INFILESIZE like this:
|
CURLOPT_INFILESIZE for all known file sizes like this[1]:
|
||||||
|
|
||||||
curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE, file_size);
|
curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE, file_size);
|
||||||
|
|
||||||
@@ -404,7 +408,7 @@ HTTP POSTing
|
|||||||
headers = curl_slist_append(headers, "Content-Type: text/xml");
|
headers = curl_slist_append(headers, "Content-Type: text/xml");
|
||||||
|
|
||||||
/* post binary data */
|
/* post binary data */
|
||||||
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELD, binaryptr);
|
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, binaryptr);
|
||||||
|
|
||||||
/* set the size of the postfields data */
|
/* set the size of the postfields data */
|
||||||
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, 23);
|
curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, 23);
|
||||||
@@ -726,6 +730,35 @@ Persistancy Is The Way to Happiness
|
|||||||
CURLOPT_FORBID_REUSE to TRUE.
|
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
|
Customizing Operations
|
||||||
|
|
||||||
There is an ongoing development today where more and more protocols are built
|
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.
|
libcurl is your friend here too.
|
||||||
|
|
||||||
If just changing the actual HTTP request keyword is what you want, like when
|
CUSTOMREQUEST
|
||||||
GET, HEAD or POST is not good enough for you, CURLOPT_CUSTOMREQUEST is there
|
|
||||||
for you. It is very simple to use:
|
|
||||||
|
|
||||||
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
|
curl_easy_setopt(easyhandle, CURLOPT_CUSTOMREQUEST, "MYOWNRUQUEST");
|
||||||
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.
|
|
||||||
|
|
||||||
HTTP-like protocols pass a series of headers to the server when doing the
|
When using the custom request, you change the request keyword of the
|
||||||
request, and you're free to pass any amount of extra headers that you think
|
actual request you are performing. Thus, by default you make GET request
|
||||||
fit. Adding headers are this easy:
|
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?");
|
HTTP-like protocols pass a series of headers to the server when doing the
|
||||||
headers = curl_slist_append(headers, "X-silly-content: yes");
|
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 */
|
struct curl_slist *headers=NULL; /* init to NULL is important */
|
||||||
curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);
|
|
||||||
|
|
||||||
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
|
curl_easy_perform(easyhandle); /* transfer http */
|
||||||
User-Agent:, 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, "User-Agent: 007");
|
curl_slist_free_all(headers); /* free the header list */
|
||||||
headers = curl_slist_append(headers, "Host: munged.host.line");
|
|
||||||
|
|
||||||
If you replace an existing header with one with no contents, you will prevent
|
... and if you think some of the internally generated headers, such as
|
||||||
the header from being sent. Like if you want to completely prevent the
|
Accept: or Host: don't contain the data you want them to contain, you can
|
||||||
"Accept:" header to be sent, you can disable it with code similar to this:
|
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
|
Delete Headers
|
||||||
consideration and you should be aware that you may violate the HTTP protocol
|
|
||||||
when doing so.
|
|
||||||
|
|
||||||
There's only one aspect left in the HTTP requests that we haven't yet
|
If you replace an existing header with one with no contents, you will
|
||||||
mentioned how to modify: the version field. All HTTP requests includes the
|
prevent the header from being sent. Like if you want to completely prevent
|
||||||
version number to tell the server which version we support. libcurl speak
|
the "Accept:" header to be sent, you can disable it with code similar to
|
||||||
HTTP 1.1 by default. Some very old servers don't like getting 1.1-requests
|
this:
|
||||||
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_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
|
Both replacing and cancelling internal headers should be done with careful
|
||||||
want to make for example your FTP transfers to behave differently.
|
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
|
Enforcing chunked transfer-encoding
|
||||||
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.
|
|
||||||
|
|
||||||
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 */
|
There's only one aspect left in the HTTP requests that we haven't yet
|
||||||
curl_easy_setopt(easyhandle, CURLOPT_QUOTE, headers);
|
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
|
Not all protocols are HTTP-like, and thus the above may not help you when
|
||||||
_after_ the data transfer took place the option to curl_easy_setopt() would
|
you want to make for example your FTP transfers to behave differently.
|
||||||
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
|
Sending custom commands to a FTP server means that you need to send the
|
||||||
are added to the list, and if a command gets an error code returned back from
|
comands exactly as the FTP server expects them (RFC959 is a good guide
|
||||||
the server, no more commands will be issued and libcurl will bail out with an
|
here), and you can only use commands that work on the control-connection
|
||||||
error code (CURLE_FTP_QUOTE_ERROR). Note that if you use CURLOPT_QUOTE to
|
alone. All kinds of commands that requires data interchange and thus needs
|
||||||
send commands before a transfer, no transfer will actually take place when a
|
a data-connection must be left to libcurl's own judgement. Also be aware
|
||||||
quote command has failed.
|
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
|
A little example that deletes a given file before an operation:
|
||||||
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
|
headers = curl_slist_append(headers, "DELE file-to-remove");
|
||||||
combine with CURLOPT_NOBODY. If this option is set, no actual file content
|
|
||||||
transfer will be performed.
|
/* 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
|
Cookies Without Chocolate Chips
|
||||||
@@ -1007,19 +1068,30 @@ SSL, Certificates and Other Tricks
|
|||||||
|
|
||||||
[ seeding, passwords, keys, certificates, ENGINE, ca certs ]
|
[ 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
|
Future
|
||||||
|
|
||||||
[ multi interface, sharing between handles, mutexes, pipelining ]
|
[ sharing between handles, mutexes, pipelining ]
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
Footnotes:
|
Footnotes:
|
||||||
|
|
||||||
[1] = HTTP PUT without knowing the size prior to transfer is indeed possible,
|
[1] = libcurl 7.10.3 and later have the ability to switch over to chunked
|
||||||
but libcurl does not support the chunked transfers on uploading that is
|
Tranfer-Encoding in cases were HTTP uploads are done with data of an
|
||||||
necessary for this feature to work. We'd gratefully appreciate patches
|
unknown size.
|
||||||
that bring this functionality...
|
|
||||||
|
|
||||||
[2] = This happens on Windows machines when libcurl is built and used as a
|
[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
|
DLL. However, you can still do this on Windows if you link with a static
|
||||||
|
@@ -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,
|
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
|
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)
|
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
|
.PP
|
||||||
|
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
If the operation was successful, CURLE_OK is returned. Otherwise an
|
If the operation was successful, CURLE_OK is returned. Otherwise an
|
||||||
appropriate error code will be returned.
|
appropriate error code will be returned.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
.\" nroff -man [file]
|
.\" nroff -man [file]
|
||||||
.\" $Id$
|
.\" $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
|
.SH NAME
|
||||||
curl_easy_setopt - set options for a curl easy handle
|
curl_easy_setopt - set options for a curl easy handle
|
||||||
.SH SYNOPSIS
|
.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( 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
|
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
|
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
|
multiplied with \fInmemb\fP, it will not be zero terminated. Return the number
|
||||||
of. If that amount differs from the amount passed to your function, it'll
|
of bytes actually taken care of. If that amount differs from the amount passed
|
||||||
signal an error to the library and it will abort the transfer and return
|
to your function, it'll signal an error to the library and it will abort the
|
||||||
\fICURLE_WRITE_ERROR\fP.
|
transfer and return \fICURLE_WRITE_ERROR\fP.
|
||||||
|
|
||||||
Set the \fIstream\fP argument with the \fBCURLOPT_FILE\fP option.
|
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
|
This function will receive debug information if CURLOPT_VERBOSE is
|
||||||
enabled. The curl_infotype argument specifies what kind of information it
|
enabled. The curl_infotype argument specifies what kind of information it
|
||||||
is. This funtion must return 0.
|
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
|
.TP
|
||||||
.B CURLOPT_DEBUGDATA
|
.B CURLOPT_DEBUGDATA
|
||||||
Pass a pointer to whatever you want passed in to your CURLOPT_DEBUGFUNCTION in
|
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
|
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
|
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
|
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
|
\fBNOTE:\fPThe most commonly replaced headers have "shortcuts" in the options
|
||||||
CURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER.
|
CURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER.
|
||||||
.TP
|
.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
|
.B CURLOPT_COOKIE
|
||||||
Pass a pointer to a zero terminated string as parameter. It will be used to
|
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
|
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.
|
servers make this difficult why you at times may have to use this option.
|
||||||
.TP
|
.TP
|
||||||
.B CURLOPT_SSL_VERIFYPEER
|
.B CURLOPT_SSL_VERIFYPEER
|
||||||
Pass a long that is set to a non-zero value to make curl verify the peer's
|
Pass a long that is set to a zero value to stop curl from verifying the peer's
|
||||||
certificate. The certificate to verify against must be specified with the
|
certificate (7.10 starting setting this option to TRUE by default). Alternate
|
||||||
CURLOPT_CAINFO option (Added in 7.4.2) or a certificate directory must be specified
|
certificates to verify against can be specified with the CURLOPT_CAINFO option
|
||||||
with the CURLOPT_CAPATH option (Added in 7.9.8).
|
(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
|
.TP
|
||||||
.B CURLOPT_CAINFO
|
.B CURLOPT_CAINFO
|
||||||
Pass a char * to a zero terminated string naming a file holding one or more
|
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
|
.B CURLOPT_SSL_VERIFYHOST
|
||||||
Pass a long. Set if we should verify the Common name from the peer certificate
|
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
|
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
|
.TP
|
||||||
.B CURLOPT_SSL_CIPHER_LIST
|
.B CURLOPT_SSL_CIPHER_LIST
|
||||||
Pass a char *, pointing to a zero terminated string holding the list of
|
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
|
will be used. Set the string to NULL to disable kerberos4. The kerberos
|
||||||
support only works for FTP. (Added in 7.3)
|
support only works for FTP. (Added in 7.3)
|
||||||
.PP
|
.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
|
.SH RETURN VALUE
|
||||||
CURLE_OK (zero) means that the option was set properly, non-zero means an
|
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
|
error occurred as \fI<curl/curl.h>\fP defines. See the \fIlibcurl-errors.3\fP
|
||||||
|
@@ -19,6 +19,12 @@ integer-pointer.
|
|||||||
.SH "RETURN VALUE"
|
.SH "RETURN VALUE"
|
||||||
CURLMcode type, general libcurl multi interface error code.
|
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
|
NOTE that this only returns errors etc regarding the whole multi stack. There
|
||||||
might still have occurred problems on invidual transfers even when this
|
might still have occurred problems on invidual transfers even when this
|
||||||
function returns OK.
|
function returns OK.
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
.\" nroff -man [file]
|
.\" nroff -man [file]
|
||||||
.\" $Id$
|
.\" $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
|
.SH NAME
|
||||||
error codes in libcurl
|
error codes in libcurl
|
||||||
.SH DESCRIPTION
|
.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
|
When sending custom "QUOTE" commands to the remote server, one of the commands
|
||||||
returned an error code that was 400 or higher.
|
returned an error code that was 400 or higher.
|
||||||
.TP
|
.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
|
This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server
|
||||||
returns an error code that is >= 400.
|
returns an error code that is >= 400.
|
||||||
.TP
|
.TP
|
||||||
|
@@ -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
|
A little note here about the return codes from the multi functions, and
|
||||||
especially the \fIcurl_multi_perform\fP: if you receive
|
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, this basicly means that you should call
|
||||||
\fIcurlm_call_multi_perform\fP again, before you select() on more actions. You
|
\fIcurl_multi_perform\fP again, before you select() on more actions. You don't
|
||||||
don't have to do it immediately, but the return code means that libcurl may
|
have to do it immediately, but the return code means that libcurl may have
|
||||||
have more data available to return or that there may be more data to send off
|
more data available to return or that there may be more data to send off
|
||||||
before it is "satisfied".
|
before it is "satisfied".
|
||||||
|
|
||||||
\fIcurl_multi_perform\fP stores the number of still running transfers in one
|
\fIcurl_multi_perform\fP stores the number of still running transfers in one
|
||||||
|
@@ -66,9 +66,9 @@ struct curl_httppost {
|
|||||||
char *contents; /* pointer to allocated data contents */
|
char *contents; /* pointer to allocated data contents */
|
||||||
long contentslength; /* length of contents field */
|
long contentslength; /* length of contents field */
|
||||||
|
|
||||||
/* CMC: Added support for buffer uploads */
|
/* CMC: Added support for buffer uploads */
|
||||||
char *buffer; /* pointer to allocated buffer contents */
|
char *buffer; /* pointer to allocated buffer contents */
|
||||||
long bufferlength; /* length of buffer field */
|
long bufferlength; /* length of buffer field */
|
||||||
|
|
||||||
char *contenttype; /* Content-Type */
|
char *contenttype; /* Content-Type */
|
||||||
struct curl_slist* contentheader; /* list of extra headers for this form */
|
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 ultotal,
|
||||||
double ulnow);
|
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,
|
typedef size_t (*curl_write_callback)(char *buffer,
|
||||||
size_t size,
|
size_t size,
|
||||||
@@ -160,7 +162,7 @@ typedef enum {
|
|||||||
CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
|
CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
|
||||||
CURLE_FTP_WRITE_ERROR, /* 20 */
|
CURLE_FTP_WRITE_ERROR, /* 20 */
|
||||||
CURLE_FTP_QUOTE_ERROR, /* 21 */
|
CURLE_FTP_QUOTE_ERROR, /* 21 */
|
||||||
CURLE_HTTP_NOT_FOUND, /* 22 */
|
CURLE_HTTP_RETURNED_ERROR, /* 22 */
|
||||||
CURLE_WRITE_ERROR, /* 23 */
|
CURLE_WRITE_ERROR, /* 23 */
|
||||||
CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */
|
CURLE_MALFORMAT_USER, /* 24 - user name is illegally specified */
|
||||||
CURLE_FTP_COULDNT_STOR_FILE, /* 25 - failed FTP upload */
|
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 */
|
/* Make a spelling correction for the operation timed-out define */
|
||||||
#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED
|
#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED
|
||||||
|
#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CURLPROXY_HTTP = 0,
|
CURLPROXY_HTTP = 0,
|
||||||
@@ -610,6 +613,11 @@ typedef enum {
|
|||||||
the response to be compressed. */
|
the response to be compressed. */
|
||||||
CINIT(ENCODING, OBJECTPOINT, 102),
|
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 */
|
CURLOPT_LASTENTRY /* the last unused */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
@@ -803,8 +811,8 @@ CURLcode curl_global_init(long flags);
|
|||||||
void curl_global_cleanup(void);
|
void curl_global_cleanup(void);
|
||||||
|
|
||||||
/* This is the version number */
|
/* This is the version number */
|
||||||
#define LIBCURL_VERSION "7.10.2"
|
#define LIBCURL_VERSION "7.10.3"
|
||||||
#define LIBCURL_VERSION_NUM 0x070a02
|
#define LIBCURL_VERSION_NUM 0x070a03
|
||||||
|
|
||||||
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
||||||
struct curl_slist {
|
struct curl_slist {
|
||||||
@@ -861,16 +869,13 @@ typedef enum {
|
|||||||
CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
|
CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
|
||||||
CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
|
CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
|
||||||
|
|
||||||
|
CURLINFO_PRIVATE = CURLINFO_STRING + 21,
|
||||||
|
|
||||||
/* Fill in new entries here! */
|
/* Fill in new entries here! */
|
||||||
|
|
||||||
CURLINFO_LASTONE = 21
|
CURLINFO_LASTONE = 22
|
||||||
} CURLINFO;
|
} 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 {
|
typedef enum {
|
||||||
CURLCLOSEPOLICY_NONE, /* first, never use this */
|
CURLCLOSEPOLICY_NONE, /* first, never use this */
|
||||||
|
|
||||||
@@ -894,35 +899,56 @@ typedef enum {
|
|||||||
* Setup defines, protos etc for the sharing stuff.
|
* 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 {
|
typedef enum {
|
||||||
CURL_LOCK_TYPE_NONE = 0,
|
CURL_LOCK_DATA_NONE = 0,
|
||||||
CURL_LOCK_TYPE_COOKIE = 1<<0,
|
CURL_LOCK_DATA_COOKIE = 1,
|
||||||
CURL_LOCK_TYPE_DNS = 1<<1,
|
CURL_LOCK_DATA_DNS = 2,
|
||||||
CURL_LOCK_TYPE_SSL_SESSION = 2<<1,
|
CURL_LOCK_DATA_SSL_SESSION = 3,
|
||||||
CURL_LOCK_TYPE_CONNECT = 2<<2,
|
CURL_LOCK_DATA_CONNECT = 4,
|
||||||
CURL_LOCK_TYPE_LAST
|
CURL_LOCK_DATA_LAST
|
||||||
} curl_lock_type;
|
} curl_lock_data;
|
||||||
|
|
||||||
typedef void (*curl_lock_function)(CURL *, curl_lock_type, void *);
|
/* Different lock access types */
|
||||||
typedef void (*curl_unlock_function)(CURL *, curl_lock_type, void *);
|
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 {
|
typedef void (*curl_lock_function)(CURL *handle,
|
||||||
unsigned int specifier;
|
curl_lock_data data,
|
||||||
unsigned int locked;
|
curl_lock_access access,
|
||||||
unsigned int dirty;
|
void *userptr);
|
||||||
|
typedef void (*curl_unlock_function)(CURL *handle,
|
||||||
curl_lock_function lockfunc;
|
curl_lock_data data,
|
||||||
curl_unlock_function unlockfunc;
|
void *userptr);
|
||||||
void *clientdata;
|
|
||||||
} curl_share;
|
|
||||||
|
|
||||||
curl_share *curl_share_init (void);
|
typedef void CURLSH;
|
||||||
CURLcode curl_share_setopt (curl_share *, curl_lock_type, int);
|
|
||||||
CURLcode curl_share_set_lock_function (curl_share *, curl_lock_function);
|
typedef enum {
|
||||||
CURLcode curl_share_set_unlock_function (curl_share *, curl_unlock_function);
|
CURLSHE_OK, /* all is fine */
|
||||||
CURLcode curl_share_set_lock_data (curl_share *, void *);
|
CURLSHE_BAD_OPTION, /* 1 */
|
||||||
CURLcode curl_share_destroy (curl_share *);
|
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.
|
* Structures for querying information about the curl library at runtime.
|
||||||
@@ -965,4 +991,9 @@ curl_version_info_data *curl_version_info(CURLversion);
|
|||||||
}
|
}
|
||||||
#endif
|
#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 */
|
#endif /* __CURL_CURL_H */
|
||||||
|
@@ -5,4 +5,5 @@ Makefile
|
|||||||
.deps
|
.deps
|
||||||
.libs
|
.libs
|
||||||
config.h
|
config.h
|
||||||
stamp-h1
|
stamp-*
|
||||||
|
ca-bundle.h
|
||||||
|
@@ -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 \
|
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 \
|
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 \
|
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
|
noinst_HEADERS = setup.h transfer.h
|
||||||
|
|
||||||
|
@@ -59,7 +59,11 @@ SOURCES = \
|
|||||||
easy.c \
|
easy.c \
|
||||||
strequal.c \
|
strequal.c \
|
||||||
strtok.c \
|
strtok.c \
|
||||||
connect.c
|
connect.c \
|
||||||
|
hash.c \
|
||||||
|
llist.c \
|
||||||
|
multi.c \
|
||||||
|
content_encoding.c
|
||||||
|
|
||||||
OBJECTS = $(SOURCES:.c=.obj)
|
OBJECTS = $(SOURCES:.c=.obj)
|
||||||
|
|
||||||
|
@@ -28,4 +28,8 @@
|
|||||||
+easy.obj &
|
+easy.obj &
|
||||||
+strequal.obj &
|
+strequal.obj &
|
||||||
+strtok.obj &
|
+strtok.obj &
|
||||||
+connect.obj
|
+connect.obj &
|
||||||
|
+hash.obj &
|
||||||
|
+llist.obj &
|
||||||
|
+multi.obj &
|
||||||
|
+content_encoding.obj
|
||||||
|
@@ -116,7 +116,7 @@ CFGSET = TRUE
|
|||||||
!IF "$(CFG)" == "debug-dll"
|
!IF "$(CFG)" == "debug-dll"
|
||||||
TARGET =$(LIB_NAME_DEBUG).dll
|
TARGET =$(LIB_NAME_DEBUG).dll
|
||||||
DIROBJ =.\$(CFG)
|
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)
|
CC = $(CCDEBUG)
|
||||||
CFGSET = TRUE
|
CFGSET = TRUE
|
||||||
!ENDIF
|
!ENDIF
|
||||||
@@ -139,7 +139,8 @@ CFGSET = TRUE
|
|||||||
!IF "$(CFG)" == "debug-ssl-dll"
|
!IF "$(CFG)" == "debug-ssl-dll"
|
||||||
TARGET =$(LIB_NAME_DEBUG).dll
|
TARGET =$(LIB_NAME_DEBUG).dll
|
||||||
DIROBJ =.\$(CFG)
|
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)
|
LINKLIBS = $(LINKLIBS) $(SSLLIBS)
|
||||||
CC = $(CCDEBUG) $(CFLAGSSSL)
|
CC = $(CCDEBUG) $(CFLAGSSSL)
|
||||||
CFGSET = TRUE
|
CFGSET = TRUE
|
||||||
|
98
lib/base64.c
98
lib/base64.c
@@ -61,6 +61,8 @@ static void decodeQuantum(unsigned char *dest, char *src)
|
|||||||
x = (x << 6) + 62;
|
x = (x << 6) + 62;
|
||||||
else if(src[i] == '/')
|
else if(src[i] == '/')
|
||||||
x = (x << 6) + 63;
|
x = (x << 6) + 63;
|
||||||
|
else if(src[i] == '=')
|
||||||
|
x = (x << 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest[2] = (unsigned char)(x & 255); x >>= 8;
|
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 length = 0;
|
||||||
int equalsTerm = 0;
|
int equalsTerm = 0;
|
||||||
int i;
|
int i;
|
||||||
|
int numQuantums;
|
||||||
unsigned char lastQuantum[3];
|
unsigned char lastQuantum[3];
|
||||||
|
|
||||||
while((src[length] != '=') && src[length])
|
while((src[length] != '=') && src[length])
|
||||||
@@ -85,16 +88,18 @@ static void base64Decode(unsigned char *dest, char *src, int *rawLength)
|
|||||||
while(src[length+equalsTerm] == '=')
|
while(src[length+equalsTerm] == '=')
|
||||||
equalsTerm++;
|
equalsTerm++;
|
||||||
|
|
||||||
|
numQuantums = (length + equalsTerm) / 4;
|
||||||
if(rawLength)
|
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);
|
decodeQuantum(dest, src);
|
||||||
dest += 3; src += 4;
|
dest += 3; src += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
decodeQuantum(lastQuantum, src);
|
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
|
#define TEST_NEED_SUCK
|
||||||
void *suck(int *);
|
void *suck(int *);
|
||||||
|
|
||||||
int main(int argc, char **argv, char **envp) {
|
int main(int argc, char **argv, char **envp)
|
||||||
char *base64;
|
{
|
||||||
int base64Len;
|
char *base64;
|
||||||
unsigned char *data;
|
int base64Len;
|
||||||
int dataLen;
|
unsigned char *data;
|
||||||
|
int dataLen;
|
||||||
|
|
||||||
data = (unsigned char *)suck(&dataLen);
|
data = (unsigned char *)suck(&dataLen);
|
||||||
base64Len = Curl_base64_encode(data, dataLen, &base64);
|
base64Len = Curl_base64_encode(data, dataLen, &base64);
|
||||||
|
|
||||||
fprintf(stderr, "%d\n", base64Len);
|
fprintf(stderr, "%d\n", base64Len);
|
||||||
fprintf(stdout, "%s", base64);
|
fprintf(stdout, "%s", base64);
|
||||||
|
|
||||||
free(base64); free(data);
|
free(base64); free(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -220,47 +226,47 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
#define TEST_NEED_SUCK
|
#define TEST_NEED_SUCK
|
||||||
void *suck(int *);
|
void *suck(int *);
|
||||||
|
|
||||||
int main(int argc, char **argv, char **envp) {
|
int main(int argc, char **argv, char **envp)
|
||||||
char *base64;
|
{
|
||||||
int base64Len;
|
char *base64;
|
||||||
unsigned char *data;
|
int base64Len;
|
||||||
int dataLen;
|
unsigned char *data;
|
||||||
|
int dataLen;
|
||||||
|
|
||||||
base64 = (char *)suck(&base64Len);
|
base64 = (char *)suck(&base64Len);
|
||||||
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
|
data = (unsigned char *)malloc(base64Len * 3/4 + 8);
|
||||||
dataLen = Curl_base64_decode(base64, data);
|
dataLen = Curl_base64_decode(base64, data);
|
||||||
|
|
||||||
fprintf(stderr, "%d\n", dataLen);
|
fprintf(stderr, "%d\n", dataLen);
|
||||||
fwrite(data,1,dataLen,stdout);
|
fwrite(data,1,dataLen,stdout);
|
||||||
|
|
||||||
|
free(base64); free(data);
|
||||||
free(base64); free(data);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TEST_NEED_SUCK
|
#ifdef TEST_NEED_SUCK
|
||||||
/* this function 'sucks' in as much as possible from stdin */
|
/* this function 'sucks' in as much as possible from stdin */
|
||||||
void *suck(int *lenptr) {
|
void *suck(int *lenptr)
|
||||||
int cursize = 8192;
|
{
|
||||||
unsigned char *buf = NULL;
|
int cursize = 8192;
|
||||||
int lastread;
|
unsigned char *buf = NULL;
|
||||||
int len = 0;
|
int lastread;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
cursize *= 2;
|
cursize *= 2;
|
||||||
buf = (unsigned char *)realloc(buf, cursize);
|
buf = (unsigned char *)realloc(buf, cursize);
|
||||||
memset(buf + len, 0, cursize - len);
|
memset(buf + len, 0, cursize - len);
|
||||||
lastread = fread(buf + len, 1, cursize - len, stdin);
|
lastread = fread(buf + len, 1, cursize - len, stdin);
|
||||||
len += lastread;
|
len += lastread;
|
||||||
} while(!feof(stdin));
|
} while(!feof(stdin));
|
||||||
|
|
||||||
lenptr[0] = len;
|
lenptr[0] = len;
|
||||||
return (void *)buf;
|
return (void *)buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* local variables:
|
* local variables:
|
||||||
* eval: (load-file "../curl-mode.el")
|
* eval: (load-file "../curl-mode.el")
|
||||||
|
@@ -176,10 +176,9 @@ int waitconnect(int sockfd, /* socket */
|
|||||||
/* timeout, no connect today */
|
/* timeout, no connect today */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if(FD_ISSET(sockfd, &errfd)) {
|
if(FD_ISSET(sockfd, &errfd))
|
||||||
/* error condition caught */
|
/* error condition caught */
|
||||||
return 2;
|
return 2;
|
||||||
}
|
|
||||||
|
|
||||||
/* we have a connect! */
|
/* we have a connect! */
|
||||||
return 0;
|
return 0;
|
||||||
@@ -380,6 +379,11 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
return CURLE_OPERATION_TIMEOUTED;
|
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 */
|
/* check for connect without timeout as we want to return immediately */
|
||||||
rc = waitconnect(sockfd, 0);
|
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) {
|
if(0 == rc) {
|
||||||
int err = socketerror(sockfd);
|
int err = socketerror(sockfd);
|
||||||
if ((0 == err) || (EISCONN == err)) {
|
if ((0 == err) || (EISCONN == err)) {
|
||||||
@@ -658,12 +671,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(0 != rc) {
|
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 */
|
/* get a new timeout for next attempt */
|
||||||
after = Curl_tvnow();
|
after = Curl_tvnow();
|
||||||
timeout_ms -= Curl_tvdiff(after, before);
|
timeout_ms -= Curl_tvdiff(after, before);
|
||||||
|
@@ -31,19 +31,19 @@ RSC=rc.exe
|
|||||||
|
|
||||||
!IF "$(CFG)" == "curllib - Win32 Release"
|
!IF "$(CFG)" == "curllib - Win32 Release"
|
||||||
|
|
||||||
# PROP BASE Use_MFC 6
|
# PROP BASE Use_MFC 0
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
# PROP BASE Output_Dir "Release"
|
# PROP BASE Output_Dir "Release"
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
# PROP BASE Target_Dir ""
|
# PROP BASE Target_Dir ""
|
||||||
# PROP Use_MFC 6
|
# PROP Use_MFC 0
|
||||||
# PROP Use_Debug_Libraries 0
|
# PROP Use_Debug_Libraries 0
|
||||||
# PROP Output_Dir "Release"
|
# PROP Output_Dir "Release"
|
||||||
# PROP Intermediate_Dir "Release"
|
# PROP Intermediate_Dir "Release"
|
||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# 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 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
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
# ADD 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 Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# 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 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
|
# SUBTRACT CPP /WX /YX
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
14
lib/easy.c
14
lib/easy.c
@@ -233,15 +233,17 @@ CURLcode curl_easy_perform(CURL *curl)
|
|||||||
{
|
{
|
||||||
struct SessionHandle *data = (struct SessionHandle *)curl;
|
struct SessionHandle *data = (struct SessionHandle *)curl;
|
||||||
|
|
||||||
if (!data->hostcache) {
|
if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) {
|
||||||
if (Curl_global_host_cache_use(data)) {
|
if (data->hostcache) {
|
||||||
data->hostcache = Curl_global_host_cache_get();
|
Curl_hash_destroy(data->hostcache);
|
||||||
}
|
|
||||||
else {
|
|
||||||
data->hostcache = Curl_hash_alloc(7, Curl_freeaddrinfo);
|
|
||||||
}
|
}
|
||||||
|
data->hostcache = Curl_global_host_cache_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data->hostcache) {
|
||||||
|
data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
|
||||||
|
}
|
||||||
|
|
||||||
return Curl_perform(data);
|
return Curl_perform(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
lib/escape.c
15
lib/escape.c
@@ -41,6 +41,7 @@ char *curl_escape(const char *string, int length)
|
|||||||
{
|
{
|
||||||
int alloc = (length?length:(int)strlen(string))+1;
|
int alloc = (length?length:(int)strlen(string))+1;
|
||||||
char *ns = malloc(alloc);
|
char *ns = malloc(alloc);
|
||||||
|
char *testing_ptr = NULL;
|
||||||
unsigned char in;
|
unsigned char in;
|
||||||
int newlen = alloc;
|
int newlen = alloc;
|
||||||
int index=0;
|
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 */
|
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||||
if(newlen > alloc) {
|
if(newlen > alloc) {
|
||||||
alloc *= 2;
|
alloc *= 2;
|
||||||
ns = realloc(ns, alloc);
|
testing_ptr = realloc(ns, alloc);
|
||||||
if(!ns)
|
if(!testing_ptr) {
|
||||||
|
free( ns );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ns = testing_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sprintf(&ns[index], "%%%02X", in);
|
sprintf(&ns[index], "%%%02X", in);
|
||||||
|
|
||||||
@@ -80,6 +86,10 @@ char *curl_unescape(const char *string, int length)
|
|||||||
unsigned char in;
|
unsigned char in;
|
||||||
int index=0;
|
int index=0;
|
||||||
unsigned int hex;
|
unsigned int hex;
|
||||||
|
|
||||||
|
if( !ns ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while(--alloc > 0) {
|
while(--alloc > 0) {
|
||||||
in = *string;
|
in = *string;
|
||||||
@@ -97,7 +107,6 @@ char *curl_unescape(const char *string, int length)
|
|||||||
}
|
}
|
||||||
ns[index]=0; /* terminate it */
|
ns[index]=0; /* terminate it */
|
||||||
return ns;
|
return ns;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void curl_free(void *p)
|
void curl_free(void *p)
|
||||||
|
@@ -1319,7 +1319,7 @@ int Curl_FormReader(char *buffer,
|
|||||||
wantedsize = size * nitems;
|
wantedsize = size * nitems;
|
||||||
|
|
||||||
if(!form->data)
|
if(!form->data)
|
||||||
return -1; /* nothing, error, empty */
|
return 0; /* nothing, error, empty */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
247
lib/ftp.c
247
lib/ftp.c
@@ -173,9 +173,9 @@ static CURLcode AllowServerConnect(struct SessionHandle *data,
|
|||||||
* response and extract the relevant return code for the invoking function.
|
* response and extract the relevant return code for the invoking function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Curl_GetFTPResponse(char *buf,
|
CURLcode Curl_GetFTPResponse(int *nreadp, /* return number of bytes read */
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
int *ftpcode)
|
int *ftpcode) /* return the ftp-code */
|
||||||
{
|
{
|
||||||
/* Brand new implementation.
|
/* Brand new implementation.
|
||||||
* We cannot read just one byte per read() and then go back to select()
|
* 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. */
|
* line in a response or continue reading. */
|
||||||
|
|
||||||
int sockfd = conn->firstsocket;
|
int sockfd = conn->firstsocket;
|
||||||
int nread; /* total size read */
|
|
||||||
int perline; /* count bytes per line */
|
int perline; /* count bytes per line */
|
||||||
bool keepon=TRUE;
|
bool keepon=TRUE;
|
||||||
ssize_t gotbytes;
|
ssize_t gotbytes;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int timeout = 3600; /* default timeout in seconds */
|
int timeout; /* timeout in seconds */
|
||||||
struct timeval interval;
|
struct timeval interval;
|
||||||
fd_set rkeepfd;
|
fd_set rkeepfd;
|
||||||
fd_set readfd;
|
fd_set readfd;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
char *line_start;
|
char *line_start;
|
||||||
int code=0; /* default "error code" to return */
|
int code=0; /* default ftp "error code" to return */
|
||||||
|
char *buf = data->state.buffer;
|
||||||
#define SELECT_OK 0
|
CURLcode result = CURLE_OK;
|
||||||
#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;
|
|
||||||
|
|
||||||
struct FTP *ftp = conn->proto.ftp;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
|
struct timeval now = Curl_tvnow();
|
||||||
|
|
||||||
if (ftpcode)
|
if (ftpcode)
|
||||||
*ftpcode = 0; /* 0 for errors */
|
*ftpcode = 0; /* 0 for errors */
|
||||||
@@ -221,20 +214,25 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
ptr=buf;
|
ptr=buf;
|
||||||
line_start = buf;
|
line_start = buf;
|
||||||
|
|
||||||
nread=0;
|
*nreadp=0;
|
||||||
perline=0;
|
perline=0;
|
||||||
keepon=TRUE;
|
keepon=TRUE;
|
||||||
|
|
||||||
while((nread<BUFSIZE) && (keepon && !error)) {
|
while((*nreadp<BUFSIZE) && (keepon && !result)) {
|
||||||
/* check and reset timeout value every lap */
|
/* 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 */
|
/* if timeout is requested, find out how much remaining time we have */
|
||||||
timeout = data->set.timeout - /* timeout time */
|
timeout = data->set.timeout - /* timeout time */
|
||||||
Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */
|
Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */
|
||||||
if(timeout <=0 ) {
|
else
|
||||||
failf(data, "Transfer aborted due to timeout");
|
/* Even without a requested timeout, we only wait response_time
|
||||||
return -SELECT_TIMEOUT; /* already too little 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) {
|
if(!ftp->cache) {
|
||||||
@@ -244,19 +242,18 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
|
|
||||||
switch (select (sockfd+1, &readfd, NULL, NULL, &interval)) {
|
switch (select (sockfd+1, &readfd, NULL, NULL, &interval)) {
|
||||||
case -1: /* select() error, stop reading */
|
case -1: /* select() error, stop reading */
|
||||||
error = SELECT_ERROR;
|
result = CURLE_RECV_ERROR;
|
||||||
failf(data, "Transfer aborted due to select() error");
|
failf(data, "Transfer aborted due to select() error: %d", errno);
|
||||||
break;
|
break;
|
||||||
case 0: /* timeout */
|
case 0: /* timeout */
|
||||||
error = SELECT_TIMEOUT;
|
result = CURLE_OPERATION_TIMEDOUT;
|
||||||
failf(data, "Transfer aborted due to timeout");
|
failf(data, "Transfer aborted due to timeout");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = SELECT_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(SELECT_OK == error) {
|
if(CURLE_OK == result) {
|
||||||
/*
|
/*
|
||||||
* This code previously didn't use the kerberos sec_read() code
|
* 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
|
* 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 */
|
ftp->cache_size = 0; /* zero the size just in case */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int res = Curl_read(conn, sockfd, ptr,
|
int res = Curl_read(conn, sockfd, ptr, BUFSIZE-*nreadp, &gotbytes);
|
||||||
BUFSIZE-nread, &gotbytes);
|
|
||||||
if(res < 0)
|
if(res < 0)
|
||||||
/* EWOULDBLOCK */
|
/* EWOULDBLOCK */
|
||||||
continue; /* go looping again */
|
continue; /* go looping again */
|
||||||
@@ -286,7 +282,7 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
;
|
;
|
||||||
else if(gotbytes <= 0) {
|
else if(gotbytes <= 0) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
error = SELECT_ERROR;
|
result = CURLE_RECV_ERROR;
|
||||||
failf(data, "Connection aborted");
|
failf(data, "Connection aborted");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -295,7 +291,7 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
* line */
|
* line */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
nread += gotbytes;
|
*nreadp += gotbytes;
|
||||||
for(i = 0; i < gotbytes; ptr++, i++) {
|
for(i = 0; i < gotbytes; ptr++, i++) {
|
||||||
perline++;
|
perline++;
|
||||||
if(*ptr=='\n') {
|
if(*ptr=='\n') {
|
||||||
@@ -315,7 +311,7 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
result = Curl_client_write(data, CLIENTWRITE_HEADER,
|
result = Curl_client_write(data, CLIENTWRITE_HEADER,
|
||||||
line_start, perline);
|
line_start, perline);
|
||||||
if(result)
|
if(result)
|
||||||
return -SELECT_CALLBACK;
|
return result;
|
||||||
|
|
||||||
#define lastline(line) (isdigit((int)line[0]) && isdigit((int)line[1]) && \
|
#define lastline(line) (isdigit((int)line[0]) && isdigit((int)line[1]) && \
|
||||||
isdigit((int)line[2]) && (' ' == line[3]))
|
isdigit((int)line[2]) && (' ' == line[3]))
|
||||||
@@ -350,13 +346,13 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
if(ftp->cache)
|
if(ftp->cache)
|
||||||
memcpy(ftp->cache, line_start, ftp->cache_size);
|
memcpy(ftp->cache, line_start, ftp->cache_size);
|
||||||
else
|
else
|
||||||
return -SELECT_MEMORY; /**BANG**/
|
return CURLE_OUT_OF_MEMORY; /**BANG**/
|
||||||
}
|
}
|
||||||
} /* there was data */
|
} /* there was data */
|
||||||
} /* if(no error) */
|
} /* if(no error) */
|
||||||
} /* while there's buffer left and loop is requested */
|
} /* while there's buffer left and loop is requested */
|
||||||
|
|
||||||
if(!error)
|
if(!result)
|
||||||
code = atoi(buf);
|
code = atoi(buf);
|
||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
@@ -378,13 +374,10 @@ int Curl_GetFTPResponse(char *buf,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(error)
|
|
||||||
return -error;
|
|
||||||
|
|
||||||
if(ftpcode)
|
if(ftpcode)
|
||||||
*ftpcode=code; /* return the initial number like this */
|
*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 */
|
/* no need to duplicate them, the data struct won't change */
|
||||||
ftp->user = data->state.user;
|
ftp->user = data->state.user;
|
||||||
ftp->passwd = data->state.passwd;
|
ftp->passwd = data->state.passwd;
|
||||||
|
ftp->response_time = 3600; /* set default response time-out */
|
||||||
|
|
||||||
if (data->set.tunnel_thru_httpproxy) {
|
if (data->set.tunnel_thru_httpproxy) {
|
||||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
/* 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: */
|
/* The first thing we do is wait for the "220*" line: */
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode != 220) {
|
if(ftpcode != 220) {
|
||||||
failf(data, "This doesn't seem like a nice ftp-server response");
|
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);
|
FTPSENDF(conn, "USER %s", ftp->user);
|
||||||
|
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode == 530) {
|
if(ftpcode == 530) {
|
||||||
/* 530 User ... access denied
|
/* 530 User ... access denied
|
||||||
@@ -481,9 +475,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
/* 331 Password required for ...
|
/* 331 Password required for ...
|
||||||
(the server requires to send the user's password too) */
|
(the server requires to send the user's password too) */
|
||||||
FTPSENDF(conn, "PASS %s", ftp->passwd);
|
FTPSENDF(conn, "PASS %s", ftp->passwd);
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode == 530) {
|
if(ftpcode == 530) {
|
||||||
/* 530 Login incorrect.
|
/* 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
|
/* we may need to issue a KAUTH here to have access to the files
|
||||||
* do it if user supplied a password
|
* do it if user supplied a password
|
||||||
*/
|
*/
|
||||||
if(data->state.passwd && *data->state.passwd)
|
if(data->state.passwd && *data->state.passwd) {
|
||||||
Curl_krb_kauth(conn);
|
result = Curl_krb_kauth(conn);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -529,9 +526,9 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
FTPSENDF(conn, "PWD", NULL);
|
FTPSENDF(conn, "PWD", NULL);
|
||||||
|
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode == 257) {
|
if(ftpcode == 257) {
|
||||||
char *dir = (char *)malloc(nread+1);
|
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
|
The directory name can contain any character; embedded double-quotes
|
||||||
should be escaped by double-quotes (the "quote-doubling" convention).
|
should be escaped by double-quotes (the "quote-doubling" convention).
|
||||||
*/
|
*/
|
||||||
if('\"' == *ptr) {
|
if(dir && ('\"' == *ptr)) {
|
||||||
/* it started good */
|
/* it started good */
|
||||||
ptr++;
|
ptr++;
|
||||||
while(ptr && *ptr) {
|
while(ptr && *ptr) {
|
||||||
@@ -570,6 +567,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* couldn't get the path */
|
/* 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 SessionHandle *data = conn->data;
|
||||||
struct FTP *ftp = conn->proto.ftp;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
char *buf = data->state.buffer; /* this is our buffer */
|
|
||||||
int ftpcode;
|
int ftpcode;
|
||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
|
|
||||||
@@ -633,11 +631,24 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
conn->secondarysocket = -1;
|
conn->secondarysocket = -1;
|
||||||
|
|
||||||
if(!ftp->no_transfer) {
|
if(!ftp->no_transfer) {
|
||||||
/* now let's see what the server says about the transfer we just
|
/* Let's see what the server says about the transfer we just performed,
|
||||||
performed: */
|
but lower the timeout as sometimes this connection has died while
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
the data has been transfered. This happens when doing through NATs
|
||||||
if(nread < 0)
|
etc that abandon old silent connections.
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
*/
|
||||||
|
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) {
|
if(!ftp->dont_check) {
|
||||||
/* 226 Transfer complete, 250 Requested file action okay, completed. */
|
/* 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) {
|
if (item->data) {
|
||||||
FTPSENDF(conn, "%s", item->data);
|
FTPSENDF(conn, "%s", item->data);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if (nread < 0)
|
if (result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if (ftpcode >= 400) {
|
if (ftpcode >= 400) {
|
||||||
failf(conn->data, "QUOT string not accepted: %s", item->data);
|
failf(conn->data, "QUOT string not accepted: %s", item->data);
|
||||||
@@ -711,9 +722,9 @@ CURLcode ftp_cwd(struct connectdata *conn, char *path)
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
FTPSENDF(conn, "CWD %s", path);
|
FTPSENDF(conn, "CWD %s", path);
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if (nread < 0)
|
if (result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if (ftpcode != 250) {
|
if (ftpcode != 250) {
|
||||||
failf(conn->data, "Couldn't cd to %s", path);
|
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 */
|
again a grey area as the MDTM is not kosher RFC959 */
|
||||||
FTPSENDF(conn, "MDTM %s", file);
|
FTPSENDF(conn, "MDTM %s", file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode == 213) {
|
switch(ftpcode) {
|
||||||
/* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
|
case 213:
|
||||||
last .sss part is optional and means fractions of a second */
|
{
|
||||||
int year, month, day, hour, minute, second;
|
/* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
|
||||||
if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
|
last .sss part is optional and means fractions of a second */
|
||||||
&year, &month, &day, &hour, &minute, &second)) {
|
int year, month, day, hour, minute, second;
|
||||||
/* we have a time, reformat it */
|
if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
|
||||||
time_t secs=time(NULL);
|
&year, &month, &day, &hour, &minute, &second)) {
|
||||||
sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
|
/* we have a time, reformat it */
|
||||||
year, month, day, hour, minute, second);
|
time_t secs=time(NULL);
|
||||||
/* now, convert this into a time() value: */
|
sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
|
||||||
conn->data->info.filetime = curl_getdate(buf, &secs);
|
year, month, day, hour, minute, second);
|
||||||
}
|
/* now, convert this into a time() value: */
|
||||||
else {
|
conn->data->info.filetime = curl_getdate(buf, &secs);
|
||||||
infof(conn->data, "unsupported MDTM reply format\n");
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -778,14 +797,13 @@ static CURLcode ftp_transfertype(struct connectdata *conn,
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
int ftpcode;
|
int ftpcode;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
char *buf=data->state.buffer;
|
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
FTPSENDF(conn, "TYPE %s", ascii?"A":"I");
|
FTPSENDF(conn, "TYPE %s", ascii?"A":"I");
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode != 200) {
|
if(ftpcode != 200) {
|
||||||
failf(data, "Couldn't set %s mode",
|
failf(data, "Couldn't set %s mode",
|
||||||
@@ -814,9 +832,9 @@ CURLcode ftp_getsize(struct connectdata *conn, char *file,
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
FTPSENDF(conn, "SIZE %s", file);
|
FTPSENDF(conn, "SIZE %s", file);
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode == 213) {
|
if(ftpcode == 213) {
|
||||||
/* get the size from the ascii string: */
|
/* get the size from the ascii string: */
|
||||||
@@ -975,7 +993,6 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||||||
struct SessionHandle *data=conn->data;
|
struct SessionHandle *data=conn->data;
|
||||||
int portsock=-1;
|
int portsock=-1;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
char *buf = data->state.buffer; /* this is our buffer */
|
|
||||||
int ftpcode; /* receive FTP response codes in this */
|
int ftpcode; /* receive FTP response codes in this */
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
@@ -1155,9 +1172,9 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if (ftpcode != 200) {
|
if (ftpcode != 200) {
|
||||||
failf(data, "Server does not grok %s", *modep);
|
failf(data, "Server does not grok %s", *modep);
|
||||||
@@ -1301,9 +1318,9 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode != 200) {
|
if(ftpcode != 200) {
|
||||||
failf(data, "Server does not grok PORT, try without it!");
|
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]);
|
result = Curl_ftpsendf(conn, "%s", mode[modeoff]);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
if (ftpcode == results[modeoff])
|
if (ftpcode == results[modeoff])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1522,7 +1539,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
int ftpcode; /* for ftp status */
|
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;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
long *bytecountp = ftp->bytecountp;
|
long *bytecountp = ftp->bytecountp;
|
||||||
|
|
||||||
@@ -1582,8 +1599,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
readthisamountnow = BUFSIZE;
|
readthisamountnow = BUFSIZE;
|
||||||
|
|
||||||
actuallyread =
|
actuallyread =
|
||||||
data->set.fread(data->state.buffer, 1, readthisamountnow,
|
conn->fread(data->state.buffer, 1, readthisamountnow,
|
||||||
data->set.in);
|
conn->fread_in);
|
||||||
|
|
||||||
passed += actuallyread;
|
passed += actuallyread;
|
||||||
if(actuallyread != readthisamountnow) {
|
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) {
|
if(data->set.ftp_append) {
|
||||||
/* we append onto the file instead of rewriting it */
|
/* we append onto the file instead of rewriting it */
|
||||||
FTPSENDF(conn, "APPE %s", ftp->file);
|
FTPSENDF(conn, "APPE %s", ftp->file);
|
||||||
@@ -1623,9 +1640,9 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
FTPSENDF(conn, "STOR %s", ftp->file);
|
FTPSENDF(conn, "STOR %s", ftp->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode>=400) {
|
if(ftpcode>=400) {
|
||||||
failf(data, "Failed FTP upload:%s", buf+3);
|
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);
|
FTPSENDF(conn, "REST %d", conn->resume_from);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if(ftpcode != 350) {
|
if(ftpcode != 350) {
|
||||||
failf(data, "Couldn't use REST: %s", buf+4);
|
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);
|
FTPSENDF(conn, "RETR %s", ftp->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(buf, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(result)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return result;
|
||||||
|
|
||||||
if((ftpcode == 150) || (ftpcode == 125)) {
|
if((ftpcode == 150) || (ftpcode == 125)) {
|
||||||
|
|
||||||
@@ -1919,7 +1936,7 @@ CURLcode ftp_perform(struct connectdata *conn,
|
|||||||
struct SessionHandle *data=conn->data;
|
struct SessionHandle *data=conn->data;
|
||||||
char *buf = data->state.buffer; /* this is our buffer */
|
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;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
|
|
||||||
/* Send any QUOTE strings? */
|
/* Send any QUOTE strings? */
|
||||||
@@ -1980,7 +1997,7 @@ CURLcode ftp_perform(struct connectdata *conn,
|
|||||||
well, we "emulate" a HTTP-style header in our output. */
|
well, we "emulate" a HTTP-style header in our output. */
|
||||||
|
|
||||||
#ifdef HAVE_STRFTIME
|
#ifdef HAVE_STRFTIME
|
||||||
if(data->set.get_filetime && data->info.filetime) {
|
if(data->set.get_filetime && (data->info.filetime>=0) ) {
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
#ifdef HAVE_LOCALTIME_R
|
#ifdef HAVE_LOCALTIME_R
|
||||||
struct tm buffer;
|
struct tm buffer;
|
||||||
|
@@ -29,8 +29,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn);
|
|||||||
CURLcode Curl_ftp_connect(struct connectdata *conn);
|
CURLcode Curl_ftp_connect(struct connectdata *conn);
|
||||||
CURLcode Curl_ftp_disconnect(struct connectdata *conn);
|
CURLcode Curl_ftp_disconnect(struct connectdata *conn);
|
||||||
CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
|
CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
|
||||||
int Curl_GetFTPResponse(char *buf, struct connectdata *conn,
|
CURLcode Curl_GetFTPResponse(int *nread, struct connectdata *conn,
|
||||||
int *ftpcode);
|
int *ftpcode);
|
||||||
CURLcode Curl_ftp_nextconnect(struct connectdata *conn);
|
CURLcode Curl_ftp_nextconnect(struct connectdata *conn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -158,6 +158,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
|||||||
case CURLINFO_CONTENT_TYPE:
|
case CURLINFO_CONTENT_TYPE:
|
||||||
*param_charp = data->info.contenttype;
|
*param_charp = data->info.contenttype;
|
||||||
break;
|
break;
|
||||||
|
case CURLINFO_PRIVATE:
|
||||||
|
*param_charp = data->set.private?data->set.private:(char *)"";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
44
lib/hostip.c
44
lib/hostip.c
@@ -88,7 +88,7 @@ static Curl_addrinfo *my_getaddrinfo(struct SessionHandle *data,
|
|||||||
void Curl_global_host_cache_init(void)
|
void Curl_global_host_cache_init(void)
|
||||||
{
|
{
|
||||||
if (!host_cache_initialized) {
|
if (!host_cache_initialized) {
|
||||||
Curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo);
|
Curl_hash_init(&hostname_cache, 7, Curl_freednsinfo);
|
||||||
host_cache_initialized = 1;
|
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
|
* This is a wrapper function for freeing name information in a protocol
|
||||||
* independent way. This takes care of using the appropriate underlaying
|
* 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;
|
struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis;
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
Curl_freeaddrinfo(p->addr);
|
||||||
freeaddrinfo(p->addr);
|
|
||||||
#else
|
|
||||||
free(p->addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
@@ -623,16 +631,28 @@ static Curl_addrinfo *my_getaddrinfo(struct SessionHandle *data,
|
|||||||
&h, /* DIFFERENCE */
|
&h, /* DIFFERENCE */
|
||||||
&h_errnop);
|
&h_errnop);
|
||||||
/* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
|
/* 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
|
sudden this function returns EAGAIN if the given buffer size is too
|
||||||
size is too small. Previous versions are known to return ERANGE for
|
small. Previous versions are known to return ERANGE for the same
|
||||||
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)) {
|
if((ERANGE == res) || (EAGAIN == res)) {
|
||||||
step_size+=200;
|
step_size+=200;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while(1);
|
} while(step_size <= CURL_NAMELOOKUP_SIZE);
|
||||||
|
|
||||||
if(!h) /* failure */
|
if(!h) /* failure */
|
||||||
res=1;
|
res=1;
|
||||||
|
@@ -65,7 +65,10 @@ struct Curl_dns_entry *Curl_resolv(struct SessionHandle *data,
|
|||||||
void Curl_scan_cache_used(void *user, void *ptr);
|
void Curl_scan_cache_used(void *user, void *ptr);
|
||||||
|
|
||||||
/* free name info */
|
/* 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
|
#ifdef MALLOCDEBUG
|
||||||
void curl_freeaddrinfo(struct addrinfo *freethis,
|
void curl_freeaddrinfo(struct addrinfo *freethis,
|
||||||
|
303
lib/http.c
303
lib/http.c
@@ -98,12 +98,65 @@
|
|||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
#endif
|
#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
|
* 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
|
* from repeated function invokes. Used so that the entire HTTP request can
|
||||||
* be sent in one go.
|
* 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
|
static CURLcode
|
||||||
add_buffer(send_buffer *in, const void *inptr, size_t size);
|
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.
|
* add_buffer_send() sends a buffer and frees all associated memory.
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
|
CURLcode add_buffer_send(send_buffer *in,
|
||||||
long *bytes_written)
|
int sockfd,
|
||||||
|
struct connectdata *conn,
|
||||||
|
long *bytes_written) /* add the number of sent
|
||||||
|
bytes to this counter */
|
||||||
{
|
{
|
||||||
ssize_t amount;
|
ssize_t amount;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int size;
|
int size;
|
||||||
|
struct HTTP *http = conn->proto.http;
|
||||||
|
|
||||||
/* The looping below is required since we use non-blocking sockets, but due
|
/* 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 */
|
to the circumstances we will just loop and try again and again etc */
|
||||||
|
|
||||||
ptr = in->buffer;
|
ptr = in->buffer;
|
||||||
size = in->size_used;
|
size = in->size_used;
|
||||||
do {
|
|
||||||
res = Curl_write(conn, sockfd, ptr, size, &amount);
|
|
||||||
|
|
||||||
if(CURLE_OK != res)
|
res = Curl_write(conn, sockfd, ptr, size, &amount);
|
||||||
break;
|
|
||||||
|
if(CURLE_OK == res) {
|
||||||
|
|
||||||
if(conn->data->set.verbose)
|
if(conn->data->set.verbose)
|
||||||
/* this data _may_ contain binary stuff */
|
/* this data _may_ contain binary stuff */
|
||||||
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, amount);
|
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, amount);
|
||||||
|
|
||||||
|
*bytes_written += amount;
|
||||||
|
|
||||||
if(amount != size) {
|
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;
|
size -= amount;
|
||||||
ptr += 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)
|
if(in->buffer)
|
||||||
free(in->buffer);
|
free(in->buffer);
|
||||||
free(in);
|
free(in);
|
||||||
|
|
||||||
*bytes_written += amount;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,21 +298,75 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
|
|||||||
/* end of the add_buffer functions */
|
/* 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
|
* This function checks the linked list of custom HTTP headers for a particular
|
||||||
* header (prefix).
|
* header (prefix).
|
||||||
*/
|
*/
|
||||||
static bool checkheaders(struct SessionHandle *data, const char *thisheader)
|
static char *checkheaders(struct SessionHandle *data, const char *thisheader)
|
||||||
{
|
{
|
||||||
struct curl_slist *head;
|
struct curl_slist *head;
|
||||||
size_t thislen = strlen(thisheader);
|
size_t thislen = strlen(thisheader);
|
||||||
|
|
||||||
for(head = data->set.headers; head; head=head->next) {
|
for(head = data->set.headers; head; head=head->next) {
|
||||||
if(strnequal(head->data, thisheader, thislen)) {
|
if(strnequal(head->data, thisheader, thislen))
|
||||||
return TRUE;
|
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) {
|
if(conn->bits.user_passwd && !data->state.this_is_a_follow) {
|
||||||
/* Authorization: is requested, this is not a followed location, get the
|
/* Authorization: is requested, this is not a followed location, get the
|
||||||
original host name */
|
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);
|
data->state.auth_host = strdup(conn->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,13 +587,21 @@ CURLcode Curl_http_done(struct connectdata *conn)
|
|||||||
data=conn->data;
|
data=conn->data;
|
||||||
http=conn->proto.http;
|
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) {
|
if(HTTPREQ_POST_FORM == data->set.httpreq) {
|
||||||
conn->bytecount = http->readbytecount + http->writebytecount;
|
conn->bytecount = http->readbytecount + http->writebytecount;
|
||||||
|
|
||||||
Curl_formclean(http->sendit); /* Now free that whole lot */
|
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)
|
else if(HTTPREQ_PUT == data->set.httpreq)
|
||||||
conn->bytecount = http->readbytecount + http->writebytecount;
|
conn->bytecount = http->readbytecount + http->writebytecount;
|
||||||
@@ -475,7 +616,6 @@ CURLcode Curl_http_done(struct connectdata *conn)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CURLcode Curl_http(struct connectdata *conn)
|
CURLcode Curl_http(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data=conn->data;
|
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 */
|
host due to a location-follow, we do some weirdo checks here */
|
||||||
if(!data->state.this_is_a_follow ||
|
if(!data->state.this_is_a_follow ||
|
||||||
!data->state.auth_host ||
|
!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",
|
sprintf(data->state.buffer, "%s:%s",
|
||||||
data->state.user, data->state.passwd);
|
data->state.user, data->state.passwd);
|
||||||
if(Curl_base64_encode(data->state.buffer, strlen(data->state.buffer),
|
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);
|
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) {
|
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:")) {
|
if(!checkheaders(data, "Transfer-Encoding:")) {
|
||||||
te = "Transfer-Encoding: chunked\r\n";
|
te = "Transfer-Encoding: chunked\r\n";
|
||||||
}
|
}
|
||||||
/* else
|
else {
|
||||||
our header was already added, what to do now? */
|
/* The "Transfer-Encoding:" header was already added. */
|
||||||
|
te = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->cookies) {
|
if(data->cookies) {
|
||||||
@@ -847,16 +1005,16 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
return CURLE_HTTP_POST_ERROR;
|
return CURLE_HTTP_POST_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
http->storefread = data->set.fread; /* backup */
|
/* set the read function to read from the generated form data */
|
||||||
http->in = data->set.in; /* backup */
|
conn->fread = (curl_read_callback)Curl_FormReader;
|
||||||
|
conn->fread_in = &http->form;
|
||||||
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;
|
|
||||||
|
|
||||||
add_bufferf(req_buffer,
|
http->sending = HTTPSEND_BODY;
|
||||||
"Content-Length: %d\r\n", http->postsize);
|
|
||||||
|
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(!checkheaders(data, "Expect:")) {
|
||||||
/* if not disabled explicitly we add a Expect: 100-continue
|
/* 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);
|
Curl_pgrsSetUploadSize(data, http->postsize);
|
||||||
|
|
||||||
/* fire away the whole request to the server */
|
/* 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);
|
&data->info.request_size);
|
||||||
if(result)
|
if(result)
|
||||||
failf(data, "Failed sending POST request");
|
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! */
|
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,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: %d\r\n\r\n", /* file size */
|
"Content-Length: %d\r\n", /* file size */
|
||||||
data->set.infilesize );
|
data->set.infilesize );
|
||||||
}
|
|
||||||
else
|
add_bufferf(req_buffer, "\r\n");
|
||||||
add_bufferf(req_buffer, "\015\012");
|
|
||||||
|
|
||||||
/* set the upload size to the progress meter */
|
/* set the upload size to the progress meter */
|
||||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||||
|
|
||||||
/* this sends the buffer and frees all the buffer resources */
|
/* 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);
|
&data->info.request_size);
|
||||||
if(result)
|
if(result)
|
||||||
failf(data, "Faied sending POST request");
|
failf(data, "Failed sending POST request");
|
||||||
else
|
else
|
||||||
/* prepare for transfer */
|
/* prepare for transfer */
|
||||||
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
||||||
@@ -943,14 +1101,20 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
case HTTPREQ_POST:
|
case HTTPREQ_POST:
|
||||||
/* this is the simple POST, using x-www-form-urlencoded style */
|
/* this is the simple POST, using x-www-form-urlencoded style */
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Length:"))
|
if(!conn->bits.upload_chunky) {
|
||||||
/* we allow replacing this header, although it isn't very wise to
|
/* We only set Content-Length and allow a custom Content-Length if
|
||||||
actually set your own */
|
we don't upload data chunked, as RFC2616 forbids us to set both
|
||||||
add_bufferf(req_buffer,
|
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
||||||
"Content-Length: %d\r\n",
|
|
||||||
data->set.postfieldsize?
|
if(!checkheaders(data, "Content-Length:"))
|
||||||
data->set.postfieldsize:
|
/* we allow replacing this header, although it isn't very wise to
|
||||||
(data->set.postfields?strlen(data->set.postfields):0) );
|
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:"))
|
if(!checkheaders(data, "Content-Type:"))
|
||||||
add_bufferf(req_buffer,
|
add_bufferf(req_buffer,
|
||||||
@@ -958,18 +1122,28 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
add_buffer(req_buffer, "\r\n", 2);
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
|
|
||||||
/* and here comes the actual data */
|
/* and here we setup the pointers to the actual data */
|
||||||
if(data->set.postfieldsize && data->set.postfields) {
|
if(data->set.postfields) {
|
||||||
add_buffer(req_buffer, data->set.postfields,
|
if(data->set.postfieldsize)
|
||||||
data->set.postfieldsize);
|
http->postsize = data->set.postfieldsize;
|
||||||
}
|
else
|
||||||
else if(data->set.postfields)
|
http->postsize = strlen(data->set.postfields);
|
||||||
add_bufferf(req_buffer,
|
http->postdata = data->set.postfields;
|
||||||
"%s",
|
|
||||||
data->set.postfields );
|
|
||||||
|
|
||||||
/* issue the request */
|
http->sending = HTTPSEND_BODY;
|
||||||
result = add_buffer_send(conn->firstsocket, conn, req_buffer,
|
|
||||||
|
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);
|
&data->info.request_size);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
@@ -978,15 +1152,15 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
result =
|
result =
|
||||||
Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
data->set.postfields?-1:conn->firstsocket,
|
conn->firstsocket,
|
||||||
data->set.postfields?NULL:&http->writebytecount);
|
&http->writebytecount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
add_buffer(req_buffer, "\r\n", 2);
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
|
|
||||||
/* issue the request */
|
/* 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);
|
&data->info.request_size);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
@@ -995,7 +1169,8 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
/* HTTP GET/HEAD download: */
|
/* HTTP GET/HEAD download: */
|
||||||
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
-1, NULL); /* nothing to upload */
|
http->postdata?conn->firstsocket:-1,
|
||||||
|
http->postdata?&http->writebytecount:NULL);
|
||||||
}
|
}
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
@@ -24,6 +24,10 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#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 */
|
/* ftp can use this as well */
|
||||||
CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
|
CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
|
||||||
int tunnelsocket,
|
int tunnelsocket,
|
||||||
|
35
lib/if2ip.h
35
lib/if2ip.h
@@ -29,5 +29,40 @@ extern char *Curl_if2ip(char *interface, char *buf, int buf_size);
|
|||||||
#else
|
#else
|
||||||
#define Curl_if2ip(a,b,c) NULL
|
#define Curl_if2ip(a,b,c) NULL
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
52
lib/krb4.c
52
lib/krb4.c
@@ -202,6 +202,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
int l = sizeof(conn->local_addr);
|
int l = sizeof(conn->local_addr);
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
CURLcode result;
|
||||||
|
|
||||||
if(getsockname(conn->firstsocket,
|
if(getsockname(conn->firstsocket,
|
||||||
(struct sockaddr *)LOCAL_ADDR, &l) < 0)
|
(struct sockaddr *)LOCAL_ADDR, &l) < 0)
|
||||||
@@ -246,13 +247,15 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||||||
return AUTH_CONTINUE;
|
return AUTH_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Curl_ftpsendf(conn, "ADAT %s", p))
|
result = Curl_ftpsendf(conn, "ADAT %s", p);
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
if(result)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->state.buffer, conn, NULL);
|
if(Curl_GetFTPResponse(&nread, conn, NULL))
|
||||||
if(nread < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
free(p);
|
|
||||||
|
|
||||||
if(data->state.buffer[0] != '2'){
|
if(data->state.buffer[0] != '2'){
|
||||||
Curl_failf(data, "Server didn't accept auth data");
|
Curl_failf(data, "Server didn't accept auth data");
|
||||||
@@ -299,7 +302,7 @@ struct Curl_sec_client_mech Curl_krb4_client_mech = {
|
|||||||
krb4_decode
|
krb4_decode
|
||||||
};
|
};
|
||||||
|
|
||||||
void Curl_krb_kauth(struct connectdata *conn)
|
CURLcode Curl_krb_kauth(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
des_cblock key;
|
des_cblock key;
|
||||||
des_key_schedule schedule;
|
des_key_schedule schedule;
|
||||||
@@ -309,18 +312,19 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||||||
char passwd[100];
|
char passwd[100];
|
||||||
int tmp;
|
int tmp;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
int save;
|
int save;
|
||||||
|
CURLcode result;
|
||||||
|
|
||||||
save = Curl_set_command_prot(conn, prot_private);
|
save = Curl_set_command_prot(conn, prot_private);
|
||||||
|
|
||||||
if(Curl_ftpsendf(conn, "SITE KAUTH %s", conn->data->state.user))
|
result = Curl_ftpsendf(conn, "SITE KAUTH %s", conn->data->state.user);
|
||||||
return;
|
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer,
|
if(result)
|
||||||
conn, NULL);
|
return result;
|
||||||
if(nread < 0)
|
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/;
|
result = Curl_GetFTPResponse(&nread, conn, NULL);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
|
||||||
if(conn->data->state.buffer[0] != '3'){
|
if(conn->data->state.buffer[0] != '3'){
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
@@ -331,7 +335,7 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||||||
if(!p) {
|
if(!p) {
|
||||||
Curl_failf(conn->data, "Bad reply from server");
|
Curl_failf(conn->data, "Bad reply from server");
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
return;
|
return CURLE_FTP_WEIRD_SERVER_REPLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += 2;
|
p += 2;
|
||||||
@@ -339,7 +343,7 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||||||
if(tmp < 0) {
|
if(tmp < 0) {
|
||||||
Curl_failf(conn->data, "Failed to decode base64 in reply.\n");
|
Curl_failf(conn->data, "Failed to decode base64 in reply.\n");
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
return;
|
return CURLE_FTP_WEIRD_SERVER_REPLY;
|
||||||
}
|
}
|
||||||
tkt.length = tmp;
|
tkt.length = tmp;
|
||||||
tktcopy.length = tkt.length;
|
tktcopy.length = tkt.length;
|
||||||
@@ -348,7 +352,7 @@ void Curl_krb_kauth(struct connectdata *conn)
|
|||||||
if(!p) {
|
if(!p) {
|
||||||
Curl_failf(conn->data, "Bad reply from server");
|
Curl_failf(conn->data, "Bad reply from server");
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
return;
|
return CURLE_FTP_WEIRD_SERVER_REPLY;
|
||||||
}
|
}
|
||||||
name = p + 2;
|
name = p + 2;
|
||||||
for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++);
|
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) {
|
if(Curl_base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) {
|
||||||
failf(conn->data, "Out of memory base64-encoding.");
|
failf(conn->data, "Out of memory base64-encoding.");
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
return;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
memset (tktcopy.dat, 0, tktcopy.length);
|
memset (tktcopy.dat, 0, tktcopy.length);
|
||||||
|
|
||||||
if(Curl_ftpsendf(conn, "SITE KAUTH %s %s", name, p))
|
result = 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*/;
|
|
||||||
free(p);
|
free(p);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
result = Curl_GetFTPResponse(&nread, conn, NULL);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
Curl_set_command_prot(conn, save);
|
Curl_set_command_prot(conn, save);
|
||||||
|
|
||||||
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* KRB4 */
|
#endif /* KRB4 */
|
||||||
|
@@ -22,6 +22,6 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void Curl_krb_kauth(struct connectdata *conn);
|
CURLcode Curl_krb_kauth(struct connectdata *conn);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -313,9 +313,8 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
easy->easy_handle->hostcache = Curl_global_host_cache_get();
|
easy->easy_handle->hostcache = Curl_global_host_cache_get();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (multi->hostcache == NULL) {
|
if (multi->hostcache == NULL)
|
||||||
multi->hostcache = Curl_hash_alloc(7, Curl_freeaddrinfo);
|
multi->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
|
||||||
}
|
|
||||||
|
|
||||||
easy->easy_handle->hostcache = multi->hostcache;
|
easy->easy_handle->hostcache = multi->hostcache;
|
||||||
}
|
}
|
||||||
|
@@ -278,32 +278,6 @@ Curl_sec_write(struct connectdata *conn, int fd, char *buffer, int length)
|
|||||||
return tx;
|
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
|
int
|
||||||
Curl_sec_putc(struct connectdata *conn, int c, FILE *F)
|
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);
|
buffer_write(&conn->out_buffer, &ch, 1);
|
||||||
if(c == '\n' || conn->out_buffer.index >= 1024 /* XXX */) {
|
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;
|
conn->out_buffer.index = 0;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
@@ -346,53 +321,6 @@ Curl_sec_read_msg(struct connectdata *conn, char *s, int level)
|
|||||||
return code;
|
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
|
enum protection_level
|
||||||
Curl_set_command_prot(struct connectdata *conn, enum protection_level 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){
|
if(level){
|
||||||
|
int code;
|
||||||
if(Curl_ftpsendf(conn, "PBSZ %u", s))
|
if(Curl_ftpsendf(conn, "PBSZ %u", s))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
|
if(Curl_GetFTPResponse(&nread, conn, &code))
|
||||||
if(nread < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(conn->data->state.buffer[0] != '2'){
|
if(code/100 != '2'){
|
||||||
failf(conn->data, "Failed to set protection buffer size.");
|
failf(conn->data, "Failed to set protection buffer size.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -437,8 +365,7 @@ sec_prot_internal(struct connectdata *conn, int level)
|
|||||||
if(Curl_ftpsendf(conn, "PROT %c", level["CSEP"]))
|
if(Curl_ftpsendf(conn, "PROT %c", level["CSEP"]))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, NULL);
|
if(Curl_GetFTPResponse(&nread, conn, NULL))
|
||||||
if(nread < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(conn->data->state.buffer[0] != '2'){
|
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))
|
if(Curl_ftpsendf(conn, "AUTH %s", (*m)->name))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(conn->data->state.buffer, conn, &ftpcode);
|
if(Curl_GetFTPResponse(&nread, conn, &ftpcode))
|
||||||
if(nread < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(conn->data->state.buffer[0] != '3'){
|
if(conn->data->state.buffer[0] != '3'){
|
||||||
|
42
lib/sendf.c
42
lib/sendf.c
@@ -154,9 +154,19 @@ void Curl_failf(struct SessionHandle *data, const char *fmt, ...)
|
|||||||
vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
||||||
data->state.errorbuf = TRUE; /* wrote error string */
|
data->state.errorbuf = TRUE; /* wrote error string */
|
||||||
|
|
||||||
if(data->set.verbose)
|
if(data->set.verbose) {
|
||||||
Curl_debug(data, CURLINFO_TEXT, data->set.errorbuffer,
|
int len = strlen(data->set.errorbuffer);
|
||||||
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);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
@@ -235,6 +245,9 @@ CURLcode Curl_write(struct connectdata *conn, int sockfd,
|
|||||||
/* this is basicly the EWOULDBLOCK equivalent */
|
/* this is basicly the EWOULDBLOCK equivalent */
|
||||||
*written = 0;
|
*written = 0;
|
||||||
return CURLE_OK;
|
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 */
|
/* a true error */
|
||||||
failf(conn->data, "SSL_write() return error %d\n", err);
|
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 *n)
|
||||||
{
|
{
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
*n=0; /* reset amount to zero */
|
||||||
|
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
if (conn->ssl.use) {
|
if (conn->ssl.use) {
|
||||||
bool loop=TRUE;
|
nread = SSL_read(conn->ssl.handle, buf, buffersize);
|
||||||
int err;
|
|
||||||
do {
|
|
||||||
nread = SSL_read(conn->ssl.handle, buf, buffersize);
|
|
||||||
|
|
||||||
if(nread >= 0)
|
if(nread < 0) {
|
||||||
/* successful read */
|
/* failed SSL_read */
|
||||||
break;
|
int err = SSL_get_error(conn->ssl.handle, nread);
|
||||||
|
|
||||||
err = SSL_get_error(conn->ssl.handle, nread);
|
|
||||||
|
|
||||||
switch(err) {
|
switch(err) {
|
||||||
case SSL_ERROR_NONE: /* this is not an error */
|
case SSL_ERROR_NONE: /* this is not an error */
|
||||||
case SSL_ERROR_ZERO_RETURN: /* no more data */
|
case SSL_ERROR_ZERO_RETURN: /* no more data */
|
||||||
loop=0; /* get out of loop */
|
|
||||||
break;
|
break;
|
||||||
case SSL_ERROR_WANT_READ:
|
case SSL_ERROR_WANT_READ:
|
||||||
case SSL_ERROR_WANT_WRITE:
|
case SSL_ERROR_WANT_WRITE:
|
||||||
/* if there's data pending, then we re-invoke SSL_read() */
|
/* there's data pending, re-invoke SSL_read() */
|
||||||
break;
|
return -1; /* basicly EWOULDBLOCK */
|
||||||
default:
|
default:
|
||||||
failf(conn->data, "SSL read error: %d", err);
|
failf(conn->data, "SSL read error: %d", err);
|
||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
}
|
}
|
||||||
} while(loop);
|
}
|
||||||
if(loop && SSL_pending(conn->ssl.handle))
|
|
||||||
return -1; /* basicly EWOULDBLOCK */
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
|
@@ -30,13 +30,6 @@ void Curl_failf(struct SessionHandle *, const char *fmt, ...);
|
|||||||
#define infof Curl_infof
|
#define infof Curl_infof
|
||||||
#define failf Curl_failf
|
#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_BODY 1
|
||||||
#define CLIENTWRITE_HEADER 2
|
#define CLIENTWRITE_HEADER 2
|
||||||
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
|
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
|
||||||
|
@@ -35,9 +35,8 @@
|
|||||||
#define CURL_DISABLE_GOPHER
|
#define CURL_DISABLE_GOPHER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(_WIN32)
|
#if !defined(WIN32) && defined(__WIN32__)
|
||||||
/* This _might_ be a good Borland fix. Please report whether this works or
|
/* This should be a good Borland fix. Alexander J. Oss told us! */
|
||||||
not! */
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
207
lib/share.c
207
lib/share.c
@@ -24,142 +24,123 @@
|
|||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "share.h"
|
|
||||||
#include "urldata.h"
|
#include "urldata.h"
|
||||||
|
#include "share.h"
|
||||||
|
|
||||||
/* The last #include file should be: */
|
/* The last #include file should be: */
|
||||||
#ifdef MALLOCDEBUG
|
#ifdef MALLOCDEBUG
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CURL_SHARE_SET_LOCKED(__share, __type) ((__share)->locked += (__type))
|
CURLSH *
|
||||||
#define CURL_SHARE_SET_UNLOCKED(__share, __type) ((__share)->locked -= (__type))
|
curl_share_init(void)
|
||||||
|
|
||||||
#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)
|
|
||||||
{
|
{
|
||||||
curl_share *share = (curl_share *) malloc (sizeof (curl_share));
|
struct Curl_share *share =
|
||||||
if (share) {
|
(struct Curl_share *)malloc(sizeof(struct Curl_share));
|
||||||
memset (share, 0, sizeof (curl_share));
|
if (share)
|
||||||
}
|
memset (share, 0, sizeof(struct Curl_share));
|
||||||
|
|
||||||
return share;
|
return share;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode
|
CURLSHcode
|
||||||
curl_share_setopt (curl_share *share, curl_lock_type option, int enable)
|
curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
||||||
{
|
{
|
||||||
if (CURL_SHARE_IS_DIRTY(share)) {
|
struct Curl_share *share = (struct Curl_share *)sh;
|
||||||
return CURLE_SHARE_IN_USE;
|
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) {
|
return CURLSHE_OK;
|
||||||
CURL_SHARE_SET_USED (share, option);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CURL_SHARE_SET_UNUSED (share, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
return CURLE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode
|
CURLSHcode curl_share_cleanup(CURLSH *sh)
|
||||||
curl_share_set_lock_function (curl_share *share, curl_lock_function lock)
|
|
||||||
{
|
{
|
||||||
if (CURL_SHARE_IS_DIRTY(share)) {
|
struct Curl_share *share = (struct Curl_share *)sh;
|
||||||
return CURLE_SHARE_IN_USE;
|
if (share->dirty)
|
||||||
}
|
return CURLSHE_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
free (share);
|
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:
|
* local variables:
|
||||||
* eval: (load-file "../curl-mode.el")
|
* eval: (load-file "../curl-mode.el")
|
||||||
|
20
lib/share.h
20
lib/share.h
@@ -27,15 +27,19 @@
|
|||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
typedef enum {
|
/* this struct is libcurl-private, don't export details */
|
||||||
SHARE_ERROR_OK = 0,
|
struct Curl_share {
|
||||||
SHARE_ERROR_INVALID,
|
unsigned int specifier;
|
||||||
SHARE_ERROR_NOT_REGISTERED,
|
unsigned int locked;
|
||||||
SHARE_ERROR_LAST
|
unsigned int dirty;
|
||||||
} Curl_share_error;
|
|
||||||
|
curl_lock_function lockfunc;
|
||||||
|
curl_unlock_function unlockfunc;
|
||||||
|
void *clientdata;
|
||||||
|
};
|
||||||
|
|
||||||
Curl_share_error Curl_share_aquire_lock (CURL *, curl_lock_type);
|
CURLSHcode Curl_share_aquire_lock (struct SessionHandle *, curl_lock_data);
|
||||||
Curl_share_error Curl_share_release_lock (CURL *, curl_lock_type);
|
CURLSHcode Curl_share_release_lock (struct SessionHandle *, curl_lock_data);
|
||||||
|
|
||||||
#endif /* __CURL_SHARE_H */
|
#endif /* __CURL_SHARE_H */
|
||||||
|
|
||||||
|
56
lib/ssluse.c
56
lib/ssluse.c
@@ -275,7 +275,8 @@ int cert_stuff(struct connectdata *conn,
|
|||||||
if (SSL_CTX_use_PrivateKey_file(conn->ssl.ctx,
|
if (SSL_CTX_use_PrivateKey_file(conn->ssl.ctx,
|
||||||
key_file,
|
key_file,
|
||||||
file_type) != 1) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -324,10 +325,15 @@ int cert_stuff(struct connectdata *conn,
|
|||||||
|
|
||||||
ssl=SSL_new(conn->ssl.ctx);
|
ssl=SSL_new(conn->ssl.ctx);
|
||||||
x509=SSL_get_certificate(ssl);
|
x509=SSL_get_certificate(ssl);
|
||||||
|
|
||||||
if (x509 != NULL)
|
/* This version was provided by Evan Jordan and is supposed to not
|
||||||
EVP_PKEY_copy_parameters(X509_get_pubkey(x509),
|
leak memory as the previous version: */
|
||||||
SSL_get_privatekey(ssl));
|
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);
|
SSL_free(ssl);
|
||||||
|
|
||||||
/* If we are using DSA, we can copy the parameters from
|
/* 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
|
#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
|
CURLcode
|
||||||
Curl_SSLConnect(struct connectdata *conn)
|
Curl_SSLConnect(struct connectdata *conn)
|
||||||
@@ -904,7 +948,7 @@ Curl_SSLConnect(struct connectdata *conn)
|
|||||||
return CURLE_SSL_PEER_CERTIFICATE;
|
return CURLE_SSL_PEER_CERTIFICATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strequal(peer_CN, conn->hostname)) {
|
if (!cert_hostcheck(peer_CN, conn->hostname)) {
|
||||||
if (data->set.ssl.verifyhost > 1) {
|
if (data->set.ssl.verifyhost > 1) {
|
||||||
failf(data, "SSL: certificate subject name '%s' does not match "
|
failf(data, "SSL: certificate subject name '%s' does not match "
|
||||||
"target host name '%s'",
|
"target host name '%s'",
|
||||||
|
1493
lib/transfer.c
1493
lib/transfer.c
File diff suppressed because it is too large
Load Diff
61
lib/url.c
61
lib/url.c
@@ -101,6 +101,7 @@
|
|||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
#include "strtok.h"
|
#include "strtok.h"
|
||||||
|
#include "share.h"
|
||||||
|
|
||||||
/* And now for the protocols */
|
/* And now for the protocols */
|
||||||
#include "ftp.h"
|
#include "ftp.h"
|
||||||
@@ -1071,8 +1072,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
|
|||||||
|
|
||||||
case CURLOPT_SHARE:
|
case CURLOPT_SHARE:
|
||||||
{
|
{
|
||||||
curl_share *set;
|
struct Curl_share *set;
|
||||||
set = va_arg(param, curl_share *);
|
set = va_arg(param, struct Curl_share *);
|
||||||
if(data->share)
|
if(data->share)
|
||||||
data->share->dirty--;
|
data->share->dirty--;
|
||||||
|
|
||||||
@@ -1088,6 +1089,20 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
|
|||||||
data->set.proxytype = va_arg(param, long);
|
data->set.proxytype = va_arg(param, long);
|
||||||
break;
|
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:
|
default:
|
||||||
/* unknown tag and its companion, just ignore: */
|
/* unknown tag and its companion, just ignore: */
|
||||||
return CURLE_FAILED_INIT; /* correct this */
|
return CURLE_FAILED_INIT; /* correct this */
|
||||||
@@ -1603,6 +1618,9 @@ static CURLcode ConnectPlease(struct connectdata *conn,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ALERT! The 'dns' pointer being passed in here might be NULL at times.
|
||||||
|
*/
|
||||||
static void verboseconnect(struct connectdata *conn,
|
static void verboseconnect(struct connectdata *conn,
|
||||||
struct Curl_dns_entry *dns)
|
struct Curl_dns_entry *dns)
|
||||||
{
|
{
|
||||||
@@ -1636,7 +1654,7 @@ static void verboseconnect(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
Curl_addrinfo *hostaddr=dns->addr;
|
Curl_addrinfo *hostaddr=dns?dns->addr:NULL;
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
(void) memcpy(&in.s_addr, &conn->serv_addr.sin_addr, sizeof (in.s_addr));
|
(void) memcpy(&in.s_addr, &conn->serv_addr.sin_addr, sizeof (in.s_addr));
|
||||||
infof(data, "Connected to %s (%s) port %d\n",
|
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;
|
struct SessionHandle *data = conn->data;
|
||||||
CURLcode result=CURLE_OK;
|
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 */
|
Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */
|
||||||
|
|
||||||
if(data->set.verbose)
|
if(data->set.verbose)
|
||||||
@@ -1779,6 +1803,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
/* else, no chunky upload */
|
/* else, no chunky upload */
|
||||||
FALSE;
|
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
|
* 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
|
* 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 */
|
/* Setup a "faked" transfer that'll do nothing */
|
||||||
if(CURLE_OK == result) {
|
if(CURLE_OK == result) {
|
||||||
|
conn->bits.tcpconnect = TRUE; /* we are "connected */
|
||||||
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
|
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
|
||||||
-1, NULL); /* no upload */
|
-1, NULL); /* no upload */
|
||||||
}
|
}
|
||||||
@@ -2463,6 +2491,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
/* no name given, get the password only */
|
/* no name given, get the password only */
|
||||||
sscanf(userpass, ":%127[^@]", data->state.passwd);
|
sscanf(userpass, ":%127[^@]", data->state.passwd);
|
||||||
|
|
||||||
|
/* we have set the password */
|
||||||
|
data->state.passwdgiven = TRUE;
|
||||||
|
|
||||||
if(data->state.user[0]) {
|
if(data->state.user[0]) {
|
||||||
char *newname=curl_unescape(data->state.user, 0);
|
char *newname=curl_unescape(data->state.user, 0);
|
||||||
if(strlen(newname) < sizeof(data->state.user)) {
|
if(strlen(newname) < sizeof(data->state.user)) {
|
||||||
@@ -2498,14 +2529,17 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
/* the name is given, get user+password */
|
/* the name is given, get user+password */
|
||||||
sscanf(data->set.userpwd, "%127[^:]:%127[^\n]",
|
sscanf(data->set.userpwd, "%127[^:]:%127[^\n]",
|
||||||
data->state.user, data->state.passwd);
|
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
|
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);
|
sscanf(data->set.userpwd+1, "%127[^\n]", data->state.passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->set.use_netrc != CURL_NETRC_IGNORED &&
|
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,
|
if(Curl_parsenetrc(conn->hostname,
|
||||||
data->state.user,
|
data->state.user,
|
||||||
data->state.passwd)) {
|
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 we have a user but no password, ask for one */
|
||||||
if(conn->bits.user_passwd &&
|
if(conn->bits.user_passwd && !data->state.passwdgiven ) {
|
||||||
!data->state.passwd[0] ) {
|
|
||||||
if(data->set.fpasswd(data->set.passwd_client,
|
if(data->set.fpasswd(data->set.passwd_client,
|
||||||
"password:", data->state.passwd,
|
"password:", data->state.passwd,
|
||||||
sizeof(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 our protocol needs a password and we have none, use the defaults */
|
||||||
if ( (conn->protocol & (PROT_FTP|PROT_HTTP)) &&
|
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.user, CURL_DEFAULT_USER);
|
||||||
strcpy(data->state.passwd, CURL_DEFAULT_PASSWORD);
|
strcpy(data->state.passwd, CURL_DEFAULT_PASSWORD);
|
||||||
|
|
||||||
/* This is the default password, so DON'T set conn->bits.user_passwd */
|
/* 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! */
|
/* Connect only if not already connected! */
|
||||||
result = ConnectPlease(conn, hostaddr, &connected);
|
result = ConnectPlease(conn, hostaddr, &connected);
|
||||||
|
|
||||||
if(connected)
|
if(connected) {
|
||||||
result = Curl_protocol_connect(conn, hostaddr);
|
result = Curl_protocol_connect(conn, hostaddr);
|
||||||
|
if(CURLE_OK == result)
|
||||||
|
conn->bits.tcpconnect = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
conn->bits.tcpconnect = FALSE;
|
||||||
|
|
||||||
|
|
||||||
if(CURLE_OK != result)
|
if(CURLE_OK != result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
|
Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
|
||||||
|
conn->bits.tcpconnect = TRUE;
|
||||||
if(data->set.verbose)
|
if(data->set.verbose)
|
||||||
verboseconnect(conn, hostaddr);
|
verboseconnect(conn, hostaddr);
|
||||||
}
|
}
|
||||||
|
@@ -157,6 +157,8 @@ struct ssl_config_data {
|
|||||||
struct HTTP {
|
struct HTTP {
|
||||||
struct FormData *sendit;
|
struct FormData *sendit;
|
||||||
int postsize;
|
int postsize;
|
||||||
|
char *postdata;
|
||||||
|
|
||||||
const char *p_pragma; /* Pragma: string */
|
const char *p_pragma; /* Pragma: string */
|
||||||
const char *p_accept; /* Accept: string */
|
const char *p_accept; /* Accept: string */
|
||||||
long readbytecount;
|
long readbytecount;
|
||||||
@@ -164,10 +166,24 @@ struct HTTP {
|
|||||||
|
|
||||||
/* For FORM posting */
|
/* For FORM posting */
|
||||||
struct Form form;
|
struct Form form;
|
||||||
curl_read_callback storefread;
|
|
||||||
FILE *in;
|
|
||||||
|
|
||||||
struct Curl_chunker chunk;
|
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. */
|
read the line, just ignore the result. */
|
||||||
bool no_transfer; /* nothing was transfered, (possibly because a resumed
|
bool no_transfer; /* nothing was transfered, (possibly because a resumed
|
||||||
transfer already was complete) */
|
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
|
bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
|
||||||
on upload */
|
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
|
and the 'upload_present' contains the number of bytes available at this
|
||||||
position */
|
position */
|
||||||
char *upload_fromhere;
|
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 */
|
/* The end of connectdata. 08/27/02 jhrg */
|
||||||
@@ -543,6 +570,9 @@ struct UrlState {
|
|||||||
char proxyuser[MAX_CURL_USER_LENGTH];
|
char proxyuser[MAX_CURL_USER_LENGTH];
|
||||||
char proxypasswd[MAX_CURL_PASSWORD_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 */
|
struct timeval keeps_speed; /* for the progress meter really */
|
||||||
|
|
||||||
/* 'connects' will be an allocated array with pointers. If the pointer is
|
/* '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
|
bool free_referer; /* set TRUE if 'referer' points to a string we
|
||||||
allocated */
|
allocated */
|
||||||
char *useragent; /* User-Agent string */
|
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 */
|
char *postfields; /* if POST, set the fields' values here */
|
||||||
size_t postfieldsize; /* if POST, this might have a size to use instead of
|
size_t postfieldsize; /* if POST, this might have a size to use instead of
|
||||||
strlen(), and then the data *may* be binary (contain
|
strlen(), and then the data *may* be binary (contain
|
||||||
@@ -686,6 +716,10 @@ struct UserDefined {
|
|||||||
|
|
||||||
int dns_cache_timeout; /* DNS cache timeout */
|
int dns_cache_timeout; /* DNS cache timeout */
|
||||||
long buffer_size; /* size of receive buffer to use */
|
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
|
/* Here follows boolean settings that define how to behave during
|
||||||
this session. They are STATIC, set by libcurl users or at least initially
|
this session. They are STATIC, set by libcurl users or at least initially
|
||||||
@@ -734,7 +768,7 @@ struct UserDefined {
|
|||||||
|
|
||||||
struct SessionHandle {
|
struct SessionHandle {
|
||||||
curl_hash *hostcache;
|
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 UserDefined set; /* values set by the libcurl user */
|
||||||
struct DynamicStatic change; /* possibly modified userdefined data */
|
struct DynamicStatic change; /* possibly modified userdefined data */
|
||||||
|
|
||||||
|
196
perl/contrib/formfind
Executable file
196
perl/contrib/formfind
Executable 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
121
src/main.c
121
src/main.c
@@ -31,6 +31,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
@@ -144,6 +145,12 @@ char *strdup(char *str)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#define F_OK 0
|
||||||
|
#define mkdir(x,y) (mkdir)(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
int vms_show = 0;
|
int vms_show = 0;
|
||||||
#define FAC_CURL 0xC01
|
#define FAC_CURL 0xC01
|
||||||
@@ -355,6 +362,7 @@ static void help(void)
|
|||||||
" --ciphers <list> What SSL ciphers to use (SSL)\n"
|
" --ciphers <list> What SSL ciphers to use (SSL)\n"
|
||||||
" --compressed Request a compressed response (using deflate).");
|
" --compressed Request a compressed response (using deflate).");
|
||||||
puts(" --connect-timeout <seconds> Maximum time allowed for connection\n"
|
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"
|
" --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/--fail Fail silently (no output at all) on errors (H)\n"
|
||||||
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
||||||
@@ -484,6 +492,7 @@ struct Configurable {
|
|||||||
bool globoff;
|
bool globoff;
|
||||||
bool use_httpget;
|
bool use_httpget;
|
||||||
bool insecure_ok; /* set TRUE to allow insecure SSL connects */
|
bool insecure_ok; /* set TRUE to allow insecure SSL connects */
|
||||||
|
bool create_dirs;
|
||||||
|
|
||||||
char *writeout; /* %-styled format string to output */
|
char *writeout; /* %-styled format string to output */
|
||||||
bool writeenv; /* write results to environment, if available */
|
bool writeenv; /* write results to environment, if available */
|
||||||
@@ -523,6 +532,7 @@ struct Configurable {
|
|||||||
static int parseconfig(const char *filename,
|
static int parseconfig(const char *filename,
|
||||||
struct Configurable *config);
|
struct Configurable *config);
|
||||||
static char *my_get_line(FILE *fp);
|
static char *my_get_line(FILE *fp);
|
||||||
|
static int create_dir_hierarchy(char *outfile);
|
||||||
|
|
||||||
static void GetStr(char **string,
|
static void GetStr(char **string,
|
||||||
char *value)
|
char *value)
|
||||||
@@ -1069,6 +1079,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
{"z", "time-cond", TRUE},
|
{"z", "time-cond", TRUE},
|
||||||
{"Z", "max-redirs", TRUE},
|
{"Z", "max-redirs", TRUE},
|
||||||
{"#", "progress-bar",FALSE},
|
{"#", "progress-bar",FALSE},
|
||||||
|
{"@", "create-dirs", FALSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
if(('-' != flag[0]) ||
|
if(('-' != flag[0]) ||
|
||||||
@@ -1704,6 +1715,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->maxredirs = atoi(nextarg);
|
config->maxredirs = atoi(nextarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '@':
|
||||||
|
config->create_dirs = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
default: /* unknown flag */
|
default: /* unknown flag */
|
||||||
return PARAM_OPTION_UNKNOWN;
|
return PARAM_OPTION_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -2186,7 +2201,7 @@ int my_trace(CURL *handle, curl_infotype type,
|
|||||||
text = "=> Send header";
|
text = "=> Send header";
|
||||||
break;
|
break;
|
||||||
case CURLINFO_DATA_OUT:
|
case CURLINFO_DATA_OUT:
|
||||||
text = "=> Send data ";
|
text = "=> Send data";
|
||||||
break;
|
break;
|
||||||
case CURLINFO_HEADER_IN:
|
case CURLINFO_HEADER_IN:
|
||||||
text = "<= Recv header";
|
text = "<= Recv header";
|
||||||
@@ -2333,6 +2348,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
config->showerror=TRUE;
|
config->showerror=TRUE;
|
||||||
config->conf=CONF_DEFAULT;
|
config->conf=CONF_DEFAULT;
|
||||||
config->use_httpget=FALSE;
|
config->use_httpget=FALSE;
|
||||||
|
config->create_dirs=FALSE;
|
||||||
|
|
||||||
if(argc>1 &&
|
if(argc>1 &&
|
||||||
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
|
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
|
||||||
@@ -2555,13 +2571,20 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
free(storefile);
|
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) {
|
if(config->resume_from_current) {
|
||||||
/* we're told to continue where we are now, then we get the size of
|
/* We're told to continue from where we are now. Get the
|
||||||
the file as it is now and open it for append instead */
|
size of the file as it is now and open it for append instead */
|
||||||
|
|
||||||
struct stat fileinfo;
|
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))
|
if(0 == stat(outfile, &fileinfo))
|
||||||
/* set offset to current file size: */
|
/* set offset to current file size: */
|
||||||
config->resume_from = fileinfo.st_size;
|
config->resume_from = fileinfo.st_size;
|
||||||
@@ -2569,7 +2592,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
/* let offset be 0 */
|
/* let offset be 0 */
|
||||||
config->resume_from = 0;
|
config->resume_from = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->resume_from) {
|
if(config->resume_from) {
|
||||||
/* open file for output: */
|
/* open file for output: */
|
||||||
outs.stream=(FILE *) fopen(outfile, config->resume_from?"ab":"wb");
|
outs.stream=(FILE *) fopen(outfile, config->resume_from?"ab":"wb");
|
||||||
@@ -3020,3 +3043,89 @@ static char *my_get_line(FILE *fp)
|
|||||||
|
|
||||||
return retval;
|
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 */
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -25,9 +25,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(_WIN32)
|
#if !defined(WIN32) && defined(__WIN32__)
|
||||||
/* This _might_ be a good Borland fix. Please report whether this works or
|
/* Borland fix */
|
||||||
not! */
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define CURL_NAME "curl"
|
#define CURL_NAME "curl"
|
||||||
#define CURL_VERSION "7.10.2"
|
#define CURL_VERSION "7.10.3"
|
||||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||||
|
@@ -1,2 +1,4 @@
|
|||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
|
memdump
|
||||||
|
log
|
||||||
|
@@ -38,6 +38,16 @@ reply is sent
|
|||||||
</reply>
|
</reply>
|
||||||
|
|
||||||
<client>
|
<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>
|
<name>
|
||||||
test case description
|
test case description
|
||||||
</name>
|
</name>
|
||||||
@@ -48,6 +58,15 @@ accordingly. more about them elsewhere
|
|||||||
Set 'option=no-output' to prevent the test script to slap on the --output
|
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
|
argument that directs the output to a file. The --output is also not added if
|
||||||
the client/stdout section is used.
|
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>
|
</command>
|
||||||
<file name="log/filename">
|
<file name="log/filename">
|
||||||
this creates the named file with this content before the test case is run
|
this creates the named file with this content before the test case is run
|
||||||
|
@@ -2,13 +2,10 @@ EXTRA_DIST = ftpserver.pl httpserver.pl httpsserver.pl runtests.pl \
|
|||||||
ftpsserver.pl stunnel.pm getpart.pm FILEFORMAT README \
|
ftpsserver.pl stunnel.pm getpart.pm FILEFORMAT README \
|
||||||
stunnel.pem memanalyze.pl
|
stunnel.pem memanalyze.pl
|
||||||
|
|
||||||
SUBDIRS = data server
|
SUBDIRS = data server libtest
|
||||||
|
|
||||||
PERLFLAGS = -I$(srcdir)
|
PERLFLAGS = -I$(srcdir)
|
||||||
|
|
||||||
all:
|
|
||||||
install:
|
|
||||||
|
|
||||||
curl:
|
curl:
|
||||||
@(cd ..; make)
|
@(cd ..; make)
|
||||||
|
|
||||||
@@ -20,9 +17,5 @@ quiet-test: server/sws
|
|||||||
@cd data && exec $(MAKE) test
|
@cd data && exec $(MAKE) test
|
||||||
srcdir=$(srcdir) $(PERL) $(PERLFLAGS) $(srcdir)/runtests.pl -s -a
|
srcdir=$(srcdir) $(PERL) $(PERLFLAGS) $(srcdir)/runtests.pl -s -a
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf log
|
|
||||||
find . -name "*~" | xargs rm -f
|
|
||||||
|
|
||||||
server/sws:
|
server/sws:
|
||||||
cd server; make sws
|
cd server; make sws
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
all:
|
iall:
|
||||||
install:
|
install:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -17,4 +17,5 @@ test106 test115 test124 test190 test25 test303 test44 test38 \
|
|||||||
test107 test116 test125 test2 test26 test33 test45 test126 \
|
test107 test116 test125 test2 test26 test33 test45 test126 \
|
||||||
test304 test39 test32 test128 test48 test306 \
|
test304 test39 test32 test128 test48 test306 \
|
||||||
test130 test131 test132 test133 test134 test135 test403 test305 \
|
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
29
tests/data/test136
Normal 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>
|
@@ -1,6 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Server-side
|
# Server-side
|
||||||
<reply>
|
<reply>
|
||||||
|
MOOOOO
|
||||||
</reply>
|
</reply>
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -10,7 +11,7 @@
|
|||||||
HTTPS GET over HTTP proxy fails
|
HTTPS GET over HTTP proxy fails
|
||||||
</name>
|
</name>
|
||||||
<command>
|
<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>
|
</command>
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
|
48
tests/data/test500
Normal file
48
tests/data/test500
Normal 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
30
tests/data/test501
Normal 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
40
tests/data/test502
Normal 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
52
tests/data/test503
Normal 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
28
tests/data/test504
Normal 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
49
tests/data/test56
Normal file
File diff suppressed because one or more lines are too long
@@ -439,7 +439,8 @@ for ( $waitedpid = 0;
|
|||||||
|
|
||||||
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
|
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
|
||||||
print "500 '$_': command not understood.\r\n";
|
print "500 '$_': command not understood.\r\n";
|
||||||
next;
|
logmsg "unknown crap received, bailing out hard\n";
|
||||||
|
last;
|
||||||
}
|
}
|
||||||
my $FTPCMD=$1;
|
my $FTPCMD=$1;
|
||||||
my $FTPARG=$2;
|
my $FTPARG=$2;
|
||||||
|
9
tests/libtest/.cvsignore
Normal file
9
tests/libtest/.cvsignore
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
lib500
|
||||||
|
lib501
|
||||||
|
lib502
|
||||||
|
lib503
|
||||||
|
.libs
|
||||||
|
.deps
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
lib504
|
33
tests/libtest/Makefile.am
Normal file
33
tests/libtest/Makefile.am
Normal 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
31
tests/libtest/first.c
Normal 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
13
tests/libtest/lib500.c
Normal 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
14
tests/libtest/lib501.c
Normal 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
33
tests/libtest/lib502.c
Normal 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
77
tests/libtest/lib503.c
Normal 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
76
tests/libtest/lib504.c
Normal 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
5
tests/libtest/test.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include <curl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern char *arg2; /* set by first.c to the argv[2] or NULL */
|
||||||
|
|
@@ -6,14 +6,17 @@
|
|||||||
# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
|
# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
|
||||||
# MEM sendf.c:232 free(f6520)
|
# MEM sendf.c:232 free(f6520)
|
||||||
|
|
||||||
do {
|
while(1) {
|
||||||
if($ARGV[0] eq "-v") {
|
if($ARGV[0] eq "-v") {
|
||||||
$verbose=1;
|
$verbose=1;
|
||||||
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-t") {
|
elsif($ARGV[0] eq "-t") {
|
||||||
$trace=1;
|
$trace=1;
|
||||||
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
} while (shift @ARGV);
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
my $maxmem;
|
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 $_;
|
chomp $_;
|
||||||
$line = $_;
|
$line = $_;
|
||||||
|
|
||||||
if($line =~ /^MEM ([^:]*):(\d*) (.*)/) {
|
if($line =~ /^MEM ([^ ]*):(\d*) (.*)/) {
|
||||||
# generic match for the filename+linenumber
|
# generic match for the filename+linenumber
|
||||||
$source = $1;
|
$source = $1;
|
||||||
$linenum = $2;
|
$linenum = $2;
|
||||||
@@ -130,7 +145,7 @@ while(<STDIN>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# FD url.c:1282 socket() = 5
|
# FD url.c:1282 socket() = 5
|
||||||
elsif($_ =~ /^FD ([^:]*):(\d*) (.*)/) {
|
elsif($_ =~ /^FD ([^ ]*):(\d*) (.*)/) {
|
||||||
# generic match for the filename+linenumber
|
# generic match for the filename+linenumber
|
||||||
$source = $1;
|
$source = $1;
|
||||||
$linenum = $2;
|
$linenum = $2;
|
||||||
@@ -157,7 +172,7 @@ while(<STDIN>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# FILE url.c:1282 fopen("blabla") = 0x5ddd
|
# FILE url.c:1282 fopen("blabla") = 0x5ddd
|
||||||
elsif($_ =~ /^FILE ([^:]*):(\d*) (.*)/) {
|
elsif($_ =~ /^FILE ([^ ]*):(\d*) (.*)/) {
|
||||||
# generic match for the filename+linenumber
|
# generic match for the filename+linenumber
|
||||||
$source = $1;
|
$source = $1;
|
||||||
$linenum = $2;
|
$linenum = $2;
|
||||||
@@ -185,7 +200,7 @@ while(<STDIN>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ADDR url.c:1282 getaddrinfo() = 0x5ddd
|
# ADDR url.c:1282 getaddrinfo() = 0x5ddd
|
||||||
elsif($_ =~ /^ADDR ([^:]*):(\d*) (.*)/) {
|
elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) {
|
||||||
# generic match for the filename+linenumber
|
# generic match for the filename+linenumber
|
||||||
$source = $1;
|
$source = $1;
|
||||||
$linenum = $2;
|
$linenum = $2;
|
||||||
@@ -219,6 +234,7 @@ while(<STDIN>) {
|
|||||||
print "Not recognized prefix line: $line\n";
|
print "Not recognized prefix line: $line\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close(FILE);
|
||||||
|
|
||||||
if($totalmem) {
|
if($totalmem) {
|
||||||
print "Leak detected: memory still allocated: $totalmem bytes\n";
|
print "Leak detected: memory still allocated: $totalmem bytes\n";
|
||||||
|
@@ -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 $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging
|
||||||
my $LOGDIR="log";
|
my $LOGDIR="log";
|
||||||
my $TESTDIR="data";
|
my $TESTDIR="data";
|
||||||
|
my $LIBDIR="./libtest";
|
||||||
my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
|
my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
|
||||||
my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
|
my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
|
||||||
my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
|
my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
|
||||||
@@ -517,6 +518,14 @@ sub singletest {
|
|||||||
return 0; # look successful
|
return 0; # look successful
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my @codepieces = getpart("client", "tool");
|
||||||
|
|
||||||
|
my $tool="";
|
||||||
|
if(@codepieces) {
|
||||||
|
$tool = $codepieces[0];
|
||||||
|
chomp $tool;
|
||||||
|
}
|
||||||
|
|
||||||
# remove previous server output logfile
|
# remove previous server output logfile
|
||||||
unlink($SERVERIN);
|
unlink($SERVERIN);
|
||||||
|
|
||||||
@@ -575,12 +584,19 @@ sub singletest {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!@validstdout) {
|
if (!@validstdout) {
|
||||||
$out="--output $CURLOUT ";
|
$out=" --output $CURLOUT ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# run curl, add -v for debug information output
|
my $cmdargs;
|
||||||
my $cmdargs="$out--include -v $cmd";
|
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");
|
my @stdintest = getpart("client", "stdin");
|
||||||
|
|
||||||
@@ -590,11 +606,21 @@ sub singletest {
|
|||||||
|
|
||||||
$cmdargs .= " <$stdinfile";
|
$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) {
|
if($verbose) {
|
||||||
print "$CMDLINE\n";
|
print "$CMDLINE\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print CMDLOG "$CMDLINE\n";
|
print CMDLOG "$CMDLINE\n";
|
||||||
|
|
||||||
@@ -653,8 +679,7 @@ sub singletest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my %replyattr = getpartattr("reply", "data");
|
my %replyattr = getpartattr("reply", "data");
|
||||||
if(!$replyattr{'nocheck'} &&
|
if(!$replyattr{'nocheck'} && @reply) {
|
||||||
@reply) {
|
|
||||||
# verify the received data
|
# verify the received data
|
||||||
my @out = loadarray($CURLOUT);
|
my @out = loadarray($CURLOUT);
|
||||||
$res = compare(\@out, \@reply);
|
$res = compare(\@out, \@reply);
|
||||||
@@ -752,7 +777,7 @@ sub singletest {
|
|||||||
print "\n** ALERT! memory debuggin without any output file?\n";
|
print "\n** ALERT! memory debuggin without any output file?\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my @memdata=`$memanalyze < $memdump`;
|
my @memdata=`$memanalyze $memdump`;
|
||||||
my $leak=0;
|
my $leak=0;
|
||||||
for(@memdata) {
|
for(@memdata) {
|
||||||
if($_ ne "") {
|
if($_ ne "") {
|
||||||
@@ -790,63 +815,96 @@ my %run;
|
|||||||
|
|
||||||
sub serverfortest {
|
sub serverfortest {
|
||||||
my ($testnum)=@_;
|
my ($testnum)=@_;
|
||||||
|
my @what;
|
||||||
|
|
||||||
if($testnum< 100) {
|
if($testnum< 100) {
|
||||||
# 0 - 99 is for HTTP
|
# 0 - 99 is for HTTP
|
||||||
if(!$run{'http'}) {
|
push @what, "http";
|
||||||
runhttpserver($verbose);
|
|
||||||
$run{'http'}=$HTTPPIDFILE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elsif($testnum< 200) {
|
elsif($testnum< 200) {
|
||||||
# 100 - 199 is for FTP
|
# 100 - 199 is for FTP
|
||||||
if(!$run{'ftp'}) {
|
push @what, "ftp";
|
||||||
runftpserver($verbose);
|
|
||||||
$run{'ftp'}=$FTPPIDFILE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elsif($testnum< 300) {
|
elsif($testnum< 300) {
|
||||||
# 200 - 299 is for FILE, no server!
|
# 200 - 299 is for FILE, no server!
|
||||||
$run{'file'}="moo";
|
push @what, "file";
|
||||||
}
|
}
|
||||||
elsif($testnum< 400) {
|
elsif($testnum< 400) {
|
||||||
# 300 - 399 is for HTTPS, two servers!
|
# 300 - 399 is for HTTPS
|
||||||
|
push @what, "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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elsif($testnum< 500) {
|
elsif($testnum< 500) {
|
||||||
# 400 - 499 is for FTPS, also two servers
|
# 400 - 499 is for FTPS
|
||||||
|
push @what, "ftps";
|
||||||
|
}
|
||||||
|
|
||||||
if(!$checkstunnel || !$ssl_version) {
|
if(!@what) {
|
||||||
# we can't run https tests without stunnel
|
# load the test case file definition
|
||||||
# or if libcurl is SSL-less
|
if(loadtest("${TESTDIR}/test${testnum}")) {
|
||||||
return 1;
|
if($verbose) {
|
||||||
|
# this is not a test
|
||||||
|
print "$testnum doesn't look like a test case!\n";
|
||||||
|
}
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
if(!$run{'ftp'}) {
|
@what = getpart("client", "server");
|
||||||
runftpserver($verbose);
|
|
||||||
$run{'ftp'}=$FTPPIDFILE;
|
if(!$what[0]) {
|
||||||
}
|
warn "Test case $testnum has no server(s) specified!";
|
||||||
if(!$run{'ftps'}) {
|
return 100;
|
||||||
runftpsserver($verbose);
|
|
||||||
$run{'ftps'}=$FTPSPIDFILE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
for(@what) {
|
||||||
print "Bad test number, no server available\n";
|
my $what = lc($_);
|
||||||
return 100;
|
$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
|
sleep 1; # give a second for the server(s) to startup
|
||||||
return 0; # ok
|
return 0; # ok
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
.libs
|
.libs
|
||||||
Makefile.in
|
Makefile.in
|
||||||
stamp-h3.in
|
|
||||||
sws
|
sws
|
||||||
.deps
|
.deps
|
||||||
stamp-h3
|
stamp-h*
|
||||||
config.h
|
config.h
|
||||||
Makefile
|
Makefile
|
||||||
|
@@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
/* sws.c: simple (silly?) web server
|
/* 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!
|
Wilke. Thanks a bunch!
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -41,6 +41,13 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
spitout(FILE *stream,
|
spitout(FILE *stream,
|
||||||
const char *main,
|
const char *main,
|
||||||
@@ -54,11 +61,34 @@ spitout(FILE *stream,
|
|||||||
|
|
||||||
#define VERSION "cURL test suite HTTP server/0.1"
|
#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"
|
#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";
|
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"
|
static const char *doc404 = "HTTP/1.1 404 Not Found\n"
|
||||||
"Server: " VERSION "\n"
|
"Server: " VERSION "\n"
|
||||||
"Connection: close\n"
|
"Connection: close\n"
|
||||||
@@ -86,10 +116,7 @@ static void logmsg(const char *msg)
|
|||||||
|
|
||||||
strcpy(loctime, asctime(curr_time));
|
strcpy(loctime, asctime(curr_time));
|
||||||
loctime[strlen(loctime) - 1] = '\0';
|
loctime[strlen(loctime) - 1] = '\0';
|
||||||
fprintf(logfp, "%s: pid %d: %s\n", loctime, (int)getpid(), msg);
|
fprintf(logfp, "%s: %d: %s\n", loctime, (int)getpid(), msg);
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "%s: pid %d: %s\n", loctime, (int)getpid(), msg);
|
|
||||||
#endif
|
|
||||||
fflush(logfp);
|
fflush(logfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +133,7 @@ int ProcessRequest(char *request)
|
|||||||
{
|
{
|
||||||
char *line=request;
|
char *line=request;
|
||||||
unsigned long contentlength=0;
|
unsigned long contentlength=0;
|
||||||
|
char chunked=FALSE;
|
||||||
|
|
||||||
#define END_OF_HEADERS "\r\n\r\n"
|
#define END_OF_HEADERS "\r\n\r\n"
|
||||||
|
|
||||||
@@ -128,8 +156,23 @@ int ProcessRequest(char *request)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if(!strncasecmp("Content-Length:", line, 15))
|
if(!strncasecmp("Content-Length:", line, 15)) {
|
||||||
contentlength = strtol(line+15, &line, 10);
|
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');
|
line = strchr(line, '\n');
|
||||||
if(line)
|
if(line)
|
||||||
@@ -183,10 +226,10 @@ static int get_request(int sock, int *part)
|
|||||||
if (got <= 0) {
|
if (got <= 0) {
|
||||||
if (got < 0) {
|
if (got < 0) {
|
||||||
perror("recv");
|
perror("recv");
|
||||||
return -1;
|
return DOCNUMBER_INTERNAL;
|
||||||
}
|
}
|
||||||
logmsg("Connection closed by client");
|
logmsg("Connection closed by client");
|
||||||
return -1;
|
return DOCNUMBER_INTERNAL;
|
||||||
}
|
}
|
||||||
offset += got;
|
offset += got;
|
||||||
|
|
||||||
@@ -198,20 +241,18 @@ static int get_request(int sock, int *part)
|
|||||||
|
|
||||||
if (offset >= REQBUFSIZ) {
|
if (offset >= REQBUFSIZ) {
|
||||||
logmsg("Request buffer overflow, closing connection");
|
logmsg("Request buffer overflow, closing connection");
|
||||||
return -1;
|
return DOCNUMBER_INTERNAL;
|
||||||
}
|
}
|
||||||
reqbuf[offset]=0;
|
reqbuf[offset]=0;
|
||||||
|
|
||||||
logmsg("Received a request");
|
|
||||||
|
|
||||||
/* dump the request to an external file */
|
/* dump the request to an external file */
|
||||||
storerequest(reqbuf);
|
storerequest(reqbuf);
|
||||||
|
|
||||||
if (sscanf(reqbuf, "%" REQBUFSIZ_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
|
if(sscanf(reqbuf, "%" REQBUFSIZ_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
|
||||||
request,
|
request,
|
||||||
doc,
|
doc,
|
||||||
&prot_major,
|
&prot_major,
|
||||||
&prot_minor) == 4) {
|
&prot_minor) == 4) {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int test_no=0;
|
int test_no=0;
|
||||||
|
|
||||||
@@ -231,7 +272,7 @@ static int get_request(int sock, int *part)
|
|||||||
|
|
||||||
if(!strncmp("/verifiedserver", ptr, 15)) {
|
if(!strncmp("/verifiedserver", ptr, 15)) {
|
||||||
logmsg("Are-we-friendly question received");
|
logmsg("Are-we-friendly question received");
|
||||||
return -2;
|
return DOCNUMBER_WERULEZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr++; /* skip the slash */
|
ptr++; /* skip the slash */
|
||||||
@@ -247,8 +288,23 @@ static int get_request(int sock, int *part)
|
|||||||
logmsg(logbuf);
|
logmsg(logbuf);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
return test_no;
|
||||||
@@ -268,27 +324,46 @@ static int send_doc(int sock, int doc, int part_no)
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *cmd=NULL;
|
char *cmd=NULL;
|
||||||
int cmdsize;
|
int cmdsize=0;
|
||||||
|
FILE *dump;
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
char partbuf[80]="data";
|
char partbuf[80]="data";
|
||||||
|
|
||||||
if(doc < 0) {
|
if(doc < 0) {
|
||||||
if(-2 == doc)
|
switch(doc) {
|
||||||
|
case DOCNUMBER_WERULEZ:
|
||||||
/* we got a "friends?" question, reply back that we sure are */
|
/* we got a "friends?" question, reply back that we sure are */
|
||||||
|
logmsg("Identifying ourselves as friends");
|
||||||
buffer = docfriends;
|
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;
|
buffer = doc404;
|
||||||
|
break;
|
||||||
|
}
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
stream=NULL;
|
stream=NULL;
|
||||||
|
|
||||||
count = strlen(buffer);
|
count = strlen(buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(0 != part_no) {
|
logmsg("Fetch response data");
|
||||||
sprintf(partbuf, "data%d", part_no);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(0 != part_no)
|
||||||
|
sprintf(partbuf, "data%d", part_no);
|
||||||
|
|
||||||
sprintf(filename, TEST_DATA_PATH, doc);
|
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 {
|
do {
|
||||||
written = send(sock, buffer, count, 0);
|
written = send(sock, buffer, count, 0);
|
||||||
if (written < 0) {
|
if (written < 0) {
|
||||||
|
logmsg("Sending response failed and we bailed out!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/* write to file as well */
|
||||||
|
fwrite(buffer, 1, written, dump);
|
||||||
|
|
||||||
count -= written;
|
count -= written;
|
||||||
buffer += written;
|
buffer += written;
|
||||||
} while(count>0);
|
} while(count>0);
|
||||||
|
|
||||||
|
fclose(dump);
|
||||||
|
|
||||||
|
logmsg("Response sent!");
|
||||||
|
|
||||||
if(ptr)
|
if(ptr)
|
||||||
free(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(2 == sscanf(ptr, "%31s %d", command, &num)) {
|
||||||
if(!strcmp("wait", command))
|
if(!strcmp("wait", command))
|
||||||
sleep(num); /* wait this many seconds */
|
sleep(num); /* wait this many seconds */
|
||||||
else {
|
else
|
||||||
logmsg("Unknown command in reply command section");
|
logmsg("Unknown command in reply command section");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ptr = strchr(ptr, '\n');
|
ptr = strchr(ptr, '\n');
|
||||||
if(ptr)
|
if(ptr)
|
||||||
@@ -365,8 +453,6 @@ int main(int argc, char *argv[])
|
|||||||
if(argc>1)
|
if(argc>1)
|
||||||
port = atoi(argv[1]);
|
port = atoi(argv[1]);
|
||||||
|
|
||||||
/* FIX: write our pid to a file name */
|
|
||||||
|
|
||||||
logfp = fopen(logfile, "a");
|
logfp = fopen(logfile, "a");
|
||||||
if (!logfp) {
|
if (!logfp) {
|
||||||
perror(logfile);
|
perror(logfile);
|
||||||
@@ -374,9 +460,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SIGNAL
|
#ifdef HAVE_SIGNAL
|
||||||
/* FIX: make a more portable signal handler */
|
|
||||||
signal(SIGPIPE, sigpipe_handler);
|
signal(SIGPIPE, sigpipe_handler);
|
||||||
|
|
||||||
siginterrupt(SIGPIPE, 1);
|
siginterrupt(SIGPIPE, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -428,9 +512,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
logmsg("New client connected");
|
logmsg("New client connected");
|
||||||
|
|
||||||
doc = get_request(msgsock, &part_no);
|
do {
|
||||||
send_doc(msgsock, doc, part_no);
|
|
||||||
|
|
||||||
|
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);
|
close(msgsock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user