Compare commits
39 Commits
curl-7_6_1
...
curl-7_7_a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cf8704ccdf | ||
![]() |
5543c2f11f | ||
![]() |
90ac37a683 | ||
![]() |
dd893fd8a4 | ||
![]() |
834f079918 | ||
![]() |
2665c763df | ||
![]() |
d1cfbd51b5 | ||
![]() |
a3ba6b7a6a | ||
![]() |
415d2e7cb7 | ||
![]() |
af4451ec26 | ||
![]() |
7c6562683a | ||
![]() |
b6fa2f882c | ||
![]() |
b6c5da337a | ||
![]() |
9bc24e4876 | ||
![]() |
4af55809e4 | ||
![]() |
9c63fcf210 | ||
![]() |
1f17fb5f89 | ||
![]() |
584dbffe60 | ||
![]() |
1c6f6f6972 | ||
![]() |
da06a6e7e3 | ||
![]() |
46e0937263 | ||
![]() |
a1d6ad2610 | ||
![]() |
5f3d63ed5b | ||
![]() |
63b5748eb6 | ||
![]() |
e2590430c5 | ||
![]() |
ada9bc2b24 | ||
![]() |
43da41e73e | ||
![]() |
720fa45b56 | ||
![]() |
7de874c438 | ||
![]() |
2078c1a01a | ||
![]() |
f7a8909372 | ||
![]() |
250df30e64 | ||
![]() |
b887cf7521 | ||
![]() |
630e932091 | ||
![]() |
cdabd67aa9 | ||
![]() |
42e4f9d776 | ||
![]() |
c111033595 | ||
![]() |
26d1aaccdf | ||
![]() |
ce95d2020f |
73
CHANGES
73
CHANGES
@@ -6,6 +6,79 @@
|
|||||||
|
|
||||||
History of Changes
|
History of Changes
|
||||||
|
|
||||||
|
** curl 7.7 DOES NOT currently WORK. **
|
||||||
|
|
||||||
|
Daniel (4 March 2001)
|
||||||
|
- Now, there's even a basic check that a re-used connection is still alive
|
||||||
|
before it is assumed so. A few first tests have proven that libcurl will
|
||||||
|
then re-connect instead of re-use the dead connection!
|
||||||
|
|
||||||
|
Daniel (2 March 2001)
|
||||||
|
- Now they work intermixed as well. Major coolness!
|
||||||
|
|
||||||
|
- More fiddling around, my 'tiny' client I have for testing purposes now has
|
||||||
|
proved to download both FTP and HTTP with persistant connections. They do
|
||||||
|
not work intermixed yet though.
|
||||||
|
|
||||||
|
Daniel (1 March 2001)
|
||||||
|
- Wilfredo Sanchez pointed out a minor spelling mistake in a man page and that
|
||||||
|
curl_slist_append() should take a const char * as second argument. It does
|
||||||
|
now.
|
||||||
|
|
||||||
|
Daniel (22 February 2001)
|
||||||
|
- The persistant connections start to look good for HTTP. On a subsequent
|
||||||
|
request, it seems that libcurl now can pick an already existing connection
|
||||||
|
if a suitable one exists, or it opens a new one.
|
||||||
|
|
||||||
|
- Douglas R. Horner mailed me corrections to the curl_formparse() man page
|
||||||
|
that I applied.
|
||||||
|
|
||||||
|
Daniel (20 February 2001)
|
||||||
|
- Added the docs/examples/win32sockets.c file for our windows friends.
|
||||||
|
|
||||||
|
- Linus Nielsen Feltzing provided brand new TELNET functionality and
|
||||||
|
improvements:
|
||||||
|
|
||||||
|
* Negotiation is now passive. Curl does not negotiate until the peer does.
|
||||||
|
* Possibility to set negotiation options on the command line, currently only
|
||||||
|
XDISPLOC, TTYPE and NEW_ENVIRON (called NEW_ENV).
|
||||||
|
* Now sends the USER environment variable if the -u switch is used.
|
||||||
|
* Use -t to set telnet options (Linus even updated the man page, awesome!)
|
||||||
|
|
||||||
|
- Haven't done this big changes to curl for a while. Moved around a lot of
|
||||||
|
struct fields and stuff to make multiple connections get connection specific
|
||||||
|
data in separate structs so that they can co-exist in a nice way. See the
|
||||||
|
mailing lists for discussions around how this is gonna be implemented. Docs
|
||||||
|
and more will follow.
|
||||||
|
|
||||||
|
Studied the HTTP RFC to find out better how persistant connections should
|
||||||
|
work. Seems cool enough.
|
||||||
|
|
||||||
|
Daniel (19 February 2001)
|
||||||
|
- Bob Schader brought me two files that help set up a MS VC++ libcurl project
|
||||||
|
easier. He also provided me with an up-to-date libcurl.def file.
|
||||||
|
|
||||||
|
- I moved a bunch of prototypes from the public <curl/curl.h> file to the
|
||||||
|
library private urldata.h. This is because of the upcoming changes. The
|
||||||
|
low level interface is no longer being planned to become reality.
|
||||||
|
|
||||||
|
Daniel (15 February 2001)
|
||||||
|
- CURLOPT_POST is not required anymore. Just setting the POST string with
|
||||||
|
CURLOPT_POSTFIELDS will switch on the HTTP POST. Most other things in
|
||||||
|
libcurl already works this way, i.e they require only the parameter to
|
||||||
|
switch on a feature so I think this works well with the rest. Setting a NULL
|
||||||
|
string switches off the POST again.
|
||||||
|
|
||||||
|
- Excellent suggestions from Rich Gray, Rick Jones, Johan Nilsson and Bjorn
|
||||||
|
Reese helped me define a way how to incorporate persistant connections into
|
||||||
|
libcurl in a very smooth way. If done right, no change may have to be made
|
||||||
|
to older programs and they will just start using persistant connections when
|
||||||
|
applicable!
|
||||||
|
|
||||||
|
Daniel (13 February 2001)
|
||||||
|
- Changed the word 'timeouted' to 'timed out' in two different error messages.
|
||||||
|
Suggested by Larry Fahnoe.
|
||||||
|
|
||||||
Version 7.6.1
|
Version 7.6.1
|
||||||
|
|
||||||
Daniel (9 February 2001)
|
Daniel (9 February 2001)
|
||||||
|
@@ -733,5 +733,6 @@ AC_OUTPUT( Makefile \
|
|||||||
packages/Linux/Makefile \
|
packages/Linux/Makefile \
|
||||||
packages/Linux/RPM/Makefile \
|
packages/Linux/RPM/Makefile \
|
||||||
packages/Linux/RPM/curl.spec \
|
packages/Linux/RPM/curl.spec \
|
||||||
packages/Linux/RPM/curl-ssl.spec )
|
packages/Linux/RPM/curl-ssl.spec \
|
||||||
|
tiny/Makefile )
|
||||||
|
|
||||||
|
9
docs/FAQ
9
docs/FAQ
@@ -1,4 +1,4 @@
|
|||||||
Updated: February 12, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
Updated: February 16, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
||||||
_ _ ____ _
|
_ _ ____ _
|
||||||
___| | | | _ \| |
|
___| | | | _ \| |
|
||||||
/ __| | | | |_) | |
|
/ __| | | | |_) | |
|
||||||
@@ -183,11 +183,8 @@ FAQ
|
|||||||
2.2. Does curl work/build with other SSL libraries?
|
2.2. Does curl work/build with other SSL libraries?
|
||||||
|
|
||||||
Curl has been written to use OpenSSL, although I doubt there would be much
|
Curl has been written to use OpenSSL, although I doubt there would be much
|
||||||
problems using a different library. I just don't know any other free one and
|
problems using a different library. If anyone does "port" curl to use a
|
||||||
that has limited my possibilities to develop against anything else.
|
different SSL library, I am of course very interested in getting the patch!
|
||||||
|
|
||||||
If anyone does "port" curl to use a commercial SSL library, I am of course
|
|
||||||
very interested in getting the patch!
|
|
||||||
|
|
||||||
2.3. Where can I find a copy of LIBEAY32.DLL?
|
2.3. Where can I find a copy of LIBEAY32.DLL?
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ Misc
|
|||||||
- compiles on win32
|
- compiles on win32
|
||||||
- redirectable stderr
|
- redirectable stderr
|
||||||
- use selected network interface for outgoing traffic
|
- use selected network interface for outgoing traffic
|
||||||
|
- IPv6 support
|
||||||
|
|
||||||
HTTP
|
HTTP
|
||||||
- GET
|
- GET
|
||||||
@@ -28,7 +29,7 @@ HTTP
|
|||||||
- POST
|
- POST
|
||||||
- multipart POST
|
- multipart POST
|
||||||
- authentication
|
- authentication
|
||||||
- resume
|
- resume (both GET and PUT)
|
||||||
- follow redirects
|
- follow redirects
|
||||||
- maximum amount of redirects to follow
|
- maximum amount of redirects to follow
|
||||||
- custom HTTP request
|
- custom HTTP request
|
||||||
|
22
docs/MANUAL
22
docs/MANUAL
@@ -745,16 +745,22 @@ TELNET
|
|||||||
to track when the login prompt is received and send the username and
|
to track when the login prompt is received and send the username and
|
||||||
password accordingly.
|
password accordingly.
|
||||||
|
|
||||||
MAILING LIST
|
MAILING LISTS
|
||||||
|
|
||||||
We have an open mailing list to discuss curl, its development and things
|
For your convenience, we have several open mailing lists to discuss curl,
|
||||||
relevant to this.
|
its development and things relevant to this.
|
||||||
|
|
||||||
To subscribe, mail curl-request@contactor.se with "subscribe <fill in your
|
To subscribe to the main curl list, mail curl-request@contactor.se with
|
||||||
email address>" in the body.
|
"subscribe <fill in your email address>" in the body.
|
||||||
|
|
||||||
To post to the list, mail curl@contactor.se.
|
To subscribe to the libcurl users list, follow the instructions at
|
||||||
|
http://curl.haxx.se/mail/
|
||||||
|
|
||||||
To unsubcribe, mail curl-request@contactor.se with "unsubscribe <your
|
To subscribe to the curl announce list, to only get information about new
|
||||||
subscribed email address>" in the body.
|
releases, follow the instructions at http://curl.haxx.se/mail/
|
||||||
|
|
||||||
|
To subscribe to the curl-and-PHP list in which curl using with PHP is
|
||||||
|
discussed, follow the instructions at http://curl.haxx.se/mail/
|
||||||
|
|
||||||
|
Please direct curl questions, feature requests and trouble reports to one of
|
||||||
|
these mailing lists instead of mailing any individual.
|
||||||
|
11
docs/TODO
11
docs/TODO
@@ -23,11 +23,8 @@ For the future
|
|||||||
URLs mentioned in the list. I figure -O or something would have to be
|
URLs mentioned in the list. I figure -O or something would have to be
|
||||||
implied by such an action.
|
implied by such an action.
|
||||||
|
|
||||||
* Improve the regular progress meter with --continue is used. It should be
|
|
||||||
noticable when there's a resume going on.
|
|
||||||
|
|
||||||
* Add a command line option that allows the output file to get the same time
|
* Add a command line option that allows the output file to get the same time
|
||||||
stamp as the remote file. We already are capable of fetching the remote
|
stamp as the remote file. libcurl already is capable of fetching the remote
|
||||||
file's date.
|
file's date.
|
||||||
|
|
||||||
* Make the SSL layer option capable of using the Mozilla Security Services as
|
* Make the SSL layer option capable of using the Mozilla Security Services as
|
||||||
@@ -58,13 +55,15 @@ For the future
|
|||||||
started in October 1999 but halted again since it proved more work than we
|
started in October 1999 but halted again since it proved more work than we
|
||||||
thought. It is still a good idea to implement though.
|
thought. It is still a good idea to implement though.
|
||||||
|
|
||||||
* Authentication: NTLM. It would be cool to support that MS crap called NTLM
|
* Authentication: NTLM. It would be to support 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
|
||||||
sniffing. This should however be a library-based functionality. There are a
|
sniffing. This should however be a library-based functionality. There are a
|
||||||
few different efforts "out there" to make open source HTTP clients support
|
few different efforts "out there" to make open source HTTP clients support
|
||||||
this and it should be possible to take advantage of other people's hard
|
this and it should be possible to take advantage of other people's hard
|
||||||
work. http://modntlm.sourceforge.net/ is one.
|
work. http://modntlm.sourceforge.net/ is one. There's a web page at
|
||||||
|
http://www.innovation.ch/java/ntlm.html that contains detailed reverse-
|
||||||
|
engineered info.
|
||||||
|
|
||||||
* RFC2617 compliance, "Digest Access Authentication"
|
* RFC2617 compliance, "Digest Access Authentication"
|
||||||
A valid test page seem to exist at:
|
A valid test page seem to exist at:
|
||||||
|
15
docs/curl.1
15
docs/curl.1
@@ -425,11 +425,14 @@ If this option is used twice, the second will again disable mute.
|
|||||||
When used with -s it makes curl show error message if it fails.
|
When used with -s it makes curl show error message if it fails.
|
||||||
|
|
||||||
If this option is used twice, the second will again disable show error.
|
If this option is used twice, the second will again disable show error.
|
||||||
.IP "-t/--upload"
|
.IP "-t/--telnet-option <OPT=val>"
|
||||||
.B Deprecated. Use '-T -' instead.
|
Pass options to the telnet protocol. Supported options are:
|
||||||
Transfer the stdin data to the specified file. Curl will read
|
|
||||||
everything from stdin until EOF and store with the supplied name. If
|
TTYPE=<term> Sets the terminal type.
|
||||||
this is used on a http(s) server, the PUT command will be used.
|
|
||||||
|
XDISPLOC=<X display> Sets the X display location.
|
||||||
|
|
||||||
|
NEW_ENV=<var,val> Sets an environment variable.
|
||||||
.IP "-T/--upload-file <file>"
|
.IP "-T/--upload-file <file>"
|
||||||
Like -t, but this transfers the specified local file. If there is no
|
Like -t, but this transfers the specified local file. If there is no
|
||||||
file part in the specified URL, Curl will append the local file
|
file part in the specified URL, Curl will append the local file
|
||||||
@@ -758,7 +761,7 @@ If you do find bugs, mail them to curl-bug@haxx.se.
|
|||||||
- Lars J. Aas <larsa@sim.no>
|
- Lars J. Aas <larsa@sim.no>
|
||||||
- J<>rn Hartroth <Joern.Hartroth@computer.org>
|
- J<>rn Hartroth <Joern.Hartroth@computer.org>
|
||||||
- Matthew Clarke <clamat@van.maves.ca>
|
- Matthew Clarke <clamat@van.maves.ca>
|
||||||
- Linus Nielsen <Linus.Nielsen@haxx.se>
|
- Linus Nielsen Feltzing <linus@haxx.se>
|
||||||
- Felix von Leitner <felix@convergence.de>
|
- Felix von Leitner <felix@convergence.de>
|
||||||
- Dan Zitter <dzitter@zitter.net>
|
- Dan Zitter <dzitter@zitter.net>
|
||||||
- Jongki Suwandi <Jongki.Suwandi@eng.sun.com>
|
- Jongki Suwandi <Jongki.Suwandi@eng.sun.com>
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
.\" nroff -man [file]
|
.\" nroff -man [file]
|
||||||
.\" Written by daniel@haxx.se
|
.\" Written by daniel@haxx.se
|
||||||
.\"
|
.\"
|
||||||
.TH curl_easy_perform 3 "25 Jan 2001" "Curl 7.0" "libcurl Manual"
|
.TH curl_easy_perform 3 "1 Mar 2001" "Curl 7.0" "libcurl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl_easy_perform - Do the actual transfer in a "easy" session
|
curl_easy_perform - Do the actual transfer in a "easy" session
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -25,7 +25,7 @@ again first.
|
|||||||
.I <curl/curl.h>
|
.I <curl/curl.h>
|
||||||
defines. If the CURLOPT_ERRORBUFFER was set with
|
defines. If the CURLOPT_ERRORBUFFER was set with
|
||||||
.I curl_easy_setopt
|
.I curl_easy_setopt
|
||||||
there willo be a readable error message in the error buffer when non-zero is
|
there will be a readable error message in the error buffer when non-zero is
|
||||||
returned.
|
returned.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR curl_easy_init "(3), " curl_easy_setopt "(3), "
|
.BR curl_easy_init "(3), " curl_easy_setopt "(3), "
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
.\" nroff -man [file]
|
.\" nroff -man [file]
|
||||||
.\" Written by daniel@haxx.se
|
.\" Written by daniel@haxx.se
|
||||||
.\"
|
.\"
|
||||||
.TH curl_formparse 3 "8 February 2001" "Curl 7.0" "libcurl Manual"
|
.TH curl_formparse 3 "22 February 2001" "Curl 7.0" "libcurl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl_formparse - add a section to a multipart/formdata HTTP POST
|
curl_formparse - add a section to a multipart/formdata HTTP POST
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -42,14 +42,14 @@ Add a form field named 'name' with the contents as read from the local files
|
|||||||
named 'filename1' and 'filename2'. This is identical to the upper, except that
|
named 'filename1' and 'filename2'. This is identical to the upper, except that
|
||||||
you get the contents of several files in one section.
|
you get the contents of several files in one section.
|
||||||
.TP
|
.TP
|
||||||
.B [name]=@[filename];[content-type]
|
.B [name]=@[filename];[type=<content-type>]
|
||||||
Whenever you specify a file to read from, you can optionally specify the
|
Whenever you specify a file to read from, you can optionally specify the
|
||||||
content-type as well. The content-type is passed to the server together with
|
content-type as well. The content-type is passed to the server together with
|
||||||
the contents of the file. curl_formparse() will guess content-type for a
|
the contents of the file. curl_formparse() will guess content-type for a
|
||||||
number of well-known extensions and otherwise it will set it to binary. You
|
number of well-known extensions and otherwise it will set it to binary. You
|
||||||
can override the internal decision by using this option.
|
can override the internal decision by using this option.
|
||||||
.TP
|
.TP
|
||||||
.B [name]=@[filename1,filename2,...];[content-type]
|
.B [name]=@[filename1,filename2,...];[type=<content-type>]
|
||||||
When you specify several files to read the contents from, you can set the
|
When you specify several files to read the contents from, you can set the
|
||||||
content-type for all of them in the same way as with a single file.
|
content-type for all of them in the same way as with a single file.
|
||||||
.PP
|
.PP
|
||||||
|
@@ -2,14 +2,14 @@
|
|||||||
.\" nroff -man [file]
|
.\" nroff -man [file]
|
||||||
.\" Written by daniel@haxx.se
|
.\" Written by daniel@haxx.se
|
||||||
.\"
|
.\"
|
||||||
.TH curl_slist_append 3 "2 June 2000" "Curl 7.0" "libcurl Manual"
|
.TH curl_slist_append 3 "1 Mar 2001" "Curl 7.7" "libcurl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl_slist_append - add a string to an slist
|
curl_slist_append - add a string to an slist
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B #include <curl/curl.h>
|
.B #include <curl/curl.h>
|
||||||
.sp
|
.sp
|
||||||
.BI "struct curl_slist *curl_slist_append(struct curl_slit *" list,
|
.BI "struct curl_slist *curl_slist_append(struct curl_slit *" list,
|
||||||
.BI "char * "string ");"
|
.BI "const char * "string ");"
|
||||||
.ad
|
.ad
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
curl_slist_append() appends a specified string to a linked list of
|
curl_slist_append() appends a specified string to a linked list of
|
||||||
|
@@ -5,7 +5,9 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||||
|
|
||||||
EXTRA_DIST =
|
EXTRA_DIST =
|
||||||
README curlgtk.c sepheaders.c simple.c postit.c
|
README curlgtk.c sepheaders.c simple.c postit.c \
|
||||||
|
win32sockets.c \
|
||||||
|
getpageinvar.php simpleget.php simplepost.php
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@echo "done"
|
@echo "done"
|
||||||
|
@@ -6,3 +6,6 @@ advantage of libcurl.
|
|||||||
|
|
||||||
If you end up with other small but still useful example sources, please mail
|
If you end up with other small but still useful example sources, please mail
|
||||||
them for submission in future packages and on the web site.
|
them for submission in future packages and on the web site.
|
||||||
|
|
||||||
|
There are examples for different languages and environments. Browse around to
|
||||||
|
find those that fit you.
|
||||||
|
@@ -1,4 +1,12 @@
|
|||||||
/* curlgtk.c */
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
/* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
|
/* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
|
||||||
/* an attempt to use the curl library in concert with a gtk-threaded application */
|
/* an attempt to use the curl library in concert with a gtk-threaded application */
|
||||||
|
|
||||||
|
10
docs/examples/getpageinvar.php
Normal file
10
docs/examples/getpageinvar.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# The PHP curl module supports the received page to be returned in a variable
|
||||||
|
# if told.
|
||||||
|
#
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL,"http://www.myurl.com/");
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
||||||
|
$result=curl_exec ($ch);
|
||||||
|
curl_close ($ch);
|
@@ -21,6 +21,9 @@
|
|||||||
* This exact source code has not been verified to work.
|
* This exact source code has not been verified to work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* to make this work under windows, use the win32-functions from the
|
||||||
|
win32socket.c file as well */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
@@ -1,3 +1,16 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* to make this work under windows, use the win32-functions from the
|
||||||
|
win32socket.c file as well */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@@ -1,9 +1,22 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/types.h>
|
#include <curl/types.h>
|
||||||
#include <curl/easy.h>
|
#include <curl/easy.h>
|
||||||
|
|
||||||
|
/* to make this work under windows, use the win32-functions from the
|
||||||
|
win32socket.c file as well */
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
|
13
docs/examples/simpleget.php
Normal file
13
docs/examples/simpleget.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# A very simple example that gets a HTTP page.
|
||||||
|
#
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
curl_setopt ($ch, CURLOPT_URL, "http://www.zend.com/");
|
||||||
|
curl_setopt ($ch, CURLOPT_HEADER, 0);
|
||||||
|
|
||||||
|
curl_exec ($ch);
|
||||||
|
|
||||||
|
curl_close ($ch);
|
||||||
|
|
12
docs/examples/simplepost.php
Normal file
12
docs/examples/simplepost.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# A very simple PHP example that sends a HTTP POST to a remote site
|
||||||
|
#
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3");
|
||||||
|
|
||||||
|
curl_exec ($ch);
|
||||||
|
curl_close ($ch);
|
40
docs/examples/win32sockets.c
Normal file
40
docs/examples/win32sockets.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* These are example functions doing socket init that Windows
|
||||||
|
* require. If you don't use windows, you can safely ignore this crap.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void win32_cleanup(void)
|
||||||
|
{
|
||||||
|
WSACleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CURLcode win32_init(void)
|
||||||
|
{
|
||||||
|
WORD wVersionRequested;
|
||||||
|
WSADATA wsaData;
|
||||||
|
int err;
|
||||||
|
wVersionRequested = MAKEWORD(1, 1);
|
||||||
|
|
||||||
|
err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
|
if (err != 0)
|
||||||
|
/* Tell the user that we couldn't find a useable */
|
||||||
|
/* winsock.dll. */
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Confirm that the Windows Sockets DLL supports 1.1.*/
|
||||||
|
/* Note that if the DLL supports versions greater */
|
||||||
|
/* than 1.1 in addition to 1.1, it will still return */
|
||||||
|
/* 1.1 in wVersion since that is the version we */
|
||||||
|
/* requested. */
|
||||||
|
|
||||||
|
if ( LOBYTE( wsaData.wVersion ) != 1 ||
|
||||||
|
HIBYTE( wsaData.wVersion ) != 1 ) {
|
||||||
|
/* Tell the user that we couldn't find a useable */
|
||||||
|
|
||||||
|
/* winsock.dll. */
|
||||||
|
WSACleanup();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0; /* 0 is ok */
|
||||||
|
}
|
@@ -158,6 +158,9 @@ typedef enum {
|
|||||||
CURLE_BAD_PASSWORD_ENTERED, /* when the my_getpass() returns fail */
|
CURLE_BAD_PASSWORD_ENTERED, /* when the my_getpass() returns fail */
|
||||||
CURLE_TOO_MANY_REDIRECTS , /* catch endless re-direct loops */
|
CURLE_TOO_MANY_REDIRECTS , /* catch endless re-direct loops */
|
||||||
|
|
||||||
|
CURLE_UNKNOWN_TELNET_OPTION , /* User specified an unknown option */
|
||||||
|
CURLE_TELNET_OPTION_SYNTAX , /* Malformed telnet option */
|
||||||
|
|
||||||
CURL_LAST
|
CURL_LAST
|
||||||
} CURLcode;
|
} CURLcode;
|
||||||
|
|
||||||
@@ -406,6 +409,9 @@ typedef enum {
|
|||||||
document! Pass a NULL to shut it off. */
|
document! Pass a NULL to shut it off. */
|
||||||
CINIT(FILETIME, OBJECTPOINT, 69),
|
CINIT(FILETIME, OBJECTPOINT, 69),
|
||||||
|
|
||||||
|
/* This points to a linked list of telnet options */
|
||||||
|
CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unusued */
|
CURLOPT_LASTENTRY /* the last unusued */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
@@ -452,8 +458,8 @@ char *curl_getenv(char *variable);
|
|||||||
char *curl_version(void);
|
char *curl_version(void);
|
||||||
|
|
||||||
/* This is the version number */
|
/* This is the version number */
|
||||||
#define LIBCURL_VERSION "7.6.1"
|
#define LIBCURL_VERSION "7.7-alpha2"
|
||||||
#define LIBCURL_VERSION_NUM 0x070601
|
#define LIBCURL_VERSION_NUM 0x070000
|
||||||
|
|
||||||
/* 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 {
|
||||||
@@ -461,184 +467,8 @@ struct curl_slist {
|
|||||||
struct curl_slist *next;
|
struct curl_slist *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct curl_slist *curl_slist_append(struct curl_slist *list, char *data);
|
struct curl_slist *curl_slist_append(struct curl_slist *, const char *);
|
||||||
void curl_slist_free_all(struct curl_slist *list);
|
void curl_slist_free_all(struct curl_slist *);
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_init()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Inits libcurl globally. This must be used before any libcurl calls can
|
|
||||||
* be used. This may install global plug-ins or whatever. (This does not
|
|
||||||
* do winsock inits in Windows.)
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* curl_init();
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
CURLcode curl_init(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_init()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Frees libcurl globally. This must be used after all libcurl calls have
|
|
||||||
* been used. This may remove global plug-ins or whatever. (This does not
|
|
||||||
* do winsock cleanups in Windows.)
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* curl_free(curl);
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void curl_free(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_open()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Opens a general curl session. It does not try to connect or do anything
|
|
||||||
* on the network because of this call. The specified URL is only required
|
|
||||||
* to enable curl to figure out what protocol to "activate".
|
|
||||||
*
|
|
||||||
* A session should be looked upon as a series of requests to a single host. A
|
|
||||||
* session interacts with one host only, using one single protocol.
|
|
||||||
*
|
|
||||||
* The URL is not required. If set to "" or NULL, it can still be set later
|
|
||||||
* using the curl_setopt() function. If the curl_connect() function is called
|
|
||||||
* without the URL being known, it will return error.
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURLcode result;
|
|
||||||
* CURL *curl;
|
|
||||||
* result = curl_open(&curl, "http://curl.haxx.nu/libcurl/");
|
|
||||||
* if(result != CURL_OK) {
|
|
||||||
* return result;
|
|
||||||
* }
|
|
||||||
* */
|
|
||||||
CURLcode curl_open(CURL **curl, char *url);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_setopt()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Sets a particular option to the specified value.
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURL curl;
|
|
||||||
* curl_setopt(curl, CURL_HTTP_FOLLOW_LOCATION, TRUE);
|
|
||||||
*/
|
|
||||||
CURLcode curl_setopt(CURL *handle, CURLoption option, ...);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_close()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Closes a session previously opened with curl_open()
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURL *curl;
|
|
||||||
* CURLcode result;
|
|
||||||
*
|
|
||||||
* result = curl_close(curl);
|
|
||||||
*/
|
|
||||||
CURLcode curl_close(CURL *curl); /* the opposite of curl_open() */
|
|
||||||
|
|
||||||
CURLcode curl_read(CURLconnect *c_conn, char *buf, size_t buffersize,
|
|
||||||
ssize_t *n);
|
|
||||||
CURLcode curl_write(CURLconnect *c_conn, char *buf, size_t amount,
|
|
||||||
size_t *n);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_connect()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Connects to the peer server and performs the initial setup. This function
|
|
||||||
* writes a connect handle to its second argument that is a unique handle for
|
|
||||||
* this connect. This allows multiple connects from the same handle returned
|
|
||||||
* by curl_open().
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURLCode result;
|
|
||||||
* CURL curl;
|
|
||||||
* CURLconnect connect;
|
|
||||||
* result = curl_connect(curl, &connect);
|
|
||||||
*/
|
|
||||||
|
|
||||||
CURLcode curl_connect(CURL *curl, CURLconnect **in_connect);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_do()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* (Note: May 3rd 2000: this function does not currently allow you to
|
|
||||||
* specify a document, it will use the one set previously)
|
|
||||||
*
|
|
||||||
* This function asks for the particular document, file or resource that
|
|
||||||
* resides on the server we have connected to. You may specify a full URL,
|
|
||||||
* just an absolute path or even a relative path. That means, if you're just
|
|
||||||
* getting one file from the remote site, you can use the same URL as input
|
|
||||||
* for both curl_open() as well as for this function.
|
|
||||||
*
|
|
||||||
* In the even there is a host name, port number, user name or password parts
|
|
||||||
* in the URL, you can use the 'flags' argument to ignore them completely, or
|
|
||||||
* at your choice, make the function fail if you're trying to get a URL from
|
|
||||||
* different host than you connected to with curl_connect().
|
|
||||||
*
|
|
||||||
* You can only get one document at a time using the same connection. When one
|
|
||||||
* document has been received you can although request again.
|
|
||||||
*
|
|
||||||
* When the transfer is done, curl_done() MUST be called.
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURLCode result;
|
|
||||||
* char *url;
|
|
||||||
* CURLconnect *connect;
|
|
||||||
* result = curl_do(connect, url, CURL_DO_NONE); */
|
|
||||||
CURLcode curl_do(CURLconnect *in_conn);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_done()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* When the transfer following a curl_do() call is done, this function should
|
|
||||||
* get called.
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURLCode result;
|
|
||||||
* char *url;
|
|
||||||
* CURLconnect *connect;
|
|
||||||
* result = curl_done(connect); */
|
|
||||||
CURLcode curl_done(CURLconnect *connect);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NAME curl_disconnect()
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* Disconnects from the peer server and performs connection cleanup.
|
|
||||||
*
|
|
||||||
* EXAMPLE
|
|
||||||
*
|
|
||||||
* CURLcode result;
|
|
||||||
* CURLconnect *connect;
|
|
||||||
* result = curl_disconnect(connect); */
|
|
||||||
CURLcode curl_disconnect(CURLconnect *connect);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME curl_getdate()
|
* NAME curl_getdate()
|
||||||
@@ -682,6 +512,10 @@ typedef enum {
|
|||||||
CURLINFO_LASTONE = 17
|
CURLINFO_LASTONE = 17
|
||||||
} CURLINFO;
|
} CURLINFO;
|
||||||
|
|
||||||
|
/* unfortunately, the easy.h include file needs the options and info stuff
|
||||||
|
before it can be included! */
|
||||||
|
#include <curl/easy.h> /* nothing in curl is fun without the easy stuff */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME curl_getinfo()
|
* NAME curl_getinfo()
|
||||||
*
|
*
|
||||||
@@ -696,6 +530,20 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...);
|
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...);
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLCLOSEPOLICY_NONE, /* first, never use this */
|
||||||
|
|
||||||
|
CURLCLOSEPOLICY_OLDEST,
|
||||||
|
CURLCLOSEPOLICY_LEAST_RECENTLY_USED,
|
||||||
|
CURLCLOSEPOLICY_LEAST_TRAFFIC,
|
||||||
|
CURLCLOSEPOLICY_SLOWEST,
|
||||||
|
CURLCLOSEPOLICY_CALLBACK,
|
||||||
|
|
||||||
|
CURLCLOSEPOLICY_LAST /* last, never use this */
|
||||||
|
} curl_closepolicy;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -6,7 +6,7 @@ AUTOMAKE_OPTIONS = foreign
|
|||||||
|
|
||||||
EXTRA_DIST = getdate.y \
|
EXTRA_DIST = getdate.y \
|
||||||
Makefile.b32 Makefile.b32.resp Makefile.m32 Makefile.vc6 \
|
Makefile.b32 Makefile.b32.resp Makefile.m32 Makefile.vc6 \
|
||||||
libcurl.def dllinit.c
|
libcurl.def dllinit.c curllib.dsp curllib.dsw
|
||||||
|
|
||||||
lib_LTLIBRARIES = libcurl.la
|
lib_LTLIBRARIES = libcurl.la
|
||||||
|
|
||||||
|
367
lib/curllib.dsp
Normal file
367
lib/curllib.dsp
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="curllib" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||||
|
|
||||||
|
CFG=curllib - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "curllib.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "curllib.mak" CFG="curllib - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "curllib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||||
|
!MESSAGE "curllib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP AllowPerConfigDependencies 0
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
MTL=midl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "curllib - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /c
|
||||||
|
# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\jdk1.3.0_01\include" /I "C:\jdk1.3.0_01\include\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /c
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /machine:I386 /out:"Release/curl.dll"
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "curllib - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /GZ /c
|
||||||
|
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\jdk1.3.0_01\include" /I "C:\jdk1.3.0_01\include\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CURLLIB_EXPORTS" /YX /FD /GZ /c
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /out:"Debug/curl.dll" /pdbtype:sept
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "curllib - Win32 Release"
|
||||||
|
# Name "curllib - Win32 Debug"
|
||||||
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\base64.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\cookie.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\dict.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\dllinit.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\easy.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\easyswig.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\easyswig_wrap.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\escape.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\file.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\formdata.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ftp.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getdate.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getenv.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getinfo.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getpass.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\hostip.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\http.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\if2ip.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\krb4.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ldap.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\libcurl.def
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\memdebug.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\mprintf.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\netrc.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\progress.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\security.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\sendf.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\speedcheck.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ssluse.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\strequal.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\telnet.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\timeval.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\transfer.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\url.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\version.c
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\arpa_telnet.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\base64.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\cookie.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\dict.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\escape.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\file.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\formdata.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ftp.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getdate.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getenv.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\getpass.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\hostip.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\http.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\if2ip.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\inet_ntoa_r.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\krb4.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ldap.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\memdebug.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\netrc.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\progress.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\security.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\sendf.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\setup.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\speedcheck.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ssluse.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\strequal.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\telnet.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\timeval.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\transfer.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\url.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\urldata.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
# End Group
|
||||||
|
# End Target
|
||||||
|
# End Project
|
29
lib/curllib.dsw
Normal file
29
lib/curllib.dsw
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||||
|
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "curllib"=".\curllib.dsp" - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Global:
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<3>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
12
lib/dict.c
12
lib/dict.c
@@ -141,7 +141,7 @@ CURLcode Curl_dict(struct connectdata *conn)
|
|||||||
nth = atoi(nthdef);
|
nth = atoi(nthdef);
|
||||||
}
|
}
|
||||||
|
|
||||||
Curl_sendf(data->firstsocket, conn,
|
Curl_sendf(conn->firstsocket, conn,
|
||||||
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
||||||
"MATCH "
|
"MATCH "
|
||||||
"%s " /* database */
|
"%s " /* database */
|
||||||
@@ -154,7 +154,7 @@ CURLcode Curl_dict(struct connectdata *conn)
|
|||||||
word
|
word
|
||||||
);
|
);
|
||||||
|
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, FALSE, bytecount,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, FALSE, bytecount,
|
||||||
-1, NULL); /* no upload */
|
-1, NULL); /* no upload */
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
@@ -191,7 +191,7 @@ CURLcode Curl_dict(struct connectdata *conn)
|
|||||||
nth = atoi(nthdef);
|
nth = atoi(nthdef);
|
||||||
}
|
}
|
||||||
|
|
||||||
Curl_sendf(data->firstsocket, conn,
|
Curl_sendf(conn->firstsocket, conn,
|
||||||
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
||||||
"DEFINE "
|
"DEFINE "
|
||||||
"%s " /* database */
|
"%s " /* database */
|
||||||
@@ -202,7 +202,7 @@ CURLcode Curl_dict(struct connectdata *conn)
|
|||||||
word
|
word
|
||||||
);
|
);
|
||||||
|
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, FALSE, bytecount,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, FALSE, bytecount,
|
||||||
-1, NULL); /* no upload */
|
-1, NULL); /* no upload */
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
@@ -220,13 +220,13 @@ CURLcode Curl_dict(struct connectdata *conn)
|
|||||||
if (ppath[i] == ':')
|
if (ppath[i] == ':')
|
||||||
ppath[i] = ' ';
|
ppath[i] = ' ';
|
||||||
}
|
}
|
||||||
Curl_sendf(data->firstsocket, conn,
|
Curl_sendf(conn->firstsocket, conn,
|
||||||
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"QUIT\n",
|
"QUIT\n",
|
||||||
ppath);
|
ppath);
|
||||||
|
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, FALSE, bytecount,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, FALSE, bytecount,
|
||||||
-1, NULL);
|
-1, NULL);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
|
312
lib/ftp.c
312
lib/ftp.c
@@ -88,76 +88,8 @@
|
|||||||
/* easy-to-use macro: */
|
/* easy-to-use macro: */
|
||||||
#define ftpsendf Curl_ftpsendf
|
#define ftpsendf Curl_ftpsendf
|
||||||
|
|
||||||
/* returns last node in linked list */
|
|
||||||
static struct curl_slist *slist_get_last(struct curl_slist *list)
|
|
||||||
{
|
|
||||||
struct curl_slist *item;
|
|
||||||
|
|
||||||
/* if caller passed us a NULL, return now */
|
|
||||||
if (!list)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* loop through to find the last item */
|
|
||||||
item = list;
|
|
||||||
while (item->next) {
|
|
||||||
item = item->next;
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* append a struct to the linked list. It always retunrs the address of the
|
|
||||||
* first record, so that you can sure this function as an initialization
|
|
||||||
* function as well as an append function. If you find this bothersome,
|
|
||||||
* then simply create a separate _init function and call it appropriately from
|
|
||||||
* within the proram. */
|
|
||||||
struct curl_slist *curl_slist_append(struct curl_slist *list, char *data)
|
|
||||||
{
|
|
||||||
struct curl_slist *last;
|
|
||||||
struct curl_slist *new_item;
|
|
||||||
|
|
||||||
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
|
|
||||||
if (new_item) {
|
|
||||||
new_item->next = NULL;
|
|
||||||
new_item->data = strdup(data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(stderr, "Cannot allocate memory for QUOTE list.\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list) {
|
|
||||||
last = slist_get_last(list);
|
|
||||||
last->next = new_item;
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if this is the first item, then new_item *is* the list */
|
|
||||||
return new_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* be nice and clean up resources */
|
|
||||||
void curl_slist_free_all(struct curl_slist *list)
|
|
||||||
{
|
|
||||||
struct curl_slist *next;
|
|
||||||
struct curl_slist *item;
|
|
||||||
|
|
||||||
if (!list)
|
|
||||||
return;
|
|
||||||
|
|
||||||
item = list;
|
|
||||||
do {
|
|
||||||
next = item->next;
|
|
||||||
|
|
||||||
if (item->data) {
|
|
||||||
free(item->data);
|
|
||||||
}
|
|
||||||
free(item);
|
|
||||||
item = next;
|
|
||||||
} while (next);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static CURLcode AllowServerConnect(struct UrlData *data,
|
static CURLcode AllowServerConnect(struct UrlData *data,
|
||||||
|
struct connectdata *conn,
|
||||||
int sock)
|
int sock)
|
||||||
{
|
{
|
||||||
fd_set rdset;
|
fd_set rdset;
|
||||||
@@ -199,7 +131,7 @@ static CURLcode AllowServerConnect(struct UrlData *data,
|
|||||||
}
|
}
|
||||||
infof(data, "Connection accepted from server\n");
|
infof(data, "Connection accepted from server\n");
|
||||||
|
|
||||||
data->secondarysocket = s;
|
conn->secondarysocket = s;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -362,23 +294,25 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
memset(ftp, 0, sizeof(struct FTP));
|
memset(ftp, 0, sizeof(struct FTP));
|
||||||
data->proto.ftp = ftp;
|
conn->proto.ftp = ftp;
|
||||||
|
|
||||||
/* get some initial data into the ftp struct */
|
/* get some initial data into the ftp struct */
|
||||||
ftp->bytecountp = &conn->bytecount;
|
ftp->bytecountp = &conn->bytecount;
|
||||||
ftp->user = data->user;
|
|
||||||
ftp->passwd = data->passwd;
|
/* duplicate to keep them even when the data struct changes */
|
||||||
|
ftp->user = strdup(data->user);
|
||||||
|
ftp->passwd = strdup(data->passwd);
|
||||||
|
|
||||||
if (data->bits.tunnel_thru_httpproxy) {
|
if (data->bits.tunnel_thru_httpproxy) {
|
||||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
||||||
result = Curl_ConnectHTTPProxyTunnel(conn, data->firstsocket,
|
result = Curl_ConnectHTTPProxyTunnel(conn, conn->firstsocket,
|
||||||
data->hostname, data->remote_port);
|
conn->hostname, conn->remote_port);
|
||||||
if(CURLE_OK != result)
|
if(CURLE_OK != result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -398,7 +332,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
set a valid level */
|
set a valid level */
|
||||||
sec_request_prot(conn, data->krb4_level);
|
sec_request_prot(conn, data->krb4_level);
|
||||||
|
|
||||||
data->cmdchannel = fdopen(data->firstsocket, "w");
|
data->cmdchannel = fdopen(conn->firstsocket, "w");
|
||||||
|
|
||||||
if(sec_login(conn) != 0)
|
if(sec_login(conn) != 0)
|
||||||
infof(data, "Logging in with password in cleartext!\n");
|
infof(data, "Logging in with password in cleartext!\n");
|
||||||
@@ -408,10 +342,10 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* send USER */
|
/* send USER */
|
||||||
ftpsendf(data->firstsocket, conn, "USER %s", ftp->user);
|
ftpsendf(conn->firstsocket, conn, "USER %s", ftp->user);
|
||||||
|
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -424,8 +358,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
else if(ftpcode == 331) {
|
else if(ftpcode == 331) {
|
||||||
/* 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(data->firstsocket, conn, "PASS %s", ftp->passwd);
|
ftpsendf(conn->firstsocket, conn, "PASS %s", ftp->passwd);
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -469,6 +403,58 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
return CURLE_FTP_WEIRD_USER_REPLY;
|
return CURLE_FTP_WEIRD_USER_REPLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send PWD to discover our entry point */
|
||||||
|
ftpsendf(conn->firstsocket, conn, "PWD");
|
||||||
|
|
||||||
|
/* wait for feedback */
|
||||||
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
|
if(nread < 0)
|
||||||
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
|
if(ftpcode == 257) {
|
||||||
|
char *dir = (char *)malloc(nread+1);
|
||||||
|
char *store=dir;
|
||||||
|
char *ptr=&buf[4]; /* start on the first letter */
|
||||||
|
|
||||||
|
/* Reply format is like
|
||||||
|
257<space>"<directory-name>"<space><commentary> and the RFC959 says
|
||||||
|
|
||||||
|
The directory name can contain any character; embedded double-quotes
|
||||||
|
should be escaped by double-quotes (the "quote-doubling" convention).
|
||||||
|
*/
|
||||||
|
if('\"' == *ptr) {
|
||||||
|
/* it started good */
|
||||||
|
ptr++;
|
||||||
|
while(ptr && *ptr) {
|
||||||
|
if('\"' == *ptr) {
|
||||||
|
if('\"' == ptr[1]) {
|
||||||
|
/* "quote-doubling" */
|
||||||
|
*store = ptr[1];
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* end of path */
|
||||||
|
*store = '\0'; /* zero terminate */
|
||||||
|
break; /* get out of this loop */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*store = *ptr;
|
||||||
|
store++;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
ftp->entrypath =dir; /* remember this */
|
||||||
|
infof(data, "Entry path is '%s'\n", ftp->entrypath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* couldn't get the path */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* We couldn't read the PWD response! */
|
||||||
|
}
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +463,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
|||||||
CURLcode Curl_ftp_done(struct connectdata *conn)
|
CURLcode Curl_ftp_done(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
struct UrlData *data = conn->data;
|
struct UrlData *data = conn->data;
|
||||||
struct FTP *ftp = data->proto.ftp;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
size_t nread;
|
size_t nread;
|
||||||
char *buf = data->buffer; /* this is our buffer */
|
char *buf = data->buffer; /* this is our buffer */
|
||||||
struct curl_slist *qitem; /* QUOTE item */
|
struct curl_slist *qitem; /* QUOTE item */
|
||||||
@@ -492,7 +478,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if((-1 != conn->size) && (conn->size != *ftp->bytecountp) &&
|
if((-1 != conn->size) && (conn->size != *ftp->bytecountp) &&
|
||||||
(data->maxdownload != *ftp->bytecountp)) {
|
(conn->maxdownload != *ftp->bytecountp)) {
|
||||||
failf(data, "Received only partial file");
|
failf(data, "Received only partial file");
|
||||||
return CURLE_PARTIAL_FILE;
|
return CURLE_PARTIAL_FILE;
|
||||||
}
|
}
|
||||||
@@ -502,16 +488,16 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
sec_fflush_fd(conn, data->secondarysocket);
|
sec_fflush_fd(conn, conn->secondarysocket);
|
||||||
#endif
|
#endif
|
||||||
/* shut down the socket to inform the server we're done */
|
/* shut down the socket to inform the server we're done */
|
||||||
sclose(data->secondarysocket);
|
sclose(conn->secondarysocket);
|
||||||
data->secondarysocket = -1;
|
conn->secondarysocket = -1;
|
||||||
|
|
||||||
if(!data->bits.no_body) {
|
if(!data->bits.no_body) {
|
||||||
/* now let's see what the server says about the transfer we
|
/* now let's see what the server says about the transfer we
|
||||||
just performed: */
|
just performed: */
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -529,9 +515,9 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
while (qitem) {
|
while (qitem) {
|
||||||
/* Send string */
|
/* Send string */
|
||||||
if (qitem->data) {
|
if (qitem->data) {
|
||||||
ftpsendf(data->firstsocket, conn, "%s", qitem->data);
|
ftpsendf(conn->firstsocket, conn, "%s", qitem->data);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -571,7 +557,7 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
|
|
||||||
struct curl_slist *qitem; /* QUOTE item */
|
struct curl_slist *qitem; /* QUOTE item */
|
||||||
/* the ftp struct is already inited in ftp_connect() */
|
/* the ftp struct is already inited in ftp_connect() */
|
||||||
struct FTP *ftp = data->proto.ftp;
|
struct FTP *ftp = conn->proto.ftp;
|
||||||
|
|
||||||
long *bytecountp = ftp->bytecountp;
|
long *bytecountp = ftp->bytecountp;
|
||||||
int ftpcode; /* for ftp status */
|
int ftpcode; /* for ftp status */
|
||||||
@@ -583,9 +569,9 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
while (qitem) {
|
while (qitem) {
|
||||||
/* Send string */
|
/* Send string */
|
||||||
if (qitem->data) {
|
if (qitem->data) {
|
||||||
ftpsendf(data->firstsocket, conn, "%s", qitem->data);
|
ftpsendf(conn->firstsocket, conn, "%s", qitem->data);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -599,10 +585,27 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(conn->bits.reuse) {
|
||||||
|
/* This is a re-used connection. Since we change directory to where the
|
||||||
|
transfer is taking place, we must now get back to the original dir
|
||||||
|
where we ended up after login: */
|
||||||
|
ftpsendf(conn->firstsocket, conn, "CWD %s", ftp->entrypath);
|
||||||
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
|
if(nread < 0)
|
||||||
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
|
if(ftpcode != 250) {
|
||||||
|
failf(data, "Couldn't change back to directory %s", ftp->entrypath);
|
||||||
|
return CURLE_FTP_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* change directory first! */
|
/* change directory first! */
|
||||||
if(ftp->dir && ftp->dir[0]) {
|
if(ftp->dir && ftp->dir[0]) {
|
||||||
ftpsendf(data->firstsocket, conn, "CWD %s", ftp->dir);
|
ftpsendf(conn->firstsocket, conn, "CWD %s", ftp->dir);
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -615,9 +618,9 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
if(data->bits.get_filetime && ftp->file) {
|
if(data->bits.get_filetime && ftp->file) {
|
||||||
/* we have requested to get the modified-time of the file, this is yet
|
/* we have requested to get the modified-time of the file, this is yet
|
||||||
again a grey area as the MDTM is not kosher RFC959 */
|
again a grey area as the MDTM is not kosher RFC959 */
|
||||||
ftpsendf(data->firstsocket, conn, "MDTM %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "MDTM %s", ftp->file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -651,10 +654,10 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
|
|
||||||
/* Some servers return different sizes for different modes, and thus we
|
/* Some servers return different sizes for different modes, and thus we
|
||||||
must set the proper type before we check the size */
|
must set the proper type before we check the size */
|
||||||
ftpsendf(data->firstsocket, conn, "TYPE %s",
|
ftpsendf(conn->firstsocket, conn, "TYPE %s",
|
||||||
(data->bits.ftp_ascii)?"A":"I");
|
(data->bits.ftp_ascii)?"A":"I");
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -665,9 +668,9 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
CURLE_FTP_COULDNT_SET_BINARY;
|
CURLE_FTP_COULDNT_SET_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "SIZE %s", ftp->file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -731,7 +734,7 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
* I believe we should use the same address as the control connection.
|
* I believe we should use the same address as the control connection.
|
||||||
*/
|
*/
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
if (getsockname(data->firstsocket, (struct sockaddr *)&ss, &sslen) < 0)
|
if (getsockname(conn->firstsocket, (struct sockaddr *)&ss, &sslen) < 0)
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
|
|
||||||
if (getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL, 0,
|
if (getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL, 0,
|
||||||
@@ -819,7 +822,7 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
if (q)
|
if (q)
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
}
|
}
|
||||||
ftpsendf(data->firstsocket, conn, "%s |%d|%s|%s|", *modep, eprtaf,
|
ftpsendf(conn->firstsocket, conn, "%s |%d|%s|%s|", *modep, eprtaf,
|
||||||
portmsgbuf, tmp);
|
portmsgbuf, tmp);
|
||||||
} else if (strcmp(*modep, "LPRT") == 0 || strcmp(*modep, "PORT") == 0) {
|
} else if (strcmp(*modep, "LPRT") == 0 || strcmp(*modep, "PORT") == 0) {
|
||||||
int i;
|
int i;
|
||||||
@@ -856,10 +859,10 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ftpsendf(data->firstsocket, conn, "%s %s", *modep, portmsgbuf);
|
ftpsendf(conn->firstsocket, conn, "%s %s", *modep, portmsgbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -909,7 +912,7 @@ again:;
|
|||||||
/* we set the secondary socket variable to this for now, it
|
/* we set the secondary socket variable to this for now, it
|
||||||
is only so that the cleanup function will close it in case
|
is only so that the cleanup function will close it in case
|
||||||
we fail before the true secondary stuff is made */
|
we fail before the true secondary stuff is made */
|
||||||
data->secondarysocket = portsock;
|
conn->secondarysocket = portsock;
|
||||||
|
|
||||||
memset((char *)&sa, 0, sizeof(sa));
|
memset((char *)&sa, 0, sizeof(sa));
|
||||||
memcpy((char *)&sa.sin_addr,
|
memcpy((char *)&sa.sin_addr,
|
||||||
@@ -971,13 +974,13 @@ again:;
|
|||||||
sscanf( inet_ntoa(in), "%hu.%hu.%hu.%hu",
|
sscanf( inet_ntoa(in), "%hu.%hu.%hu.%hu",
|
||||||
&ip[0], &ip[1], &ip[2], &ip[3]);
|
&ip[0], &ip[1], &ip[2], &ip[3]);
|
||||||
#endif
|
#endif
|
||||||
ftpsendf(data->firstsocket, conn, "PORT %d,%d,%d,%d,%d,%d",
|
ftpsendf(conn->firstsocket, conn, "PORT %d,%d,%d,%d,%d,%d",
|
||||||
ip[0], ip[1], ip[2], ip[3],
|
ip[0], ip[1], ip[2], ip[3],
|
||||||
porttouse >> 8,
|
porttouse >> 8,
|
||||||
porttouse & 255);
|
porttouse & 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -998,8 +1001,8 @@ again:;
|
|||||||
int modeoff;
|
int modeoff;
|
||||||
|
|
||||||
for (modeoff = 0; mode[modeoff]; modeoff++) {
|
for (modeoff = 0; mode[modeoff]; modeoff++) {
|
||||||
ftpsendf(data->firstsocket, conn, mode[modeoff]);
|
ftpsendf(conn->firstsocket, conn, mode[modeoff]);
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1057,12 +1060,12 @@ again:;
|
|||||||
* previous lookup.
|
* previous lookup.
|
||||||
*/
|
*/
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
res = conn->res;
|
res = conn->hp;
|
||||||
#else
|
#else
|
||||||
he = conn->hp;
|
he = conn->hp;
|
||||||
#endif
|
#endif
|
||||||
connectport =
|
connectport =
|
||||||
(unsigned short)data->port; /* we connect to the proxy's port */
|
(unsigned short)conn->port; /* we connect to the proxy's port */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* normal, direct, ftp connection */
|
/* normal, direct, ftp connection */
|
||||||
@@ -1081,15 +1084,15 @@ again:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
data->secondarysocket = -1;
|
conn->secondarysocket = -1;
|
||||||
for (ai = res; ai; ai = ai->ai_next) {
|
for (ai = res; ai; ai = ai->ai_next) {
|
||||||
/* XXX for now, we can do IPv4 only */
|
/* XXX for now, we can do IPv4 only */
|
||||||
if (ai->ai_family != AF_INET)
|
if (ai->ai_family != AF_INET)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
data->secondarysocket = socket(ai->ai_family, ai->ai_socktype,
|
conn->secondarysocket = socket(ai->ai_family, ai->ai_socktype,
|
||||||
ai->ai_protocol);
|
ai->ai_protocol);
|
||||||
if (data->secondarysocket < 0)
|
if (conn->secondarysocket < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(data->bits.verbose) {
|
if(data->bits.verbose) {
|
||||||
@@ -1114,21 +1117,21 @@ again:;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(data->secondarysocket, ai->ai_addr, ai->ai_addrlen) < 0) {
|
if (connect(conn->secondarysocket, ai->ai_addr, ai->ai_addrlen) < 0) {
|
||||||
close(data->secondarysocket);
|
close(conn->secondarysocket);
|
||||||
data->secondarysocket = -1;
|
conn->secondarysocket = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->secondarysocket < 0) {
|
if (conn->secondarysocket < 0) {
|
||||||
failf(data, strerror(errno));
|
failf(data, strerror(errno));
|
||||||
return CURLE_FTP_CANT_RECONNECT;
|
return CURLE_FTP_CANT_RECONNECT;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
data->secondarysocket = socket(AF_INET, SOCK_STREAM, 0);
|
conn->secondarysocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
memset((char *) &serv_addr, '\0', sizeof(serv_addr));
|
memset((char *) &serv_addr, '\0', sizeof(serv_addr));
|
||||||
memcpy((char *)&(serv_addr.sin_addr), he->h_addr, he->h_length);
|
memcpy((char *)&(serv_addr.sin_addr), he->h_addr, he->h_length);
|
||||||
@@ -1202,7 +1205,7 @@ again:;
|
|||||||
if(hostdataptr)
|
if(hostdataptr)
|
||||||
free(hostdataptr);
|
free(hostdataptr);
|
||||||
|
|
||||||
if (connect(data->secondarysocket, (struct sockaddr *) &serv_addr,
|
if (connect(conn->secondarysocket, (struct sockaddr *) &serv_addr,
|
||||||
sizeof(serv_addr)) < 0) {
|
sizeof(serv_addr)) < 0) {
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
#ifdef ECONNREFUSED
|
#ifdef ECONNREFUSED
|
||||||
@@ -1213,7 +1216,7 @@ again:;
|
|||||||
#endif
|
#endif
|
||||||
#ifdef EINTR
|
#ifdef EINTR
|
||||||
case EINTR:
|
case EINTR:
|
||||||
failf(data, "Connection timeouted to ftp server");
|
failf(data, "Connection timed out to ftp server");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@@ -1226,7 +1229,7 @@ again:;
|
|||||||
|
|
||||||
if (data->bits.tunnel_thru_httpproxy) {
|
if (data->bits.tunnel_thru_httpproxy) {
|
||||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
||||||
result = Curl_ConnectHTTPProxyTunnel(conn, data->secondarysocket,
|
result = Curl_ConnectHTTPProxyTunnel(conn, conn->secondarysocket,
|
||||||
newhost, newport);
|
newhost, newport);
|
||||||
if(CURLE_OK != result)
|
if(CURLE_OK != result)
|
||||||
return result;
|
return result;
|
||||||
@@ -1241,10 +1244,10 @@ again:;
|
|||||||
if(data->bits.upload) {
|
if(data->bits.upload) {
|
||||||
|
|
||||||
/* Set type to binary (unless specified ASCII) */
|
/* Set type to binary (unless specified ASCII) */
|
||||||
ftpsendf(data->firstsocket, conn, "TYPE %s",
|
ftpsendf(conn->firstsocket, conn, "TYPE %s",
|
||||||
(data->bits.ftp_ascii)?"A":"I");
|
(data->bits.ftp_ascii)?"A":"I");
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1273,9 +1276,9 @@ again:;
|
|||||||
/* we could've got a specified offset from the command line,
|
/* we could've got a specified offset from the command line,
|
||||||
but now we know we didn't */
|
but now we know we didn't */
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "SIZE %s", ftp->file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1332,11 +1335,11 @@ again:;
|
|||||||
/* Send everything on data->in to the socket */
|
/* Send everything on data->in to the socket */
|
||||||
if(data->bits.ftp_append)
|
if(data->bits.ftp_append)
|
||||||
/* we append onto the file instead of rewriting it */
|
/* we append onto the file instead of rewriting it */
|
||||||
ftpsendf(data->firstsocket, conn, "APPE %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "APPE %s", ftp->file);
|
||||||
else
|
else
|
||||||
ftpsendf(data->firstsocket, conn, "STOR %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "STOR %s", ftp->file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1347,7 +1350,7 @@ again:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(data->bits.ftp_use_port) {
|
if(data->bits.ftp_use_port) {
|
||||||
result = AllowServerConnect(data, portsock);
|
result = AllowServerConnect(data, conn, portsock);
|
||||||
if( result )
|
if( result )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1360,7 +1363,7 @@ again:;
|
|||||||
Curl_pgrsSetUploadSize(data, data->infilesize);
|
Curl_pgrsSetUploadSize(data, data->infilesize);
|
||||||
|
|
||||||
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
|
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
|
||||||
data->secondarysocket, bytecountp);
|
conn->secondarysocket, bytecountp);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@@ -1392,16 +1395,16 @@ again:;
|
|||||||
else if(from < 0) {
|
else if(from < 0) {
|
||||||
/* -Y */
|
/* -Y */
|
||||||
totalsize = -from;
|
totalsize = -from;
|
||||||
data->maxdownload = -from;
|
conn->maxdownload = -from;
|
||||||
data->resume_from = from;
|
data->resume_from = from;
|
||||||
infof(data, "FTP RANGE the last %d bytes\n", totalsize);
|
infof(data, "FTP RANGE the last %d bytes\n", totalsize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* X-Y */
|
/* X-Y */
|
||||||
totalsize = to-from;
|
totalsize = to-from;
|
||||||
data->maxdownload = totalsize+1; /* include the last mentioned byte */
|
conn->maxdownload = totalsize+1; /* include the last mentioned byte */
|
||||||
data->resume_from = from;
|
data->resume_from = from;
|
||||||
infof(data, "FTP RANGE from %d getting %d bytes\n", from, data->maxdownload);
|
infof(data, "FTP RANGE from %d getting %d bytes\n", from, conn->maxdownload);
|
||||||
}
|
}
|
||||||
infof(data, "range-download from %d to %d, totally %d bytes\n",
|
infof(data, "range-download from %d to %d, totally %d bytes\n",
|
||||||
from, to, totalsize);
|
from, to, totalsize);
|
||||||
@@ -1414,9 +1417,9 @@ again:;
|
|||||||
dirlist = TRUE;
|
dirlist = TRUE;
|
||||||
|
|
||||||
/* Set type to ASCII */
|
/* Set type to ASCII */
|
||||||
ftpsendf(data->firstsocket, conn, "TYPE A");
|
ftpsendf(conn->firstsocket, conn, "TYPE A");
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1429,16 +1432,16 @@ again:;
|
|||||||
better used since the LIST command output is not specified or
|
better used since the LIST command output is not specified or
|
||||||
standard in any way */
|
standard in any way */
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "%s",
|
ftpsendf(conn->firstsocket, conn, "%s",
|
||||||
data->customrequest?data->customrequest:
|
data->customrequest?data->customrequest:
|
||||||
(data->bits.ftp_list_only?"NLST":"LIST"));
|
(data->bits.ftp_list_only?"NLST":"LIST"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Set type to binary (unless specified ASCII) */
|
/* Set type to binary (unless specified ASCII) */
|
||||||
ftpsendf(data->firstsocket, conn, "TYPE %s",
|
ftpsendf(conn->firstsocket, conn, "TYPE %s",
|
||||||
(data->bits.ftp_ascii)?"A":"I");
|
(data->bits.ftp_ascii)?"A":"I");
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1457,9 +1460,9 @@ again:;
|
|||||||
* of the file we're gonna get. If we can get the size, this is by far
|
* of the file we're gonna get. If we can get the size, this is by far
|
||||||
* the best way to know if we're trying to resume beyond the EOF. */
|
* the best way to know if we're trying to resume beyond the EOF. */
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "SIZE %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "SIZE %s", ftp->file);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1501,9 +1504,9 @@ again:;
|
|||||||
infof(data, "Instructs server to resume from offset %d\n",
|
infof(data, "Instructs server to resume from offset %d\n",
|
||||||
data->resume_from);
|
data->resume_from);
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "REST %d", data->resume_from);
|
ftpsendf(conn->firstsocket, conn, "REST %d", data->resume_from);
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1513,10 +1516,10 @@ again:;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ftpsendf(data->firstsocket, conn, "RETR %s", ftp->file);
|
ftpsendf(conn->firstsocket, conn, "RETR %s", ftp->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = Curl_GetFTPResponse(data->firstsocket, buf, conn, &ftpcode);
|
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
|
|
||||||
@@ -1580,7 +1583,7 @@ again:;
|
|||||||
size = downloadsize;
|
size = downloadsize;
|
||||||
|
|
||||||
if(data->bits.ftp_use_port) {
|
if(data->bits.ftp_use_port) {
|
||||||
result = AllowServerConnect(data, portsock);
|
result = AllowServerConnect(data, conn, portsock);
|
||||||
if( result )
|
if( result )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1588,7 +1591,7 @@ again:;
|
|||||||
infof(data, "Getting file with size: %d\n", size);
|
infof(data, "Getting file with size: %d\n", size);
|
||||||
|
|
||||||
/* FTP download: */
|
/* FTP download: */
|
||||||
result=Curl_Transfer(conn, data->secondarysocket, size, FALSE,
|
result=Curl_Transfer(conn, conn->secondarysocket, size, FALSE,
|
||||||
bytecountp,
|
bytecountp,
|
||||||
-1, NULL); /* no upload here */
|
-1, NULL); /* no upload here */
|
||||||
if(result)
|
if(result)
|
||||||
@@ -1617,7 +1620,7 @@ CURLcode Curl_ftp(struct connectdata *conn)
|
|||||||
int dirlength=0; /* 0 forces strlen() */
|
int dirlength=0; /* 0 forces strlen() */
|
||||||
|
|
||||||
/* the ftp struct is already inited in ftp_connect() */
|
/* the ftp struct is already inited in ftp_connect() */
|
||||||
ftp = data->proto.ftp;
|
ftp = conn->proto.ftp;
|
||||||
|
|
||||||
/* We split the path into dir and file parts *before* we URLdecode
|
/* We split the path into dir and file parts *before* we URLdecode
|
||||||
it */
|
it */
|
||||||
@@ -1706,3 +1709,16 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CURLcode Curl_ftp_disconnect(struct connectdata *conn)
|
||||||
|
{
|
||||||
|
struct FTP *ftp= conn->proto.ftp;
|
||||||
|
|
||||||
|
if(ftp->user)
|
||||||
|
free(ftp->user);
|
||||||
|
if(ftp->passwd)
|
||||||
|
free(ftp->passwd);
|
||||||
|
if(ftp->entrypath)
|
||||||
|
free(ftp->entrypath);
|
||||||
|
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
||||||
|
@@ -26,12 +26,10 @@
|
|||||||
CURLcode Curl_ftp(struct connectdata *conn);
|
CURLcode Curl_ftp(struct connectdata *conn);
|
||||||
CURLcode Curl_ftp_done(struct connectdata *conn);
|
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);
|
||||||
|
|
||||||
size_t Curl_ftpsendf(int fd, struct connectdata *, char *fmt, ...);
|
size_t Curl_ftpsendf(int fd, struct connectdata *, char *fmt, ...);
|
||||||
|
|
||||||
struct curl_slist *curl_slist_append(struct curl_slist *list, char *data);
|
|
||||||
void curl_slist_free_all(struct curl_slist *list);
|
|
||||||
|
|
||||||
/* The kerberos stuff needs this: */
|
/* The kerberos stuff needs this: */
|
||||||
int Curl_GetFTPResponse(int sockfd, char *buf,
|
int Curl_GetFTPResponse(int sockfd, char *buf,
|
||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
|
@@ -390,7 +390,7 @@ static const short yycheck[] = { 0,
|
|||||||
56
|
56
|
||||||
};
|
};
|
||||||
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
||||||
#line 3 "/usr/local/share/bison.simple"
|
#line 3 "/usr/lib/bison.simple"
|
||||||
/* This file comes from bison-1.28. */
|
/* This file comes from bison-1.28. */
|
||||||
|
|
||||||
/* Skeleton output parser for bison,
|
/* Skeleton output parser for bison,
|
||||||
@@ -604,7 +604,7 @@ __yy_memcpy (char *to, char *from, unsigned int count)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#line 217 "/usr/local/share/bison.simple"
|
#line 217 "/usr/lib/bison.simple"
|
||||||
|
|
||||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||||
into yyparse. The argument should have type void *.
|
into yyparse. The argument should have type void *.
|
||||||
@@ -1295,7 +1295,7 @@ case 50:
|
|||||||
break;}
|
break;}
|
||||||
}
|
}
|
||||||
/* the action file gets copied in in place of this dollarsign */
|
/* the action file gets copied in in place of this dollarsign */
|
||||||
#line 543 "/usr/local/share/bison.simple"
|
#line 543 "/usr/lib/bison.simple"
|
||||||
|
|
||||||
yyvsp -= yylen;
|
yyvsp -= yylen;
|
||||||
yyssp -= yylen;
|
yyssp -= yylen;
|
||||||
|
103
lib/http.c
103
lib/http.c
@@ -282,8 +282,8 @@ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
|
|||||||
"%s"
|
"%s"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
hostname, remote_port,
|
hostname, remote_port,
|
||||||
(data->bits.proxy_user_passwd)?data->ptr_proxyuserpwd:"",
|
(data->bits.proxy_user_passwd)?conn->allocptr.proxyuserpwd:"",
|
||||||
(data->useragent?data->ptr_uagent:"")
|
(data->useragent?conn->allocptr.uagent:"")
|
||||||
);
|
);
|
||||||
|
|
||||||
/* wait for the proxy to send us a HTTP/1.0 200 OK header */
|
/* wait for the proxy to send us a HTTP/1.0 200 OK header */
|
||||||
@@ -325,21 +325,21 @@ CURLcode Curl_http_connect(struct connectdata *conn)
|
|||||||
if (conn->protocol & PROT_HTTPS) {
|
if (conn->protocol & PROT_HTTPS) {
|
||||||
if (data->bits.httpproxy) {
|
if (data->bits.httpproxy) {
|
||||||
/* HTTPS through a proxy can only be done with a tunnel */
|
/* HTTPS through a proxy can only be done with a tunnel */
|
||||||
result = Curl_ConnectHTTPProxyTunnel(conn, data->firstsocket,
|
result = Curl_ConnectHTTPProxyTunnel(conn, conn->firstsocket,
|
||||||
data->hostname, data->remote_port);
|
conn->hostname, conn->remote_port);
|
||||||
if(CURLE_OK != result)
|
if(CURLE_OK != result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now, perform the SSL initialization for this socket */
|
/* now, perform the SSL initialization for this socket */
|
||||||
if(Curl_SSLConnect(data))
|
if(Curl_SSLConnect(conn))
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->bits.user_passwd && !data->bits.this_is_a_follow) {
|
if(data->bits.user_passwd && !data->bits.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 */
|
||||||
data->auth_host = strdup(data->hostname);
|
data->auth_host = strdup(conn->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
@@ -361,7 +361,7 @@ CURLcode Curl_http_done(struct connectdata *conn)
|
|||||||
struct HTTP *http;
|
struct HTTP *http;
|
||||||
|
|
||||||
data=conn->data;
|
data=conn->data;
|
||||||
http=data->proto.http;
|
http=conn->proto.http;
|
||||||
|
|
||||||
if(data->bits.http_formpost) {
|
if(data->bits.http_formpost) {
|
||||||
*bytecount = http->readbytecount + http->writebytecount;
|
*bytecount = http->readbytecount + http->writebytecount;
|
||||||
@@ -390,11 +390,17 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
char *host = conn->name;
|
char *host = conn->name;
|
||||||
long *bytecount = &conn->bytecount;
|
long *bytecount = &conn->bytecount;
|
||||||
|
|
||||||
http = (struct HTTP *)malloc(sizeof(struct HTTP));
|
if(!conn->proto.http) {
|
||||||
if(!http)
|
/* Only allocate this struct if we don't already have it! */
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
memset(http, 0, sizeof(struct HTTP));
|
http = (struct HTTP *)malloc(sizeof(struct HTTP));
|
||||||
data->proto.http = http;
|
if(!http)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
memset(http, 0, sizeof(struct HTTP));
|
||||||
|
conn->proto.http = http;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
http = conn->proto.http;
|
||||||
|
|
||||||
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
||||||
data->bits.upload) {
|
data->bits.upload) {
|
||||||
@@ -405,9 +411,9 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
have been used in the proxy connect, but if we have got a header with
|
have been used in the proxy connect, but if we have got a header with
|
||||||
the user-agent string specified, we erase the previously made string
|
the user-agent string specified, we erase the previously made string
|
||||||
here. */
|
here. */
|
||||||
if(checkheaders(data, "User-Agent:") && data->ptr_uagent) {
|
if(checkheaders(data, "User-Agent:") && conn->allocptr.uagent) {
|
||||||
free(data->ptr_uagent);
|
free(conn->allocptr.uagent);
|
||||||
data->ptr_uagent=NULL;
|
conn->allocptr.uagent=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((data->bits.user_passwd) && !checkheaders(data, "Authorization:")) {
|
if((data->bits.user_passwd) && !checkheaders(data, "Authorization:")) {
|
||||||
@@ -417,21 +423,27 @@ 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->bits.this_is_a_follow ||
|
if(!data->bits.this_is_a_follow ||
|
||||||
!data->auth_host ||
|
!data->auth_host ||
|
||||||
strequal(data->auth_host, data->hostname)) {
|
strequal(data->auth_host, conn->hostname)) {
|
||||||
sprintf(data->buffer, "%s:%s", data->user, data->passwd);
|
sprintf(data->buffer, "%s:%s", data->user, data->passwd);
|
||||||
if(Curl_base64_encode(data->buffer, strlen(data->buffer),
|
if(Curl_base64_encode(data->buffer, strlen(data->buffer),
|
||||||
&authorization) >= 0) {
|
&authorization) >= 0) {
|
||||||
data->ptr_userpwd = aprintf( "Authorization: Basic %s\015\012",
|
if(conn->allocptr.userpwd)
|
||||||
|
free(conn->allocptr.userpwd);
|
||||||
|
conn->allocptr.userpwd = aprintf( "Authorization: Basic %s\015\012",
|
||||||
authorization);
|
authorization);
|
||||||
free(authorization);
|
free(authorization);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((data->bits.http_set_referer) && !checkheaders(data, "Referer:")) {
|
if((data->bits.http_set_referer) && !checkheaders(data, "Referer:")) {
|
||||||
data->ptr_ref = aprintf("Referer: %s\015\012", data->referer);
|
if(conn->allocptr.ref)
|
||||||
|
free(conn->allocptr.ref);
|
||||||
|
conn->allocptr.ref = aprintf("Referer: %s\015\012", data->referer);
|
||||||
}
|
}
|
||||||
if(data->cookie && !checkheaders(data, "Cookie:")) {
|
if(data->cookie && !checkheaders(data, "Cookie:")) {
|
||||||
data->ptr_cookie = aprintf("Cookie: %s\015\012", data->cookie);
|
if(conn->allocptr.cookie)
|
||||||
|
free(conn->allocptr.cookie);
|
||||||
|
conn->allocptr.cookie = aprintf("Cookie: %s\015\012", data->cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->cookies) {
|
if(data->cookies) {
|
||||||
@@ -450,14 +462,19 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
|
http->sendit = Curl_getFormData(data->httppost, &http->postsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!checkheaders(data, "Host:")) {
|
if(!checkheaders(data, "Host:") &&
|
||||||
if(((conn->protocol&PROT_HTTPS) && (data->remote_port == PORT_HTTPS)) ||
|
!conn->allocptr.host) {
|
||||||
(!(conn->protocol&PROT_HTTPS) && (data->remote_port == PORT_HTTP)) )
|
/* if ptr_host is already set, it is OK since we only re-use connections
|
||||||
|
to the very same host and port */
|
||||||
|
|
||||||
|
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
|
||||||
|
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
|
||||||
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
|
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
|
||||||
the port number in the host string */
|
the port number in the host string */
|
||||||
data->ptr_host = aprintf("Host: %s\r\n", host);
|
conn->allocptr.host = aprintf("Host: %s\r\n", host);
|
||||||
else
|
else
|
||||||
data->ptr_host = aprintf("Host: %s:%d\r\n", host, data->remote_port);
|
conn->allocptr.host = aprintf("Host: %s:%d\r\n", host,
|
||||||
|
conn->remote_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!checkheaders(data, "Pragma:"))
|
if(!checkheaders(data, "Pragma:"))
|
||||||
@@ -531,7 +548,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
*/
|
*/
|
||||||
if((data->httpreq == HTTPREQ_GET) &&
|
if((data->httpreq == HTTPREQ_GET) &&
|
||||||
!checkheaders(data, "Range:")) {
|
!checkheaders(data, "Range:")) {
|
||||||
data->ptr_rangeline = aprintf("Range: bytes=%s\r\n", data->range);
|
conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", data->range);
|
||||||
}
|
}
|
||||||
else if((data->httpreq != HTTPREQ_GET) &&
|
else if((data->httpreq != HTTPREQ_GET) &&
|
||||||
!checkheaders(data, "Content-Range:")) {
|
!checkheaders(data, "Content-Range:")) {
|
||||||
@@ -539,14 +556,14 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
if(data->resume_from) {
|
if(data->resume_from) {
|
||||||
/* This is because "resume" was selected */
|
/* This is because "resume" was selected */
|
||||||
long total_expected_size= data->resume_from + data->infilesize;
|
long total_expected_size= data->resume_from + data->infilesize;
|
||||||
data->ptr_rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n",
|
conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n",
|
||||||
data->range, total_expected_size-1,
|
data->range, total_expected_size-1,
|
||||||
total_expected_size);
|
total_expected_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Range was selected and then we just pass the incoming range and
|
/* Range was selected and then we just pass the incoming range and
|
||||||
append total size */
|
append total size */
|
||||||
data->ptr_rangeline = aprintf("Content-Range: bytes %s/%d\r\n",
|
conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n",
|
||||||
data->range, data->infilesize);
|
data->range, data->infilesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +579,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
/* add the main request stuff */
|
/* add the main request stuff */
|
||||||
add_bufferf(req_buffer,
|
add_bufferf(req_buffer,
|
||||||
"%s " /* GET/HEAD/POST/PUT */
|
"%s " /* GET/HEAD/POST/PUT */
|
||||||
"%s HTTP/1.0\r\n" /* path */
|
"%s HTTP/1.1\r\n" /* path */
|
||||||
"%s" /* proxyuserpwd */
|
"%s" /* proxyuserpwd */
|
||||||
"%s" /* userpwd */
|
"%s" /* userpwd */
|
||||||
"%s" /* range */
|
"%s" /* range */
|
||||||
@@ -578,15 +595,15 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
(data->bits.http_post || data->bits.http_formpost)?"POST":
|
(data->bits.http_post || data->bits.http_formpost)?"POST":
|
||||||
(data->bits.http_put)?"PUT":"GET"),
|
(data->bits.http_put)?"PUT":"GET"),
|
||||||
ppath,
|
ppath,
|
||||||
(data->bits.proxy_user_passwd && data->ptr_proxyuserpwd)?data->ptr_proxyuserpwd:"",
|
(data->bits.proxy_user_passwd && conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"",
|
||||||
(data->bits.user_passwd && data->ptr_userpwd)?data->ptr_userpwd:"",
|
(data->bits.user_passwd && conn->allocptr.userpwd)?conn->allocptr.userpwd:"",
|
||||||
(data->bits.set_range && data->ptr_rangeline)?data->ptr_rangeline:"",
|
(data->bits.set_range && conn->allocptr.rangeline)?conn->allocptr.rangeline:"",
|
||||||
(data->useragent && *data->useragent && data->ptr_uagent)?data->ptr_uagent:"",
|
(data->useragent && *data->useragent && conn->allocptr.uagent)?conn->allocptr.uagent:"",
|
||||||
(data->ptr_cookie?data->ptr_cookie:""), /* Cookie: <data> */
|
(conn->allocptr.cookie?conn->allocptr.cookie:""), /* Cookie: <data> */
|
||||||
(data->ptr_host?data->ptr_host:""), /* Host: host */
|
(conn->allocptr.host?conn->allocptr.host:""), /* Host: host */
|
||||||
http->p_pragma?http->p_pragma:"",
|
http->p_pragma?http->p_pragma:"",
|
||||||
http->p_accept?http->p_accept:"",
|
http->p_accept?http->p_accept:"",
|
||||||
(data->bits.http_set_referer && data->ptr_ref)?data->ptr_ref:"" /* Referer: <data> <CRLF> */
|
(data->bits.http_set_referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: <data> <CRLF> */
|
||||||
);
|
);
|
||||||
|
|
||||||
if(co) {
|
if(co) {
|
||||||
@@ -690,10 +707,10 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
Curl_pgrsSetUploadSize(data, http->postsize);
|
Curl_pgrsSetUploadSize(data, http->postsize);
|
||||||
|
|
||||||
data->request_size =
|
data->request_size =
|
||||||
add_buffer_send(data->firstsocket, conn, req_buffer);
|
add_buffer_send(conn->firstsocket, conn, req_buffer);
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, TRUE,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
data->firstsocket,
|
conn->firstsocket,
|
||||||
&http->writebytecount);
|
&http->writebytecount);
|
||||||
if(result) {
|
if(result) {
|
||||||
Curl_FormFree(http->sendit); /* free that whole lot */
|
Curl_FormFree(http->sendit); /* free that whole lot */
|
||||||
@@ -716,12 +733,12 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
/* this sends the buffer and frees all the buffer resources */
|
/* this sends the buffer and frees all the buffer resources */
|
||||||
data->request_size =
|
data->request_size =
|
||||||
add_buffer_send(data->firstsocket, conn, req_buffer);
|
add_buffer_send(conn->firstsocket, conn, req_buffer);
|
||||||
|
|
||||||
/* prepare for transfer */
|
/* prepare for transfer */
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, TRUE,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
data->firstsocket,
|
conn->firstsocket,
|
||||||
&http->writebytecount);
|
&http->writebytecount);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
@@ -762,10 +779,10 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
/* issue the request */
|
/* issue the request */
|
||||||
data->request_size =
|
data->request_size =
|
||||||
add_buffer_send(data->firstsocket, conn, req_buffer);
|
add_buffer_send(conn->firstsocket, conn, req_buffer);
|
||||||
|
|
||||||
/* HTTP GET/HEAD download: */
|
/* HTTP GET/HEAD download: */
|
||||||
result = Curl_Transfer(conn, data->firstsocket, -1, TRUE, bytecount,
|
result = Curl_Transfer(conn, conn->firstsocket, -1, TRUE, bytecount,
|
||||||
-1, NULL); /* nothing to upload */
|
-1, NULL); /* nothing to upload */
|
||||||
}
|
}
|
||||||
if(result)
|
if(result)
|
||||||
|
14
lib/krb4.c
14
lib/krb4.c
@@ -290,7 +290,7 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||||||
size_t nread;
|
size_t nread;
|
||||||
int l = sizeof(local_addr);
|
int l = sizeof(local_addr);
|
||||||
|
|
||||||
if(getsockname(conn->data->firstsocket,
|
if(getsockname(conn->firstsocket,
|
||||||
(struct sockaddr *)LOCAL_ADDR, &l) < 0)
|
(struct sockaddr *)LOCAL_ADDR, &l) < 0)
|
||||||
perror("getsockname()");
|
perror("getsockname()");
|
||||||
|
|
||||||
@@ -339,9 +339,9 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||||||
return AUTH_CONTINUE;
|
return AUTH_CONTINUE;
|
||||||
}
|
}
|
||||||
/*ret = command("ADAT %s", p)*/
|
/*ret = command("ADAT %s", p)*/
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn, "ADAT %s", p);
|
Curl_ftpsendf(conn->firstsocket, conn, "ADAT %s", p);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket,
|
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||||
conn->data->buffer, conn, NULL);
|
conn->data->buffer, conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||||
@@ -409,10 +409,10 @@ void krb_kauth(struct connectdata *conn)
|
|||||||
|
|
||||||
save = set_command_prot(conn, prot_private);
|
save = set_command_prot(conn, prot_private);
|
||||||
/*ret = command("SITE KAUTH %s", name);***/
|
/*ret = command("SITE KAUTH %s", name);***/
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn,
|
Curl_ftpsendf(conn->firstsocket, conn,
|
||||||
"SITE KAUTH %s", conn->data->user);
|
"SITE KAUTH %s", conn->data->user);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket, conn->data->buffer,
|
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
|
||||||
conn, NULL);
|
conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/;
|
return /*CURLE_OPERATION_TIMEOUTED*/;
|
||||||
@@ -486,10 +486,10 @@ void krb_kauth(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
memset (tktcopy.dat, 0, tktcopy.length);
|
memset (tktcopy.dat, 0, tktcopy.length);
|
||||||
/*ret = command("SITE KAUTH %s %s", name, p);***/
|
/*ret = command("SITE KAUTH %s %s", name, p);***/
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn,
|
Curl_ftpsendf(conn->firstsocket, conn,
|
||||||
"SITE KAUTH %s %s", name, p);
|
"SITE KAUTH %s %s", name, p);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket, conn->data->buffer,
|
nread = Curl_GetFTPResponse(conn->firstsocket, conn->data->buffer,
|
||||||
conn, NULL);
|
conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/;
|
return /*CURLE_OPERATION_TIMEOUTED*/;
|
||||||
|
@@ -171,10 +171,10 @@ CURLcode Curl_ldap(struct connectdata *conn)
|
|||||||
DYNA_GET_FUNCTION(int (*)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long), ldap_entry2text);
|
DYNA_GET_FUNCTION(int (*)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long), ldap_entry2text);
|
||||||
DYNA_GET_FUNCTION(int (*)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long, char *, char *), ldap_entry2html);
|
DYNA_GET_FUNCTION(int (*)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long, char *, char *), ldap_entry2html);
|
||||||
|
|
||||||
server = ldap_open(data->hostname, data->port);
|
server = ldap_open(conn->hostname, conn->port);
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
failf(data, "LDAP: Cannot connect to %s:%d",
|
failf(data, "LDAP: Cannot connect to %s:%d",
|
||||||
data->hostname, data->port);
|
conn->hostname, conn->port);
|
||||||
status = CURLE_COULDNT_CONNECT;
|
status = CURLE_COULDNT_CONNECT;
|
||||||
} else {
|
} else {
|
||||||
rc = ldap_simple_bind_s(server, data->user, data->passwd);
|
rc = ldap_simple_bind_s(server, data->user, data->passwd);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
; Definition file for the DLL version of the LIBCURL library from curl
|
; Definition file for the DLL version of the LIBCURL library from curl
|
||||||
;
|
;
|
||||||
|
|
||||||
LIBRARY LIBCURL
|
LIBRARY CURL
|
||||||
|
|
||||||
DESCRIPTION 'curl libcurl - http://curl.haxx.se'
|
DESCRIPTION 'curl libcurl - http://curl.haxx.se'
|
||||||
|
|
||||||
@@ -32,11 +32,11 @@ EXPORTS
|
|||||||
curl_unescape @ 23 ;
|
curl_unescape @ 23 ;
|
||||||
curl_version @ 24 ;
|
curl_version @ 24 ;
|
||||||
curl_write @ 25 ;
|
curl_write @ 25 ;
|
||||||
maprintf @ 26 ;
|
curl_maprintf @ 26 ;
|
||||||
mfprintf @ 27 ;
|
curl_mfprintf @ 27 ;
|
||||||
mprintf @ 28 ;
|
curl_mprintf @ 28 ;
|
||||||
msprintf @ 29 ;
|
curl_msprintf @ 29 ;
|
||||||
msnprintf @ 30 ;
|
curl_msnprintf @ 30 ;
|
||||||
mvfprintf @ 31 ;
|
curl_mvfprintf @ 31 ;
|
||||||
strequal @ 32 ;
|
Curl_strequal @ 32 ;
|
||||||
strnequal @ 33 ;
|
Curl_strnequal @ 33 ;
|
||||||
|
@@ -72,7 +72,7 @@ void *curl_domalloc(size_t size, int line, char *source)
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *curl_dostrdup(char *str, int line, char *source)
|
char *curl_dostrdup(const char *str, int line, char *source)
|
||||||
{
|
{
|
||||||
char *mem;
|
char *mem;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
void *curl_domalloc(size_t size, int line, char *source);
|
void *curl_domalloc(size_t size, int line, char *source);
|
||||||
void *curl_dorealloc(void *ptr, size_t size, int line, char *source);
|
void *curl_dorealloc(void *ptr, size_t size, int line, char *source);
|
||||||
void curl_dofree(void *ptr, int line, char *source);
|
void curl_dofree(void *ptr, int line, char *source);
|
||||||
char *curl_dostrdup(char *str, int line, char *source);
|
char *curl_dostrdup(const char *str, int line, char *source);
|
||||||
void curl_memdebug(char *logname);
|
void curl_memdebug(char *logname);
|
||||||
|
|
||||||
/* file descriptor manipulators */
|
/* file descriptor manipulators */
|
||||||
|
@@ -482,10 +482,10 @@ sec_prot_internal(struct connectdata *conn, int level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(level){
|
if(level){
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn,
|
Curl_ftpsendf(conn->firstsocket, conn,
|
||||||
"PBSZ %u", s);
|
"PBSZ %u", s);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket,
|
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||||
conn->data->buffer, conn, NULL);
|
conn->data->buffer, conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||||
@@ -501,10 +501,10 @@ sec_prot_internal(struct connectdata *conn, int level)
|
|||||||
conn->buffer_size = s;
|
conn->buffer_size = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn,
|
Curl_ftpsendf(conn->firstsocket, conn,
|
||||||
"PROT %c", level["CSEP"]);
|
"PROT %c", level["CSEP"]);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket,
|
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||||
conn->data->buffer, conn, NULL);
|
conn->data->buffer, conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||||
@@ -610,10 +610,10 @@ sec_login(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
infof(data, "Trying %s...\n", (*m)->name);
|
infof(data, "Trying %s...\n", (*m)->name);
|
||||||
/*ret = command("AUTH %s", (*m)->name);***/
|
/*ret = command("AUTH %s", (*m)->name);***/
|
||||||
Curl_ftpsendf(conn->data->firstsocket, conn,
|
Curl_ftpsendf(conn->firstsocket, conn,
|
||||||
"AUTH %s", (*m)->name);
|
"AUTH %s", (*m)->name);
|
||||||
/* wait for feedback */
|
/* wait for feedback */
|
||||||
nread = Curl_GetFTPResponse(conn->data->firstsocket,
|
nread = Curl_GetFTPResponse(conn->firstsocket,
|
||||||
conn->data->buffer, conn, NULL);
|
conn->data->buffer, conn, NULL);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
return /*CURLE_OPERATION_TIMEOUTED*/-1;
|
||||||
|
89
lib/sendf.c
89
lib/sendf.c
@@ -50,6 +50,76 @@
|
|||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* returns last node in linked list */
|
||||||
|
static struct curl_slist *slist_get_last(struct curl_slist *list)
|
||||||
|
{
|
||||||
|
struct curl_slist *item;
|
||||||
|
|
||||||
|
/* if caller passed us a NULL, return now */
|
||||||
|
if (!list)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* loop through to find the last item */
|
||||||
|
item = list;
|
||||||
|
while (item->next) {
|
||||||
|
item = item->next;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* append a struct to the linked list. It always retunrs the address of the
|
||||||
|
* first record, so that you can sure this function as an initialization
|
||||||
|
* function as well as an append function. If you find this bothersome,
|
||||||
|
* then simply create a separate _init function and call it appropriately from
|
||||||
|
* within the proram. */
|
||||||
|
struct curl_slist *curl_slist_append(struct curl_slist *list,
|
||||||
|
const char *data)
|
||||||
|
{
|
||||||
|
struct curl_slist *last;
|
||||||
|
struct curl_slist *new_item;
|
||||||
|
|
||||||
|
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
|
||||||
|
if (new_item) {
|
||||||
|
new_item->next = NULL;
|
||||||
|
new_item->data = strdup(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "Cannot allocate memory for QUOTE list.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list) {
|
||||||
|
last = slist_get_last(list);
|
||||||
|
last->next = new_item;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if this is the first item, then new_item *is* the list */
|
||||||
|
return new_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* be nice and clean up resources */
|
||||||
|
void curl_slist_free_all(struct curl_slist *list)
|
||||||
|
{
|
||||||
|
struct curl_slist *next;
|
||||||
|
struct curl_slist *item;
|
||||||
|
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item = list;
|
||||||
|
do {
|
||||||
|
next = item->next;
|
||||||
|
|
||||||
|
if (item->data) {
|
||||||
|
free(item->data);
|
||||||
|
}
|
||||||
|
free(item);
|
||||||
|
item = next;
|
||||||
|
} while (next);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* infof() is for info message along the way */
|
/* infof() is for info message along the way */
|
||||||
|
|
||||||
void Curl_infof(struct UrlData *data, char *fmt, ...)
|
void Curl_infof(struct UrlData *data, char *fmt, ...)
|
||||||
@@ -72,8 +142,11 @@ void Curl_failf(struct UrlData *data, char *fmt, ...)
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if(data->errorbuffer)
|
if(data->errorbuffer)
|
||||||
vsnprintf(data->errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
vsnprintf(data->errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
||||||
else /* no errorbuffer receives this, write to data->err instead */
|
else {
|
||||||
|
/* no errorbuffer receives this, write to data->err instead */
|
||||||
vfprintf(data->err, fmt, ap);
|
vfprintf(data->err, fmt, ap);
|
||||||
|
fprintf(data->err, "\n");
|
||||||
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,15 +184,14 @@ CURLcode Curl_write(struct connectdata *conn, int sockfd,
|
|||||||
size_t *written)
|
size_t *written)
|
||||||
{
|
{
|
||||||
size_t bytes_written;
|
size_t bytes_written;
|
||||||
struct UrlData *data=conn->data; /* conn knows data, not vice versa */
|
|
||||||
|
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
if (data->ssl.use) {
|
if (conn->ssl.use) {
|
||||||
int loop=100; /* just a precaution to never loop endlessly */
|
int loop=100; /* just a precaution to never loop endlessly */
|
||||||
while(loop--) {
|
while(loop--) {
|
||||||
bytes_written = SSL_write(data->ssl.handle, mem, len);
|
bytes_written = SSL_write(conn->ssl.handle, mem, len);
|
||||||
if((-1 != bytes_written) ||
|
if((-1 != bytes_written) ||
|
||||||
(SSL_ERROR_WANT_WRITE != SSL_get_error(data->ssl.handle,
|
(SSL_ERROR_WANT_WRITE != SSL_get_error(conn->ssl.handle,
|
||||||
bytes_written) ))
|
bytes_written) ))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -200,16 +272,15 @@ CURLcode Curl_read(struct connectdata *conn, int sockfd,
|
|||||||
char *buf, size_t buffersize,
|
char *buf, size_t buffersize,
|
||||||
ssize_t *n)
|
ssize_t *n)
|
||||||
{
|
{
|
||||||
struct UrlData *data = conn->data;
|
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
if (data->ssl.use) {
|
if (conn->ssl.use) {
|
||||||
int loop=100; /* just a precaution to never loop endlessly */
|
int loop=100; /* just a precaution to never loop endlessly */
|
||||||
while(loop--) {
|
while(loop--) {
|
||||||
nread = SSL_read(data->ssl.handle, buf, buffersize);
|
nread = SSL_read(conn->ssl.handle, buf, buffersize);
|
||||||
if((-1 != nread) ||
|
if((-1 != nread) ||
|
||||||
(SSL_ERROR_WANT_READ != SSL_get_error(data->ssl.handle, nread) ))
|
(SSL_ERROR_WANT_READ != SSL_get_error(conn->ssl.handle, nread) ))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
212
lib/ssluse.c
212
lib/ssluse.c
@@ -64,6 +64,7 @@ static int passwd_callback(char *buf, int num, int verify
|
|||||||
|
|
||||||
static
|
static
|
||||||
int cert_stuff(struct UrlData *data,
|
int cert_stuff(struct UrlData *data,
|
||||||
|
struct connectdata *conn,
|
||||||
char *cert_file,
|
char *cert_file,
|
||||||
char *key_file)
|
char *key_file)
|
||||||
{
|
{
|
||||||
@@ -78,10 +79,10 @@ int cert_stuff(struct UrlData *data,
|
|||||||
*/
|
*/
|
||||||
strcpy(global_passwd, data->cert_passwd);
|
strcpy(global_passwd, data->cert_passwd);
|
||||||
/* Set passwd callback: */
|
/* Set passwd callback: */
|
||||||
SSL_CTX_set_default_passwd_cb(data->ssl.ctx, passwd_callback);
|
SSL_CTX_set_default_passwd_cb(conn->ssl.ctx, passwd_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SSL_CTX_use_certificate_file(data->ssl.ctx,
|
if (SSL_CTX_use_certificate_file(conn->ssl.ctx,
|
||||||
cert_file,
|
cert_file,
|
||||||
SSL_FILETYPE_PEM) <= 0) {
|
SSL_FILETYPE_PEM) <= 0) {
|
||||||
failf(data, "unable to set certificate file (wrong password?)\n");
|
failf(data, "unable to set certificate file (wrong password?)\n");
|
||||||
@@ -90,14 +91,14 @@ int cert_stuff(struct UrlData *data,
|
|||||||
if (key_file == NULL)
|
if (key_file == NULL)
|
||||||
key_file=cert_file;
|
key_file=cert_file;
|
||||||
|
|
||||||
if (SSL_CTX_use_PrivateKey_file(data->ssl.ctx,
|
if (SSL_CTX_use_PrivateKey_file(conn->ssl.ctx,
|
||||||
key_file,
|
key_file,
|
||||||
SSL_FILETYPE_PEM) <= 0) {
|
SSL_FILETYPE_PEM) <= 0) {
|
||||||
failf(data, "unable to set public key file\n");
|
failf(data, "unable to set public key file\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl=SSL_new(data->ssl.ctx);
|
ssl=SSL_new(conn->ssl.ctx);
|
||||||
x509=SSL_get_certificate(ssl);
|
x509=SSL_get_certificate(ssl);
|
||||||
|
|
||||||
if (x509 != NULL)
|
if (x509 != NULL)
|
||||||
@@ -111,7 +112,7 @@ int cert_stuff(struct UrlData *data,
|
|||||||
|
|
||||||
/* Now we know that a key and cert have been set against
|
/* Now we know that a key and cert have been set against
|
||||||
* the SSL context */
|
* the SSL context */
|
||||||
if (!SSL_CTX_check_private_key(data->ssl.ctx)) {
|
if (!SSL_CTX_check_private_key(conn->ssl.ctx)) {
|
||||||
failf(data, "Private key does not match the certificate public key\n");
|
failf(data, "Private key does not match the certificate public key\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -141,22 +142,23 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
|
|||||||
|
|
||||||
/* ====================================================== */
|
/* ====================================================== */
|
||||||
int
|
int
|
||||||
Curl_SSLConnect (struct UrlData *data)
|
Curl_SSLConnect(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
int err;
|
struct UrlData *data = conn->data;
|
||||||
char * str;
|
int err;
|
||||||
SSL_METHOD *req_method;
|
char * str;
|
||||||
|
SSL_METHOD *req_method;
|
||||||
|
|
||||||
/* mark this is being ssl enabled from here on out. */
|
/* mark this is being ssl enabled from here on out. */
|
||||||
data->ssl.use = TRUE;
|
conn->ssl.use = TRUE;
|
||||||
|
|
||||||
/* Lets get nice error messages */
|
/* Lets get nice error messages */
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
|
|
||||||
#ifdef HAVE_RAND_STATUS
|
#ifdef HAVE_RAND_STATUS
|
||||||
/* RAND_status() was introduced in OpenSSL 0.9.5 */
|
/* RAND_status() was introduced in OpenSSL 0.9.5 */
|
||||||
if(0 == RAND_status())
|
if(0 == RAND_status())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* We need to seed the PRNG properly! */
|
/* We need to seed the PRNG properly! */
|
||||||
@@ -177,116 +179,116 @@ Curl_SSLConnect (struct UrlData *data)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup all the global SSL stuff */
|
/* Setup all the global SSL stuff */
|
||||||
SSLeay_add_ssl_algorithms();
|
SSLeay_add_ssl_algorithms();
|
||||||
|
|
||||||
switch(data->ssl.version) {
|
switch(data->ssl.version) {
|
||||||
default:
|
default:
|
||||||
req_method = SSLv23_client_method();
|
req_method = SSLv23_client_method();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
req_method = SSLv2_client_method();
|
req_method = SSLv2_client_method();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
req_method = SSLv3_client_method();
|
req_method = SSLv3_client_method();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ssl.ctx = SSL_CTX_new(req_method);
|
conn->ssl.ctx = SSL_CTX_new(req_method);
|
||||||
|
|
||||||
if(!data->ssl.ctx) {
|
if(!conn->ssl.ctx) {
|
||||||
failf(data, "SSL: couldn't create a context!");
|
failf(data, "SSL: couldn't create a context!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->cert) {
|
if(data->cert) {
|
||||||
if (!cert_stuff(data, data->cert, data->cert)) {
|
if (!cert_stuff(data, conn, data->cert, data->cert)) {
|
||||||
failf(data, "couldn't use certificate!\n");
|
failf(data, "couldn't use certificate!\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(data->ssl.verifypeer){
|
if(data->ssl.verifypeer){
|
||||||
SSL_CTX_set_verify(data->ssl.ctx,
|
SSL_CTX_set_verify(conn->ssl.ctx,
|
||||||
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT|
|
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT|
|
||||||
SSL_VERIFY_CLIENT_ONCE,
|
SSL_VERIFY_CLIENT_ONCE,
|
||||||
cert_verify_callback);
|
cert_verify_callback);
|
||||||
if (!SSL_CTX_load_verify_locations(data->ssl.ctx,
|
if (!SSL_CTX_load_verify_locations(conn->ssl.ctx,
|
||||||
data->ssl.CAfile,
|
data->ssl.CAfile,
|
||||||
data->ssl.CApath)) {
|
data->ssl.CApath)) {
|
||||||
failf(data,"error setting cerficate verify locations\n");
|
failf(data,"error setting cerficate verify locations\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
SSL_CTX_set_verify(data->ssl.ctx, SSL_VERIFY_NONE, cert_verify_callback);
|
else
|
||||||
|
SSL_CTX_set_verify(conn->ssl.ctx, SSL_VERIFY_NONE, cert_verify_callback);
|
||||||
|
|
||||||
|
|
||||||
/* Lets make an SSL structure */
|
/* Lets make an SSL structure */
|
||||||
data->ssl.handle = SSL_new (data->ssl.ctx);
|
conn->ssl.handle = SSL_new (conn->ssl.ctx);
|
||||||
SSL_set_connect_state (data->ssl.handle);
|
SSL_set_connect_state (conn->ssl.handle);
|
||||||
|
|
||||||
data->ssl.server_cert = 0x0;
|
conn->ssl.server_cert = 0x0;
|
||||||
|
|
||||||
/* pass the raw socket into the SSL layers */
|
/* pass the raw socket into the SSL layers */
|
||||||
SSL_set_fd (data->ssl.handle, data->firstsocket);
|
SSL_set_fd (conn->ssl.handle, conn->firstsocket);
|
||||||
err = SSL_connect (data->ssl.handle);
|
err = SSL_connect (conn->ssl.handle);
|
||||||
|
|
||||||
if (-1 == err) {
|
if (-1 == err) {
|
||||||
err = ERR_get_error();
|
err = ERR_get_error();
|
||||||
failf(data, "SSL: %s", ERR_error_string(err, NULL));
|
failf(data, "SSL: %s", ERR_error_string(err, NULL));
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Informational message */
|
/* Informational message */
|
||||||
infof (data, "SSL connection using %s\n",
|
infof (data, "SSL connection using %s\n",
|
||||||
SSL_get_cipher(data->ssl.handle));
|
SSL_get_cipher(conn->ssl.handle));
|
||||||
|
|
||||||
/* Get server's certificate (note: beware of dynamic allocation) - opt */
|
/* Get server's certificate (note: beware of dynamic allocation) - opt */
|
||||||
/* major serious hack alert -- we should check certificates
|
/* major serious hack alert -- we should check certificates
|
||||||
* to authenticate the server; otherwise we risk man-in-the-middle
|
* to authenticate the server; otherwise we risk man-in-the-middle
|
||||||
* attack
|
* attack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
data->ssl.server_cert = SSL_get_peer_certificate (data->ssl.handle);
|
conn->ssl.server_cert = SSL_get_peer_certificate (conn->ssl.handle);
|
||||||
if(!data->ssl.server_cert) {
|
if(!conn->ssl.server_cert) {
|
||||||
failf(data, "SSL: couldn't get peer certificate!");
|
failf(data, "SSL: couldn't get peer certificate!");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
infof (data, "Server certificate:\n");
|
infof (data, "Server certificate:\n");
|
||||||
|
|
||||||
str = X509_NAME_oneline (X509_get_subject_name (data->ssl.server_cert),
|
str = X509_NAME_oneline (X509_get_subject_name (conn->ssl.server_cert),
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
if(!str) {
|
if(!str) {
|
||||||
failf(data, "SSL: couldn't get X509-subject!");
|
failf(data, "SSL: couldn't get X509-subject!");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
infof(data, "\t subject: %s\n", str);
|
infof(data, "\t subject: %s\n", str);
|
||||||
CRYPTO_free(str);
|
CRYPTO_free(str);
|
||||||
|
|
||||||
str = X509_NAME_oneline (X509_get_issuer_name (data->ssl.server_cert),
|
str = X509_NAME_oneline (X509_get_issuer_name (conn->ssl.server_cert),
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
if(!str) {
|
if(!str) {
|
||||||
failf(data, "SSL: couldn't get X509-issuer name!");
|
failf(data, "SSL: couldn't get X509-issuer name!");
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
infof(data, "\t issuer: %s\n", str);
|
infof(data, "\t issuer: %s\n", str);
|
||||||
CRYPTO_free(str);
|
CRYPTO_free(str);
|
||||||
|
|
||||||
/* We could do all sorts of certificate verification stuff here before
|
/* We could do all sorts of certificate verification stuff here before
|
||||||
deallocating the certificate. */
|
deallocating the certificate. */
|
||||||
|
|
||||||
if(data->ssl.verifypeer) {
|
if(data->ssl.verifypeer) {
|
||||||
data->ssl.certverifyresult=SSL_get_verify_result(data->ssl.handle);
|
data->ssl.certverifyresult=SSL_get_verify_result(conn->ssl.handle);
|
||||||
infof(data, "Verify result: %d\n", data->ssl.certverifyresult);
|
infof(data, "Verify result: %d\n", data->ssl.certverifyresult);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data->ssl.certverifyresult=0;
|
data->ssl.certverifyresult=0;
|
||||||
|
|
||||||
X509_free(data->ssl.server_cert);
|
X509_free(conn->ssl.server_cert);
|
||||||
#else /* USE_SSLEAY */
|
#else /* USE_SSLEAY */
|
||||||
/* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */
|
/* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */
|
||||||
(void) data;
|
(void) data;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -22,5 +22,6 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int Curl_SSLConnect (struct UrlData *data);
|
#include "urldata.h"
|
||||||
|
int Curl_SSLConnect(struct connectdata *conn);
|
||||||
#endif
|
#endif
|
||||||
|
1125
lib/telnet.c
1125
lib/telnet.c
File diff suppressed because it is too large
Load Diff
@@ -127,6 +127,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
int offset = 0; /* possible resume offset read from the
|
int offset = 0; /* possible resume offset read from the
|
||||||
Content-Range: header */
|
Content-Range: header */
|
||||||
int code = 0; /* error code from the 'HTTP/1.? XXX' line */
|
int code = 0; /* error code from the 'HTTP/1.? XXX' line */
|
||||||
|
int httpversion = -1; /* the last digit in the HTTP/1.1 string */
|
||||||
|
|
||||||
/* for the low speed checks: */
|
/* for the low speed checks: */
|
||||||
CURLcode urg;
|
CURLcode urg;
|
||||||
@@ -319,9 +320,9 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
p++; /* pass the \r byte */
|
p++; /* pass the \r byte */
|
||||||
if ('\n' == *p)
|
if ('\n' == *p)
|
||||||
p++; /* pass the \n byte */
|
p++; /* pass the \n byte */
|
||||||
|
#if 0 /* headers are not included in the size */
|
||||||
Curl_pgrsSetDownloadSize(data, conn->size);
|
Curl_pgrsSetDownloadSize(data, conn->size);
|
||||||
|
#endif
|
||||||
header = FALSE; /* no more header to parse! */
|
header = FALSE; /* no more header to parse! */
|
||||||
|
|
||||||
/* now, only output this if the header AND body are requested:
|
/* now, only output this if the header AND body are requested:
|
||||||
@@ -342,7 +343,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
if (!headerline++) {
|
if (!headerline++) {
|
||||||
/* This is the first header, it MUST be the error code line
|
/* This is the first header, it MUST be the error code line
|
||||||
or else we consiser this to be the body right away! */
|
or else we consiser this to be the body right away! */
|
||||||
if (sscanf (p, " HTTP/1.%*c %3d", &code)) {
|
if (2 == sscanf (p, " HTTP/1.%d %3d", &httpversion, &code)) {
|
||||||
/* 404 -> URL not found! */
|
/* 404 -> URL not found! */
|
||||||
if (
|
if (
|
||||||
( ((data->bits.http_follow_location) && (code >= 400))
|
( ((data->bits.http_follow_location) && (code >= 400))
|
||||||
@@ -366,6 +367,16 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
if (strnequal("Content-Length", p, 14) &&
|
if (strnequal("Content-Length", p, 14) &&
|
||||||
sscanf (p+14, ": %ld", &contentlength))
|
sscanf (p+14, ": %ld", &contentlength))
|
||||||
conn->size = contentlength;
|
conn->size = contentlength;
|
||||||
|
else if (strnequal("Connection: close", p,
|
||||||
|
strlen("Connection: close"))) {
|
||||||
|
/*
|
||||||
|
* [RFC 2616, section 8.1.2.1]
|
||||||
|
* "Connection: close" is HTTP/1.1 language and means that
|
||||||
|
* the connection will close when this request has been
|
||||||
|
* served.
|
||||||
|
*/
|
||||||
|
conn->bits.close = TRUE; /* close when done */
|
||||||
|
}
|
||||||
else if (strnequal("Content-Range", p, 13)) {
|
else if (strnequal("Content-Range", p, 13)) {
|
||||||
if (sscanf (p+13, ": bytes %d-", &offset) ||
|
if (sscanf (p+13, ": bytes %d-", &offset) ||
|
||||||
sscanf (p+13, ": bytes: %d-", &offset)) {
|
sscanf (p+13, ": bytes: %d-", &offset)) {
|
||||||
@@ -489,13 +500,23 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
} /* switch */
|
} /* switch */
|
||||||
} /* two valid time strings */
|
} /* two valid time strings */
|
||||||
} /* we have a time condition */
|
} /* we have a time condition */
|
||||||
|
if(!conn->bits.close && (httpversion == 1)) {
|
||||||
|
/* If this is not the last request before a close, we must
|
||||||
|
set the maximum download size to the size of the expected
|
||||||
|
document or else, we won't know when to stop reading! */
|
||||||
|
if(-1 != conn->size)
|
||||||
|
conn->maxdownload = conn->size;
|
||||||
|
|
||||||
|
/* What to do if the size is *not* known? */
|
||||||
|
}
|
||||||
|
|
||||||
} /* this is HTTP */
|
} /* this is HTTP */
|
||||||
} /* this is the first time we write a body part */
|
} /* this is the first time we write a body part */
|
||||||
bodywrites++;
|
bodywrites++;
|
||||||
|
|
||||||
if(data->maxdownload &&
|
if(conn->maxdownload &&
|
||||||
(bytecount + nread > data->maxdownload)) {
|
(bytecount + nread >= conn->maxdownload)) {
|
||||||
nread = data->maxdownload - bytecount;
|
nread = conn->maxdownload - bytecount;
|
||||||
if((signed int)nread < 0 ) /* this should be unusual */
|
if((signed int)nread < 0 ) /* this should be unusual */
|
||||||
nread = 0;
|
nread = 0;
|
||||||
keepon &= ~KEEP_READ; /* we're done reading */
|
keepon &= ~KEEP_READ; /* we're done reading */
|
||||||
@@ -611,12 +632,13 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
CURLcode res;
|
CURLcode res;
|
||||||
struct UrlData *data = curl;
|
struct UrlData *data = curl;
|
||||||
struct connectdata *c_connect=NULL;
|
struct connectdata *c_connect=NULL;
|
||||||
|
bool port=TRUE; /* allow data->use_port to set port to use */
|
||||||
|
|
||||||
Curl_pgrsStartNow(data);
|
Curl_pgrsStartNow(data);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Curl_pgrsTime(data, TIMER_STARTSINGLE);
|
Curl_pgrsTime(data, TIMER_STARTSINGLE);
|
||||||
res = curl_connect(curl, (CURLconnect **)&c_connect);
|
res = curl_connect(curl, (CURLconnect **)&c_connect, port);
|
||||||
if(res == CURLE_OK) {
|
if(res == CURLE_OK) {
|
||||||
res = curl_do(c_connect);
|
res = curl_do(c_connect);
|
||||||
if(res == CURLE_OK) {
|
if(res == CURLE_OK) {
|
||||||
@@ -633,9 +655,14 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
char prot[16]; /* URL protocol string storage */
|
char prot[16]; /* URL protocol string storage */
|
||||||
char letter; /* used for a silly sscanf */
|
char letter; /* used for a silly sscanf */
|
||||||
|
|
||||||
|
port=TRUE; /* by default we use the user set port number even after
|
||||||
|
a Location: */
|
||||||
|
|
||||||
if (data->maxredirs && (data->followlocation >= data->maxredirs)) {
|
if (data->maxredirs && (data->followlocation >= data->maxredirs)) {
|
||||||
failf(data,"Maximum (%d) redirects followed", data->maxredirs);
|
failf(data,"Maximum (%d) redirects followed", data->maxredirs);
|
||||||
|
#ifdef USE_OLD_DISCONNECT
|
||||||
curl_disconnect(c_connect);
|
curl_disconnect(c_connect);
|
||||||
|
#endif
|
||||||
res=CURLE_TOO_MANY_REDIRECTS;
|
res=CURLE_TOO_MANY_REDIRECTS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -678,9 +705,10 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
if(!protsep)
|
if(!protsep)
|
||||||
protsep=data->url;
|
protsep=data->url;
|
||||||
else {
|
else {
|
||||||
/* TBD: set the port with curl_setopt() */
|
port=FALSE; /* we got a full URL and thus we should not obey the
|
||||||
data->port=0; /* we got a full URL and then we should reset the
|
port number that might have been set by the user
|
||||||
port number here to re-initiate it later */
|
in data->use_port */
|
||||||
|
|
||||||
protsep+=2; /* pass the slashes */
|
protsep+=2; /* pass the slashes */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,9 +745,8 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
data->newurl = newest;
|
data->newurl = newest;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* This was an absolute URL, clear the port number! */
|
/* This is an absolute URL, don't use the custom port number */
|
||||||
/* TBD: set the port with curl_setopt() */
|
port = FALSE;
|
||||||
data->port = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->bits.urlstringalloc)
|
if(data->bits.urlstringalloc)
|
||||||
@@ -772,11 +799,15 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_OLD_DISCONNECT
|
||||||
curl_disconnect(c_connect);
|
curl_disconnect(c_connect);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_OLD_DISCONNECT
|
||||||
curl_disconnect(c_connect);
|
curl_disconnect(c_connect);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break; /* it only reaches here when this shouldn't loop */
|
break; /* it only reaches here when this shouldn't loop */
|
||||||
|
|
||||||
|
413
lib/urldata.h
413
lib/urldata.h
@@ -133,6 +133,64 @@ enum protection_level {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* struct for data related to SSL and SSL connections */
|
||||||
|
struct ssl_connect_data {
|
||||||
|
bool use; /* use ssl encrypted communications TRUE/FALSE */
|
||||||
|
#ifdef USE_SSLEAY
|
||||||
|
/* these ones requires specific SSL-types */
|
||||||
|
SSL_CTX* ctx;
|
||||||
|
SSL* handle;
|
||||||
|
X509* server_cert;
|
||||||
|
#endif /* USE_SSLEAY */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ssl_config_data {
|
||||||
|
long version; /* what version the client wants to use */
|
||||||
|
long certverifyresult; /* result from the certificate verification */
|
||||||
|
long verifypeer; /* set TRUE if this is desired */
|
||||||
|
char *CApath; /* DOES NOT WORK ON WINDOWS */
|
||||||
|
char *CAfile; /* cerficate to verify peer against */
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* HTTP unique setup
|
||||||
|
***************************************************************************/
|
||||||
|
struct HTTP {
|
||||||
|
struct FormData *sendit;
|
||||||
|
int postsize;
|
||||||
|
char *p_pragma; /* Pragma: string */
|
||||||
|
char *p_accept; /* Accept: string */
|
||||||
|
long readbytecount;
|
||||||
|
long writebytecount;
|
||||||
|
|
||||||
|
/* For FORM posting */
|
||||||
|
struct Form form;
|
||||||
|
size_t (*storefread)(char *, size_t , size_t , FILE *);
|
||||||
|
FILE *in;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* FTP unique setup
|
||||||
|
***************************************************************************/
|
||||||
|
struct FTP {
|
||||||
|
long *bytecountp;
|
||||||
|
char *user; /* user name string */
|
||||||
|
char *passwd; /* password string */
|
||||||
|
char *urlpath; /* the originally given path part of the URL */
|
||||||
|
char *dir; /* decoded directory */
|
||||||
|
char *file; /* decoded file */
|
||||||
|
|
||||||
|
char *entrypath; /* the PWD reply when we logged on */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boolean values that concerns this connection.
|
||||||
|
*/
|
||||||
|
struct ConnectBits {
|
||||||
|
bool close; /* if set, we close the connection after this request */
|
||||||
|
bool reuse; /* if set, this is a re-used connection */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The connectdata struct contains all fields and variables that should be
|
* The connectdata struct contains all fields and variables that should be
|
||||||
* unique for an entire connection.
|
* unique for an entire connection.
|
||||||
@@ -145,6 +203,9 @@ struct connectdata {
|
|||||||
Handle handle; /* struct identifier */
|
Handle handle; /* struct identifier */
|
||||||
struct UrlData *data; /* link to the root CURL struct */
|
struct UrlData *data; /* link to the root CURL struct */
|
||||||
|
|
||||||
|
int connectindex; /* what index in the connects index this particular
|
||||||
|
struct has */
|
||||||
|
|
||||||
/**** curl_connect() phase fields */
|
/**** curl_connect() phase fields */
|
||||||
ConnState state; /* for state dependent actions */
|
ConnState state; /* for state dependent actions */
|
||||||
|
|
||||||
@@ -160,23 +221,37 @@ struct connectdata {
|
|||||||
#define PROT_FILE (1<<8)
|
#define PROT_FILE (1<<8)
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
struct addrinfo *res;
|
struct addrinfo *hp; /* host info pointer list */
|
||||||
|
struct addrinfo *ai; /* the particular host we use */
|
||||||
#else
|
#else
|
||||||
char *hostent_buf; /* pointer to allocated memory for name info */
|
char *hostent_buf; /* pointer to allocated memory for name info */
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
#endif
|
#endif
|
||||||
char proto[64]; /* store the protocol string in this buffer */
|
char protostr[64]; /* store the protocol string in this buffer */
|
||||||
char gname[257]; /* store the hostname in this buffer */
|
char gname[257]; /* store the hostname in this buffer */
|
||||||
char *name; /* host name pointer to fool around with */
|
char *name; /* host name pointer to fool around with */
|
||||||
char *path; /* allocated buffer to store the URL's path part in */
|
char *path; /* allocated buffer to store the URL's path part in */
|
||||||
|
char *hostname; /* hostname to connect, as parsed from url */
|
||||||
|
long port; /* which port to use locally */
|
||||||
|
unsigned short remote_port; /* what remote port to connect to,
|
||||||
|
not the proxy port! */
|
||||||
char *ppath;
|
char *ppath;
|
||||||
long bytecount;
|
long bytecount;
|
||||||
struct timeval now; /* current time */
|
struct timeval now; /* current time */
|
||||||
|
int firstsocket; /* the main socket to use */
|
||||||
|
int secondarysocket; /* for i.e ftp transfers */
|
||||||
|
|
||||||
long upload_bufsize; /* adjust as you see fit, never bigger than BUFSIZE
|
long upload_bufsize; /* adjust as you see fit, never bigger than BUFSIZE
|
||||||
never smaller than UPLOAD_BUFSIZE */
|
never smaller than UPLOAD_BUFSIZE */
|
||||||
|
|
||||||
|
long maxdownload; /* in bytes, the maximum amount of data to fetch, 0
|
||||||
|
means unlimited */
|
||||||
|
|
||||||
|
struct ssl_connect_data ssl; /* this is for ssl-stuff */
|
||||||
|
|
||||||
|
struct ConnectBits bits; /* various state-flags for this connection */
|
||||||
|
|
||||||
/* These two functions MUST be set by the curl_connect() function to be
|
/* These two functions MUST be set by the curl_connect() function to be
|
||||||
be protocol dependent */
|
be protocol dependent */
|
||||||
CURLcode (*curl_do)(struct connectdata *connect);
|
CURLcode (*curl_do)(struct connectdata *connect);
|
||||||
@@ -187,6 +262,11 @@ struct connectdata {
|
|||||||
*/
|
*/
|
||||||
CURLcode (*curl_connect)(struct connectdata *connect);
|
CURLcode (*curl_connect)(struct connectdata *connect);
|
||||||
|
|
||||||
|
/* This function *MAY* be set to a protocol-dependent function that is run
|
||||||
|
* by the curl_disconnect(), as a step in the disconnection.
|
||||||
|
*/
|
||||||
|
CURLcode (*curl_disconnect)(struct connectdata *connect);
|
||||||
|
|
||||||
/* This function *MAY* be set to a protocol-dependent function that is run
|
/* This function *MAY* be set to a protocol-dependent function that is run
|
||||||
* in the curl_close() function if protocol-specific cleanups are required.
|
* in the curl_close() function if protocol-specific cleanups are required.
|
||||||
*/
|
*/
|
||||||
@@ -205,6 +285,18 @@ struct connectdata {
|
|||||||
the same we read from. -1 disables */
|
the same we read from. -1 disables */
|
||||||
long *writebytecountp; /* return number of bytes written or NULL */
|
long *writebytecountp; /* return number of bytes written or NULL */
|
||||||
|
|
||||||
|
/** Dynamicly allocated strings, may need to be freed before this **/
|
||||||
|
/** struct is killed. **/
|
||||||
|
struct dynamically_allocated_data {
|
||||||
|
char *proxyuserpwd; /* free later if not NULL! */
|
||||||
|
char *uagent; /* free later if not NULL! */
|
||||||
|
char *userpwd; /* free later if not NULL! */
|
||||||
|
char *rangeline; /* free later if not NULL! */
|
||||||
|
char *ref; /* free later if not NULL! */
|
||||||
|
char *cookie; /* free later if not NULL! */
|
||||||
|
char *host; /* free later if not NULL */
|
||||||
|
} allocptr;
|
||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
|
|
||||||
enum protection_level command_prot;
|
enum protection_level command_prot;
|
||||||
@@ -218,6 +310,24 @@ struct connectdata {
|
|||||||
void *app_data;
|
void *app_data;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*************** Request - specific items ************/
|
||||||
|
/* previously this was in the urldata struct */
|
||||||
|
union {
|
||||||
|
struct HTTP *http;
|
||||||
|
struct HTTP *gopher; /* alias, just for the sake of being more readable */
|
||||||
|
struct HTTP *https; /* alias, just for the sake of being more readable */
|
||||||
|
struct FTP *ftp;
|
||||||
|
#if 0 /* no need for special ones for these: */
|
||||||
|
struct TELNET *telnet;
|
||||||
|
struct FILE *file;
|
||||||
|
struct LDAP *ldap;
|
||||||
|
struct DICT *dict;
|
||||||
|
#endif
|
||||||
|
void *generic;
|
||||||
|
} proto;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Progress {
|
struct Progress {
|
||||||
@@ -253,35 +363,6 @@ struct Progress {
|
|||||||
int speeder_c;
|
int speeder_c;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* HTTP unique setup
|
|
||||||
***************************************************************************/
|
|
||||||
struct HTTP {
|
|
||||||
struct FormData *sendit;
|
|
||||||
int postsize;
|
|
||||||
char *p_pragma; /* Pragma: string */
|
|
||||||
char *p_accept; /* Accept: string */
|
|
||||||
long readbytecount;
|
|
||||||
long writebytecount;
|
|
||||||
|
|
||||||
/* For FORM posting */
|
|
||||||
struct Form form;
|
|
||||||
size_t (*storefread)(char *, size_t , size_t , FILE *);
|
|
||||||
FILE *in;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* FTP unique setup
|
|
||||||
***************************************************************************/
|
|
||||||
struct FTP {
|
|
||||||
long *bytecountp;
|
|
||||||
char *user; /* user name string */
|
|
||||||
char *passwd; /* password string */
|
|
||||||
char *urlpath; /* the originally given path part of the URL */
|
|
||||||
char *dir; /* decoded directory */
|
|
||||||
char *file; /* decoded file */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HTTPREQ_NONE, /* first in list */
|
HTTPREQ_NONE, /* first in list */
|
||||||
HTTPREQ_GET,
|
HTTPREQ_GET,
|
||||||
@@ -338,22 +419,6 @@ typedef enum {
|
|||||||
CURLI_LAST
|
CURLI_LAST
|
||||||
} CurlInterface;
|
} CurlInterface;
|
||||||
|
|
||||||
/* struct for data related to SSL and SSL connections */
|
|
||||||
struct ssldata {
|
|
||||||
bool use; /* use ssl encrypted communications TRUE/FALSE */
|
|
||||||
long version; /* what version the client wants to use */
|
|
||||||
long certverifyresult; /* result from the certificate verification */
|
|
||||||
long verifypeer; /* set TRUE if this is desired */
|
|
||||||
char *CApath; /* DOES NOT WORK ON WINDOWS */
|
|
||||||
char *CAfile; /* cerficate to verify peer against */
|
|
||||||
#ifdef USE_SSLEAY
|
|
||||||
/* these ones requires specific SSL-types */
|
|
||||||
SSL_CTX* ctx;
|
|
||||||
SSL* handle;
|
|
||||||
X509* server_cert;
|
|
||||||
#endif /* USE_SSLEAY */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As of April 11, 2000 we're now trying to split up the urldata struct in
|
* As of April 11, 2000 we're now trying to split up the urldata struct in
|
||||||
* three different parts:
|
* three different parts:
|
||||||
@@ -368,8 +433,15 @@ struct ssldata {
|
|||||||
*
|
*
|
||||||
* (Request)
|
* (Request)
|
||||||
* 3 - Request-specific. Variables that are of interest for this particular
|
* 3 - Request-specific. Variables that are of interest for this particular
|
||||||
* transfer being made right now.
|
* transfer being made right now. THIS IS WRONG STRUCT FOR THOSE.
|
||||||
*
|
*
|
||||||
|
* In Febrary 2001, this is being done stricter. The 'connectdata' struct
|
||||||
|
* MUST have all the connection oriented stuff as we may now have several
|
||||||
|
* simultaneous connections and connection structs in memory.
|
||||||
|
*
|
||||||
|
* From now on, the 'UrlData' must only contain data that is set once to go
|
||||||
|
* for many (perhaps) independent connections. Values that are generated or
|
||||||
|
* calculated internally MUST NOT be a part of this struct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct UrlData {
|
struct UrlData {
|
||||||
@@ -381,7 +453,7 @@ struct UrlData {
|
|||||||
char *errorbuffer; /* store failure messages in here */
|
char *errorbuffer; /* store failure messages in here */
|
||||||
|
|
||||||
/*************** Session - specific items ************/
|
/*************** Session - specific items ************/
|
||||||
char *proxy; /* if proxy, set it here, set CONF_PROXY to use this */
|
char *proxy; /* if proxy, set it here */
|
||||||
char *proxyuserpwd; /* Proxy <user:password>, if used */
|
char *proxyuserpwd; /* Proxy <user:password>, if used */
|
||||||
long proxyport; /* If non-zero, use this port number by default. If the
|
long proxyport; /* If non-zero, use this port number by default. If the
|
||||||
proxy string features a ":[port]" that one will override
|
proxy string features a ":[port]" that one will override
|
||||||
@@ -391,33 +463,14 @@ struct UrlData {
|
|||||||
long header_size; /* size of read header(s) in bytes */
|
long header_size; /* size of read header(s) in bytes */
|
||||||
long request_size; /* the amount of bytes sent in the request(s) */
|
long request_size; /* the amount of bytes sent in the request(s) */
|
||||||
|
|
||||||
/*************** Request - specific items ************/
|
|
||||||
|
|
||||||
union {
|
|
||||||
struct HTTP *http;
|
|
||||||
struct HTTP *gopher; /* alias, just for the sake of being more readable */
|
|
||||||
struct HTTP *https; /* alias, just for the sake of being more readable */
|
|
||||||
struct FTP *ftp;
|
|
||||||
#if 0 /* no need for special ones for these: */
|
|
||||||
struct TELNET *telnet;
|
|
||||||
struct FILE *file;
|
|
||||||
struct LDAP *ldap;
|
|
||||||
struct DICT *dict;
|
|
||||||
#endif
|
|
||||||
void *generic;
|
|
||||||
} proto;
|
|
||||||
|
|
||||||
FILE *out; /* the fetched file goes here */
|
FILE *out; /* the fetched file goes here */
|
||||||
FILE *in; /* the uploaded file is read from here */
|
FILE *in; /* the uploaded file is read from here */
|
||||||
FILE *writeheader; /* write the header to this is non-NULL */
|
FILE *writeheader; /* write the header to this is non-NULL */
|
||||||
char *url; /* what to get */
|
char *url; /* what to get */
|
||||||
char *freethis; /* if non-NULL, an allocated string for the URL */
|
char *freethis; /* if non-NULL, an allocated string for the URL */
|
||||||
char *hostname; /* hostname to connect, as parsed from url */
|
long use_port; /* which port to use (when not using default) */
|
||||||
long port; /* which port to use (if non-protocol bind) set
|
|
||||||
CONF_PORT to use this */
|
|
||||||
unsigned short remote_port; /* what remote port to connect to, not the proxy
|
|
||||||
port! */
|
|
||||||
struct Configbits bits; /* new-style (v7) flag data */
|
struct Configbits bits; /* new-style (v7) flag data */
|
||||||
|
struct ssl_config_data ssl; /* this is for ssl-stuff */
|
||||||
|
|
||||||
char *userpwd; /* <user:password>, if used */
|
char *userpwd; /* <user:password>, if used */
|
||||||
char *range; /* range, if used. See README for detailed specification on
|
char *range; /* range, if used. See README for detailed specification on
|
||||||
@@ -459,13 +512,6 @@ struct UrlData {
|
|||||||
long timeout; /* in seconds, 0 means no timeout */
|
long timeout; /* in seconds, 0 means no timeout */
|
||||||
long infilesize; /* size of file to upload, -1 means unknown */
|
long infilesize; /* size of file to upload, -1 means unknown */
|
||||||
|
|
||||||
long maxdownload; /* in bytes, the maximum amount of data to fetch, 0
|
|
||||||
means unlimited */
|
|
||||||
|
|
||||||
/* fields only set and used within _urlget() */
|
|
||||||
int firstsocket; /* the main socket to use */
|
|
||||||
int secondarysocket; /* for i.e ftp transfers */
|
|
||||||
|
|
||||||
char buffer[BUFSIZE+1]; /* buffer with size BUFSIZE */
|
char buffer[BUFSIZE+1]; /* buffer with size BUFSIZE */
|
||||||
|
|
||||||
double current_speed; /* the ProgressShow() funcion sets this */
|
double current_speed; /* the ProgressShow() funcion sets this */
|
||||||
@@ -488,12 +534,13 @@ struct UrlData {
|
|||||||
|
|
||||||
struct CookieInfo *cookies;
|
struct CookieInfo *cookies;
|
||||||
|
|
||||||
struct ssldata ssl; /* this is for ssl-stuff */
|
|
||||||
|
|
||||||
long crlf;
|
long crlf;
|
||||||
struct curl_slist *quote; /* before the transfer */
|
struct curl_slist *quote; /* before the transfer */
|
||||||
struct curl_slist *postquote; /* after the transfer */
|
struct curl_slist *postquote; /* after the transfer */
|
||||||
|
|
||||||
|
/* Telnet negotiation options */
|
||||||
|
struct curl_slist *telnet_options; /* linked list of telnet options */
|
||||||
|
|
||||||
TimeCond timecondition; /* kind of comparison */
|
TimeCond timecondition; /* kind of comparison */
|
||||||
time_t timevalue; /* what time to compare with */
|
time_t timevalue; /* what time to compare with */
|
||||||
|
|
||||||
@@ -504,12 +551,6 @@ struct UrlData {
|
|||||||
char *headerbuff; /* allocated buffer to store headers in */
|
char *headerbuff; /* allocated buffer to store headers in */
|
||||||
int headersize; /* size of the allocation */
|
int headersize; /* size of the allocation */
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* this was removed in libcurl 7.4 */
|
|
||||||
char *writeinfo; /* if non-NULL describes what to output on a successful
|
|
||||||
completion */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct Progress progress; /* for all the progress meter data */
|
struct Progress progress; /* for all the progress meter data */
|
||||||
|
|
||||||
#define MAX_CURL_USER_LENGTH 128
|
#define MAX_CURL_USER_LENGTH 128
|
||||||
@@ -526,25 +567,209 @@ struct UrlData {
|
|||||||
char proxyuser[MAX_CURL_USER_LENGTH];
|
char proxyuser[MAX_CURL_USER_LENGTH];
|
||||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
|
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
|
||||||
|
|
||||||
/**** Dynamicly allocated strings, may need to be freed on return ****/
|
|
||||||
char *ptr_proxyuserpwd; /* free later if not NULL! */
|
|
||||||
char *ptr_uagent; /* free later if not NULL! */
|
|
||||||
char *ptr_userpwd; /* free later if not NULL! */
|
|
||||||
char *ptr_rangeline; /* free later if not NULL! */
|
|
||||||
char *ptr_ref; /* free later if not NULL! */
|
|
||||||
char *ptr_cookie; /* free later if not NULL! */
|
|
||||||
char *ptr_host; /* free later if not NULL */
|
|
||||||
|
|
||||||
char *krb4_level; /* what security level */
|
char *krb4_level; /* what security level */
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
FILE *cmdchannel;
|
FILE *cmdchannel;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct timeval keeps_speed; /* this should be request-specific */
|
struct timeval keeps_speed; /* this should be request-specific */
|
||||||
|
|
||||||
|
/* 'connects' will be an allocated array with pointers. If the pointer is
|
||||||
|
set, it holds an allocated connection. */
|
||||||
|
struct connectdata **connects;
|
||||||
|
size_t numconnects; /* size of the 'connects' array */
|
||||||
|
curl_closepolicy closepolicy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LIBCURL_NAME "libcurl"
|
#define LIBCURL_NAME "libcurl"
|
||||||
#define LIBCURL_ID LIBCURL_NAME " " LIBCURL_VERSION " " SSL_ID
|
#define LIBCURL_ID LIBCURL_NAME " " LIBCURL_VERSION " " SSL_ID
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here follows function prototypes from what we used to plan to call
|
||||||
|
* the "low level" interface. It is no longer prioritized and it is not likely
|
||||||
|
* to ever be supported to external users.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_init()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Inits libcurl globally. This must be used before any libcurl calls can
|
||||||
|
* be used. This may install global plug-ins or whatever. (This does not
|
||||||
|
* do winsock inits in Windows.)
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* curl_init();
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
CURLcode curl_init(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_init()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Frees libcurl globally. This must be used after all libcurl calls have
|
||||||
|
* been used. This may remove global plug-ins or whatever. (This does not
|
||||||
|
* do winsock cleanups in Windows.)
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* curl_free(curl);
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void curl_free(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_open()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Opens a general curl session. It does not try to connect or do anything
|
||||||
|
* on the network because of this call. The specified URL is only required
|
||||||
|
* to enable curl to figure out what protocol to "activate".
|
||||||
|
*
|
||||||
|
* A session should be looked upon as a series of requests to a single host. A
|
||||||
|
* session interacts with one host only, using one single protocol.
|
||||||
|
*
|
||||||
|
* The URL is not required. If set to "" or NULL, it can still be set later
|
||||||
|
* using the curl_setopt() function. If the curl_connect() function is called
|
||||||
|
* without the URL being known, it will return error.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURLcode result;
|
||||||
|
* CURL *curl;
|
||||||
|
* result = curl_open(&curl, "http://curl.haxx.nu/libcurl/");
|
||||||
|
* if(result != CURL_OK) {
|
||||||
|
* return result;
|
||||||
|
* }
|
||||||
|
* */
|
||||||
|
CURLcode curl_open(CURL **curl, char *url);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_setopt()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Sets a particular option to the specified value.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURL curl;
|
||||||
|
* curl_setopt(curl, CURL_HTTP_FOLLOW_LOCATION, TRUE);
|
||||||
|
*/
|
||||||
|
CURLcode curl_setopt(CURL *handle, CURLoption option, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_close()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Closes a session previously opened with curl_open()
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURL *curl;
|
||||||
|
* CURLcode result;
|
||||||
|
*
|
||||||
|
* result = curl_close(curl);
|
||||||
|
*/
|
||||||
|
CURLcode curl_close(CURL *curl); /* the opposite of curl_open() */
|
||||||
|
|
||||||
|
CURLcode curl_read(CURLconnect *c_conn, char *buf, size_t buffersize,
|
||||||
|
ssize_t *n);
|
||||||
|
CURLcode curl_write(CURLconnect *c_conn, char *buf, size_t amount,
|
||||||
|
size_t *n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_connect()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Connects to the peer server and performs the initial setup. This function
|
||||||
|
* writes a connect handle to its second argument that is a unique handle for
|
||||||
|
* this connect. This allows multiple connects from the same handle returned
|
||||||
|
* by curl_open().
|
||||||
|
*
|
||||||
|
* By setting 'allow_port' to FALSE, the data->use_port will *NOT* be
|
||||||
|
* respected.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURLCode result;
|
||||||
|
* CURL curl;
|
||||||
|
* CURLconnect connect;
|
||||||
|
* result = curl_connect(curl, &connect); */
|
||||||
|
|
||||||
|
CURLcode curl_connect(CURL *curl,
|
||||||
|
CURLconnect **in_connect,
|
||||||
|
bool allow_port);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_do()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* (Note: May 3rd 2000: this function does not currently allow you to
|
||||||
|
* specify a document, it will use the one set previously)
|
||||||
|
*
|
||||||
|
* This function asks for the particular document, file or resource that
|
||||||
|
* resides on the server we have connected to. You may specify a full URL,
|
||||||
|
* just an absolute path or even a relative path. That means, if you're just
|
||||||
|
* getting one file from the remote site, you can use the same URL as input
|
||||||
|
* for both curl_open() as well as for this function.
|
||||||
|
*
|
||||||
|
* In the even there is a host name, port number, user name or password parts
|
||||||
|
* in the URL, you can use the 'flags' argument to ignore them completely, or
|
||||||
|
* at your choice, make the function fail if you're trying to get a URL from
|
||||||
|
* different host than you connected to with curl_connect().
|
||||||
|
*
|
||||||
|
* You can only get one document at a time using the same connection. When one
|
||||||
|
* document has been received you can although request again.
|
||||||
|
*
|
||||||
|
* When the transfer is done, curl_done() MUST be called.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURLCode result;
|
||||||
|
* char *url;
|
||||||
|
* CURLconnect *connect;
|
||||||
|
* result = curl_do(connect, url, CURL_DO_NONE); */
|
||||||
|
CURLcode curl_do(CURLconnect *in_conn);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_done()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* When the transfer following a curl_do() call is done, this function should
|
||||||
|
* get called.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURLCode result;
|
||||||
|
* char *url;
|
||||||
|
* CURLconnect *connect;
|
||||||
|
* result = curl_done(connect); */
|
||||||
|
CURLcode curl_done(CURLconnect *connect);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_disconnect()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Disconnects from the peer server and performs connection cleanup.
|
||||||
|
*
|
||||||
|
* EXAMPLE
|
||||||
|
*
|
||||||
|
* CURLcode result;
|
||||||
|
* CURLconnect *connect;
|
||||||
|
* result = curl_disconnect(connect); */
|
||||||
|
CURLcode curl_disconnect(CURLconnect *connect);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -145,7 +145,7 @@ if($totalmem) {
|
|||||||
for(keys %sizeataddr) {
|
for(keys %sizeataddr) {
|
||||||
$addr = $_;
|
$addr = $_;
|
||||||
$size = $sizeataddr{$addr};
|
$size = $sizeataddr{$addr};
|
||||||
if($size) {
|
if($size > 0) {
|
||||||
print "At $addr, there's $size bytes.\n";
|
print "At $addr, there's $size bytes.\n";
|
||||||
print " allocated by ".$getmem{$addr}."\n";
|
print " allocated by ".$getmem{$addr}."\n";
|
||||||
}
|
}
|
||||||
|
25
src/main.c
25
src/main.c
@@ -102,16 +102,13 @@ typedef enum {
|
|||||||
#define CONF_NOBODY (1<<11) /* use HEAD to get http document */
|
#define CONF_NOBODY (1<<11) /* use HEAD to get http document */
|
||||||
#define CONF_FAILONERROR (1<<12) /* no output on http error codes >= 300 */
|
#define CONF_FAILONERROR (1<<12) /* no output on http error codes >= 300 */
|
||||||
#define CONF_UPLOAD (1<<14) /* this is an upload */
|
#define CONF_UPLOAD (1<<14) /* this is an upload */
|
||||||
#define CONF_POST (1<<15) /* HTTP POST method */
|
|
||||||
#define CONF_FTPLISTONLY (1<<16) /* Use NLST when listing ftp dir */
|
#define CONF_FTPLISTONLY (1<<16) /* Use NLST when listing ftp dir */
|
||||||
#define CONF_FTPAPPEND (1<<20) /* Append instead of overwrite on upload! */
|
#define CONF_FTPAPPEND (1<<20) /* Append instead of overwrite on upload! */
|
||||||
#define CONF_NETRC (1<<22) /* read user+password from .netrc */
|
#define CONF_NETRC (1<<22) /* read user+password from .netrc */
|
||||||
#define CONF_FOLLOWLOCATION (1<<23) /* use Location: Luke! */
|
#define CONF_FOLLOWLOCATION (1<<23) /* use Location: Luke! */
|
||||||
#define CONF_GETTEXT (1<<24) /* use ASCII/text for transfer */
|
#define CONF_GETTEXT (1<<24) /* use ASCII/text for transfer */
|
||||||
#define CONF_HTTPPOST (1<<25) /* multipart/form-data HTTP POST */
|
#define CONF_HTTPPOST (1<<25) /* multipart/form-data HTTP POST */
|
||||||
#if 0
|
|
||||||
#define CONF_PUT (1<<27) /* PUT the input file */
|
|
||||||
#endif
|
|
||||||
#define CONF_MUTE (1<<28) /* force NOPROGRESS */
|
#define CONF_MUTE (1<<28) /* force NOPROGRESS */
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
@@ -279,6 +276,7 @@ static void help(void)
|
|||||||
" -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server\n"
|
" -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server\n"
|
||||||
" -s/--silent Silent mode. Don't output anything\n"
|
" -s/--silent Silent mode. Don't output anything\n"
|
||||||
" -S/--show-error Show error. With -s, make curl show errors when they occur\n"
|
" -S/--show-error Show error. With -s, make curl show errors when they occur\n"
|
||||||
|
" -t/--telnet-option <OPT=val> Set telnet option\n"
|
||||||
" -T/--upload-file <file> Transfer/upload <file> to remote site\n"
|
" -T/--upload-file <file> Transfer/upload <file> to remote site\n"
|
||||||
" --url <URL> Another way to specify URL to work with\n"
|
" --url <URL> Another way to specify URL to work with\n"
|
||||||
" -u/--user <user[:password]> Specify user and password to use\n"
|
" -u/--user <user[:password]> Specify user and password to use\n"
|
||||||
@@ -366,6 +364,8 @@ struct Configurable {
|
|||||||
struct HttpPost *httppost;
|
struct HttpPost *httppost;
|
||||||
struct HttpPost *last_post;
|
struct HttpPost *last_post;
|
||||||
|
|
||||||
|
struct curl_slist *telnet_options;
|
||||||
|
|
||||||
HttpReq httpreq;
|
HttpReq httpreq;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -565,7 +565,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
{"r", "range", TRUE},
|
{"r", "range", TRUE},
|
||||||
{"s", "silent", FALSE},
|
{"s", "silent", FALSE},
|
||||||
{"S", "show-error", FALSE},
|
{"S", "show-error", FALSE},
|
||||||
{"t", "upload", FALSE},
|
{"t", "telnet-options", TRUE},
|
||||||
{"T", "upload-file", TRUE},
|
{"T", "upload-file", TRUE},
|
||||||
{"u", "user", TRUE},
|
{"u", "user", TRUE},
|
||||||
{"U", "proxy-user", TRUE},
|
{"U", "proxy-user", TRUE},
|
||||||
@@ -785,8 +785,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
else
|
else
|
||||||
config->postfields=postdata;
|
config->postfields=postdata;
|
||||||
}
|
}
|
||||||
if(config->postfields)
|
|
||||||
config->conf |= CONF_POST;
|
|
||||||
if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq))
|
if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq))
|
||||||
return PARAM_BAD_USE;
|
return PARAM_BAD_USE;
|
||||||
break;
|
break;
|
||||||
@@ -959,9 +958,8 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->showerror ^= TRUE; /* toggle on if used with -s */
|
config->showerror ^= TRUE; /* toggle on if used with -s */
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
/* we are uploading */
|
/* Telnet options */
|
||||||
config->conf ^= CONF_UPLOAD;
|
config->telnet_options = curl_slist_append(config->telnet_options, nextarg);
|
||||||
fprintf(stderr, "-t is a deprecated switch, use '-T -' instead!\n");
|
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
/* we are uploading */
|
/* we are uploading */
|
||||||
@@ -1743,7 +1741,6 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR,
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR,
|
||||||
config->conf&CONF_FAILONERROR);
|
config->conf&CONF_FAILONERROR);
|
||||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, config->conf&CONF_UPLOAD);
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, config->conf&CONF_UPLOAD);
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, config->conf&CONF_POST);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FTPLISTONLY,
|
curl_easy_setopt(curl, CURLOPT_FTPLISTONLY,
|
||||||
config->conf&CONF_FTPLISTONLY);
|
config->conf&CONF_FTPLISTONLY);
|
||||||
curl_easy_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);
|
curl_easy_setopt(curl, CURLOPT_FTPAPPEND, config->conf&CONF_FTPAPPEND);
|
||||||
@@ -1751,9 +1748,6 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,
|
||||||
config->conf&CONF_FOLLOWLOCATION);
|
config->conf&CONF_FOLLOWLOCATION);
|
||||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);
|
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, config->conf&CONF_GETTEXT);
|
||||||
#if 0
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PUT, config->conf&CONF_PUT);
|
|
||||||
#endif
|
|
||||||
curl_easy_setopt(curl, CURLOPT_MUTE, config->conf&CONF_MUTE);
|
curl_easy_setopt(curl, CURLOPT_MUTE, config->conf&CONF_MUTE);
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, config->userpwd);
|
curl_easy_setopt(curl, CURLOPT_USERPWD, config->userpwd);
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
||||||
@@ -1824,6 +1818,9 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
|
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* new in libcurl 7.6.2: */
|
||||||
|
curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
if(config->writeout) {
|
if(config->writeout) {
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define CURL_NAME "curl"
|
#define CURL_NAME "curl"
|
||||||
#define CURL_VERSION "7.6.1"
|
#define CURL_VERSION "7.7-alpha2"
|
||||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||||
|
@@ -2,5 +2,6 @@ HTTP/1.1 301 This is a weirdo text message
|
|||||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
Server: test-server/fake
|
Server: test-server/fake
|
||||||
Location: data/110002.txt?coolsite=yes
|
Location: data/110002.txt?coolsite=yes
|
||||||
|
Connection: close
|
||||||
|
|
||||||
This server reply is for testing a simple Location: following
|
This server reply is for testing a simple Location: following
|
||||||
|
@@ -2,6 +2,7 @@ HTTP/1.1 301 This is a weirdo text message
|
|||||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
Server: test-server/fake
|
Server: test-server/fake
|
||||||
Location: data/110002.txt?coolsite=yes
|
Location: data/110002.txt?coolsite=yes
|
||||||
|
Connection: close
|
||||||
|
|
||||||
HTTP/1.1 200 Followed here fine
|
HTTP/1.1 200 Followed here fine
|
||||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
@@ -51,6 +51,7 @@ my $short;
|
|||||||
my $verbose;
|
my $verbose;
|
||||||
my $debugprotocol;
|
my $debugprotocol;
|
||||||
my $anyway;
|
my $anyway;
|
||||||
|
my $gdbthis; # run test case with gdb debugger
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Return the pid of the server as found in the given pid file
|
# Return the pid of the server as found in the given pid file
|
||||||
@@ -397,12 +398,13 @@ sub singletest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# run curl, add -v for debug information output
|
# run curl, add -v for debug information output
|
||||||
my $CMDLINE="$CURL $out--include -v --silent $cmd >$STDOUT 2>$STDERR";
|
my $cmdargs="$out--include -v --silent $cmd";
|
||||||
|
|
||||||
my $STDINFILE="$TESTDIR/stdin$NUMBER.txt";
|
my $STDINFILE="$TESTDIR/stdin$NUMBER.txt";
|
||||||
if(-f $STDINFILE) {
|
if(-f $STDINFILE) {
|
||||||
$CMDLINE .= " < $STDINFILE";
|
$cmdargs .= " < $STDINFILE";
|
||||||
}
|
}
|
||||||
|
my $CMDLINE="$CURL $cmdargs >$STDOUT 2>$STDERR";
|
||||||
|
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
print "$CMDLINE\n";
|
print "$CMDLINE\n";
|
||||||
@@ -410,9 +412,20 @@ sub singletest {
|
|||||||
|
|
||||||
print CMDLOG "$CMDLINE\n";
|
print CMDLOG "$CMDLINE\n";
|
||||||
|
|
||||||
|
my $res;
|
||||||
# run the command line we built
|
# run the command line we built
|
||||||
my $res = system("$CMDLINE");
|
if($gdbthis) {
|
||||||
$res /= 256;
|
open(GDBCMD, ">log/gdbcmd");
|
||||||
|
print GDBCMD "set args $cmdargs\n";
|
||||||
|
print GDBCMD "show args\n";
|
||||||
|
close(GDBCMD);
|
||||||
|
system("gdb $CURL -x log/gdbcmd");
|
||||||
|
$res =0; # makes it always continue after a debugged run
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$res = system("$CMDLINE");
|
||||||
|
$res /= 256;
|
||||||
|
}
|
||||||
|
|
||||||
my $ERRORCODE = "$TESTDIR/error$NUMBER.txt";
|
my $ERRORCODE = "$TESTDIR/error$NUMBER.txt";
|
||||||
|
|
||||||
@@ -560,6 +573,10 @@ do {
|
|||||||
# have the servers display protocol output
|
# have the servers display protocol output
|
||||||
$debugprotocol=1;
|
$debugprotocol=1;
|
||||||
}
|
}
|
||||||
|
elsif ($ARGV[0] eq "-g") {
|
||||||
|
# run this test with gdb
|
||||||
|
$gdbthis=1;
|
||||||
|
}
|
||||||
elsif($ARGV[0] eq "-s") {
|
elsif($ARGV[0] eq "-s") {
|
||||||
# short output
|
# short output
|
||||||
$short=1;
|
$short=1;
|
||||||
@@ -574,6 +591,7 @@ do {
|
|||||||
Usage: runtests.pl [-h][-s][-v][numbers]
|
Usage: runtests.pl [-h][-s][-v][numbers]
|
||||||
-a continue even if a test fails
|
-a continue even if a test fails
|
||||||
-d display server debug info
|
-d display server debug info
|
||||||
|
-g run the test case with gdb
|
||||||
-h this help text
|
-h this help text
|
||||||
-s short output
|
-s short output
|
||||||
-v verbose output
|
-v verbose output
|
||||||
|
Reference in New Issue
Block a user