Compare commits
37 Commits
curl-7_7
...
curl-7_7_1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
50a53d4eec | ||
![]() |
6bd1ed034a | ||
![]() |
fa491ed910 | ||
![]() |
66a1e3df69 | ||
![]() |
28497e7ee4 | ||
![]() |
87c7f403a9 | ||
![]() |
1a2c3acb3b | ||
![]() |
b54d752783 | ||
![]() |
b1328430c9 | ||
![]() |
34efa74a59 | ||
![]() |
794d08a728 | ||
![]() |
0abc999c4d | ||
![]() |
3e65062be2 | ||
![]() |
45ffb16c2a | ||
![]() |
0b8b0b7c86 | ||
![]() |
053bf49bd2 | ||
![]() |
8b08dfed38 | ||
![]() |
ba3a3553dc | ||
![]() |
6a26104724 | ||
![]() |
8b35b89f4d | ||
![]() |
31f9d4016d | ||
![]() |
bb601731ea | ||
![]() |
9a85172896 | ||
![]() |
a0eb52bee1 | ||
![]() |
6235a8d969 | ||
![]() |
0d6a87ed7a | ||
![]() |
b6241b3c89 | ||
![]() |
1e14f8d4c7 | ||
![]() |
bc5954fe2d | ||
![]() |
02f6894af5 | ||
![]() |
76576cd1e2 | ||
![]() |
997672ba9a | ||
![]() |
ec1f42a154 | ||
![]() |
aa1c3bb46d | ||
![]() |
95f0714ff8 | ||
![]() |
c050619b36 | ||
![]() |
58085dbbf6 |
75
CHANGES
75
CHANGES
@@ -6,6 +6,81 @@
|
||||
|
||||
History of Changes
|
||||
|
||||
Version 7.7.1
|
||||
|
||||
Daniel (3 April 2001)
|
||||
- Puneet Pawaia pointed out two serious problems. Libcurl would attempt to
|
||||
read bad memory during situations when an (ftp) connection attempt failed.
|
||||
Also, the lib/Makefile.vc6 was corrected.
|
||||
|
||||
- More investigations in the Location: following code made me realize that
|
||||
it was not clean enough to work transparantly with persistant and non-
|
||||
persistant connections. I think I've fixed it now.
|
||||
|
||||
Daniel (29 March 2001)
|
||||
- Georg Horn mailed me some corrections for the Curl::easy perl interface.
|
||||
|
||||
- Experimental ftps:// support added. It is basically FTP over SSL for the
|
||||
control connection. It still makes all data transfers going over unencrypted
|
||||
connections. Rainer Weikusat's ftpd-ssl server hack supports this and I used
|
||||
that to verify the functionality.
|
||||
|
||||
Daniel (27 March 2001)
|
||||
- Guenole Bescon discovered that if you set a CURLOPT_TIMEOUT and then tried
|
||||
to get a file from a site and it fails, the SIGALRM would still be sent
|
||||
after the timeout-time, quite inexpectedly!
|
||||
|
||||
- I added an ftp transfer example to docs/examples/ and I also wrote a tiny
|
||||
example makefile that can be used as a start when building one of the
|
||||
examples.
|
||||
|
||||
Version 7.7.1-beta1
|
||||
|
||||
Daniel (26 March 2001)
|
||||
- Mohamed Lrhazi reported problems with 7.6.1 and persistant HTTP/1.0
|
||||
connections (when the server replied a Connection: Keep-Alive) and this
|
||||
problem was not properly dealt with in 7.7 either. A patch was posted to the
|
||||
curl-and-php mailing list.
|
||||
|
||||
Daniel (24 March 2001)
|
||||
- Colin Watson reported about a problem and brought a patch that corrected it,
|
||||
which was about the man page and lines starting with a single quote (') in a
|
||||
way that gnroff doesn't like.
|
||||
|
||||
Daniel (23 March 2001)
|
||||
- Peter Bray reported correctly that the root makefile used make instead of
|
||||
$(MAKE) for the test target.
|
||||
|
||||
- Corrected the Curl::easy perl interface to use curl_easy_setopt() and not
|
||||
curl_setopt() which was removed in 7.7!
|
||||
|
||||
- SM provided updates on three documents (MANUAL, INSTALL and FAQ).
|
||||
|
||||
- When following a Location:, libcurl would sometimes write to the URL string
|
||||
in a way it shouldn't. As the pointer is passed-in to libcurl from an
|
||||
application, we can't be allowed to write to it. The particular bug report
|
||||
from 'nk' that brought this up was because he had a read-only URL that then
|
||||
caused a libcurl crash!
|
||||
|
||||
- No longer reads HEAD responses longer than to the last header. Previously,
|
||||
curl would read the full reply if the connection was a "close" one.
|
||||
|
||||
- libcurl did re-use connections way too much. Doing "curl
|
||||
http://www.{microsoft,ibm}.com" would make it re-use the connection which
|
||||
made the second request return very odd results.
|
||||
|
||||
Daniel (22 March 2001)
|
||||
- Edin Kadribasic made me aware that curl should not re-send POST requests
|
||||
when following 302-redirects. I made 302 work like 303 which means curl uses
|
||||
GET in the following request(s).
|
||||
|
||||
- libcurl now reset the "followed-location" counter on each invoke of
|
||||
curl_easy_perform() as it otherwise would sum up all redirects on the same
|
||||
connection and thus could reach the maxredirs counter wrongly.
|
||||
|
||||
- Jim Drash suggested curl_escape() should not re-encode what already looks
|
||||
like an encoded sequence and I think that's a fair suggestion.
|
||||
|
||||
Version 7.7
|
||||
|
||||
Daniel (22 March 2001)
|
||||
|
@@ -17,7 +17,7 @@ dist-hook:
|
||||
check: test
|
||||
|
||||
test:
|
||||
@(cd tests; make quiet-test)
|
||||
@(cd tests; $(MAKE) quiet-test)
|
||||
|
||||
#
|
||||
# Build source and binary rpms. For rpm-3.0 and above, the ~/.rpmmacros
|
||||
|
38
docs/FAQ
38
docs/FAQ
@@ -1,4 +1,4 @@
|
||||
Updated: March 22, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
||||
Updated: March 23, 2001 (http://curl.haxx.se/docs/faq.shtml)
|
||||
_ _ ____ _
|
||||
___| | | | _ \| |
|
||||
/ __| | | | |_) | |
|
||||
@@ -12,6 +12,8 @@ FAQ
|
||||
1.2 What is libcurl?
|
||||
1.3 What is cURL not?
|
||||
1.4 When will you make curl do XXXX ?
|
||||
1.5 Who makes cURL?
|
||||
1.6 What do you get for making cURL?
|
||||
|
||||
2. Install Related Problems
|
||||
2.1 configure doesn't find OpenSSL even when it is installed
|
||||
@@ -84,10 +86,11 @@ FAQ
|
||||
|
||||
1.2 What is libcurl?
|
||||
|
||||
libcurl is a reliable, higly portable multiprotocol file transfer library.
|
||||
libcurl is a reliable and portable library which provides you with an easy
|
||||
interface to a range of common internet protocols.
|
||||
|
||||
Any application is free to use libcurl, even commercial or closed-source
|
||||
ones.
|
||||
You can use libcurl for free in your application even if it is commercial
|
||||
or closed-source.
|
||||
|
||||
1.3 What is cURL not?
|
||||
|
||||
@@ -141,6 +144,31 @@ FAQ
|
||||
* If you write the code, chances are bigger that it will get into curl
|
||||
faster.
|
||||
|
||||
1.5 Who makes cURL?
|
||||
|
||||
cURL and libcurl are not made by any single individual. Sure, Daniel
|
||||
Stenberg writes the major parts, but various people's submissions are
|
||||
important and crucial. Anyone can post their changes and improvements and
|
||||
have them inserted in the main sources (of course on the condition that
|
||||
developers agree on that the fixes are good).
|
||||
|
||||
The list of contributors in the bottom of the man page is only a small part
|
||||
of all the people that every day provide us with bug reports, suggestions,
|
||||
ideas and source code.
|
||||
|
||||
curl is developed by a community, with Daniel at the wheel.
|
||||
|
||||
1.6 What do you get for making cURL?
|
||||
|
||||
Project cURL is entirely free and open, without any commercial interests or
|
||||
money involved. No person gets paid in any way for developing curl. We all
|
||||
do this volountarily on our spare time.
|
||||
|
||||
We get some help from companies. Contactor Data hosts the curl web site and
|
||||
the main mailing list, Haxx owns the curl web site's domain and
|
||||
sourceforge.net hosts several project tools we take advantage from like the
|
||||
bug tracker, mailing lists and more.
|
||||
|
||||
2. Install Related Problems
|
||||
|
||||
2.1. configure doesn't find OpenSSL even when it is installed
|
||||
@@ -499,7 +527,7 @@ FAQ
|
||||
available way to do multiple requests was to init/perform/cleanup for each
|
||||
transfer.
|
||||
|
||||
5.4 Does libcurl do Winsock initing on win32 systems?
|
||||
5.4 Does libcurl do Winsock initialization on win32 systems?
|
||||
|
||||
No.
|
||||
|
||||
|
@@ -183,9 +183,9 @@ Win32
|
||||
For VC++ 6, there's an included Makefile.vc6 that should be possible
|
||||
to use out-of-the-box.
|
||||
|
||||
Microsoft note: add /Zm200 to the compiler options, as the hugehelp.c
|
||||
won't compile otherwise due to "too long puts string" or something
|
||||
like that!
|
||||
Microsoft note: add /Zm200 to the compiler options to increase the
|
||||
compiler's memory allocation limit, as the hugehelp.c won't compile
|
||||
due to "too long puts string".
|
||||
|
||||
|
||||
With SSL:
|
||||
@@ -251,7 +251,7 @@ IBM OS/2
|
||||
|
||||
PORTS
|
||||
=====
|
||||
Just to show off, this is a probably incomplete list of known hardware and
|
||||
This is a probably incomplete list of known hardware and
|
||||
operating systems that curl has been compiled for:
|
||||
|
||||
- Ultrix
|
||||
|
60
docs/MANUAL
60
docs/MANUAL
@@ -15,10 +15,6 @@ SIMPLE USAGE
|
||||
|
||||
curl ftp://ftp.funet.fi/README
|
||||
|
||||
Get a gopher document from funet's gopher server:
|
||||
|
||||
curl gopher://gopher.funet.fi
|
||||
|
||||
Get a web page from a server using port 8000:
|
||||
|
||||
curl http://www.weirdserver.com:8000/
|
||||
@@ -27,6 +23,10 @@ SIMPLE USAGE
|
||||
|
||||
curl ftp://cool.haxx.se/
|
||||
|
||||
Get a gopher document from funet's gopher server:
|
||||
|
||||
curl gopher://gopher.funet.fi
|
||||
|
||||
Get the definition of curl from a dictionary:
|
||||
|
||||
curl dict://dict.org/m:curl
|
||||
@@ -186,7 +186,7 @@ DETAILED INFORMATION
|
||||
-D/--dump-header option when getting files from both FTP and HTTP, and it
|
||||
will then store the headers in the specified file.
|
||||
|
||||
Store the HTTP headers in a separate file:
|
||||
Store the HTTP headers in a separate file (headers.txt in the example):
|
||||
|
||||
curl --dump-header headers.txt curl.haxx.se
|
||||
|
||||
@@ -245,32 +245,32 @@ POST (HTTP)
|
||||
|
||||
-F accepts parameters like -F "name=contents". If you want the contents to
|
||||
be read from a file, use <@filename> as contents. When specifying a file,
|
||||
you can also specify which content type the file is, by appending
|
||||
';type=<mime type>' to the file name. You can also post contents of several
|
||||
files in one field. So that the field name 'coolfiles' can be sent three
|
||||
files with different content types in a manner similar to:
|
||||
you can also specify the file content type by appending ';type=<mime type>'
|
||||
to the file name. You can also post the contents of several files in one field.
|
||||
For example, the field name 'coolfiles' is used to send three files, with
|
||||
different content types using the following syntax:
|
||||
|
||||
curl -F "coolfiles=@fil1.gif;type=image/gif,fil2.txt,fil3.html" \
|
||||
http://www.post.com/postit.cgi
|
||||
|
||||
If content-type is not specified, curl will try to guess from the extension
|
||||
(it only knows a few), or use the previously specified type (from an earlier
|
||||
file if several files are specified in a list) or finally using the default
|
||||
type 'text/plain'.
|
||||
If the content-type is not specified, curl will try to guess from the file
|
||||
extension (it only knows a few), or use the previously specified type
|
||||
(from an earlier file if several files are specified in a list) or else it
|
||||
will using the default type 'text/plain'.
|
||||
|
||||
Emulate a fill-in form with -F. Let's say you fill in three fields in a
|
||||
form. One field is a file name which to post, one field is your name and one
|
||||
field is a file description. We want to post the file we have written named
|
||||
"cooltext.txt". To let curl do the posting of this data instead of your
|
||||
favourite browser, you have to check out the HTML of the form page to get to
|
||||
know the names of the input fields. In our example, the input field names are
|
||||
favourite browser, you have to read the HTML source of the form page and find
|
||||
the names of the input fields. In our example, the input field names are
|
||||
'file', 'yourname' and 'filedescription'.
|
||||
|
||||
curl -F "file=@cooltext.txt" -F "yourname=Daniel" \
|
||||
-F "filedescription=Cool text file with cool text inside" \
|
||||
http://www.post.com/postit.cgi
|
||||
|
||||
So, to send two files in one post you can do it in two ways:
|
||||
To send two files in one post you can do it in two ways:
|
||||
|
||||
1. Send multiple files in a single "field" with a single field name:
|
||||
|
||||
@@ -280,11 +280,11 @@ POST (HTTP)
|
||||
|
||||
curl -F "docpicture=@dog.gif" -F "catpicture=@cat.gif"
|
||||
|
||||
REFERER
|
||||
REFERRER
|
||||
|
||||
A HTTP request has the option to include information about which address
|
||||
that referred to actual page, and curl allows the user to specify that
|
||||
referrer to get specified on the command line. It is especially useful to
|
||||
that referred to actual page. Curl allows you to specify the
|
||||
referrer to be used on the command line. It is especially useful to
|
||||
fool or trick stupid servers or CGI scripts that rely on that information
|
||||
being available or contain certain data.
|
||||
|
||||
@@ -353,13 +353,17 @@ COOKIES
|
||||
Note that by specifying -b you enable the "cookie awareness" and with -L
|
||||
you can make curl follow a location: (which often is used in combination
|
||||
with cookies). So that if a site sends cookies and a location, you can
|
||||
use a non-existing file to trig the cookie awareness like:
|
||||
use a non-existing file to trigger the cookie awareness like:
|
||||
|
||||
curl -L -b empty-file www.example.com
|
||||
curl -L -b empty.txt www.example.com
|
||||
|
||||
The file to read cookies from must be formatted using plain HTTP headers OR
|
||||
as netscape's cookie file. Curl will determine what kind it is based on the
|
||||
file contents.
|
||||
file contents. In the above command, curl will parse the header and store
|
||||
the cookies received from www.example.com. curl will send to the server the
|
||||
stored cookies which match the request as it follows the location. The
|
||||
file "empty.txt" may be a non-existant file.
|
||||
|
||||
|
||||
PROGRESS METER
|
||||
|
||||
@@ -392,12 +396,12 @@ PROGRESS METER
|
||||
|
||||
SPEED LIMIT
|
||||
|
||||
Curl offers the user to set conditions regarding transfer speed that must
|
||||
be met to let the transfer keep going. By using the switch -y and -Y you
|
||||
can make curl abort transfers if the transfer speed doesn't exceed your
|
||||
given lowest limit for a specified time.
|
||||
Curl allows the user to set the transfer speed conditions that must be met
|
||||
to let the transfer keep going. By using the switch -y and -Y you
|
||||
can make curl abort transfers if the transfer speed is below the specified
|
||||
lowest limit for a specified time.
|
||||
|
||||
To let curl abandon downloading this page if its slower than 3000 bytes per
|
||||
To have curl abort the download if the speed is slower than 3000 bytes per
|
||||
second for 1 minute, run:
|
||||
|
||||
curl -y 3000 -Y 60 www.far-away-site.com
|
||||
@@ -610,7 +614,7 @@ RESUMING FILE TRANSFERS
|
||||
(*1) = This requires that the ftp server supports the non-standard command
|
||||
SIZE. If it doesn't, curl will say so.
|
||||
|
||||
(*2) = This requires that the wb server supports at least HTTP/1.1. If it
|
||||
(*2) = This requires that the web server supports at least HTTP/1.1. If it
|
||||
doesn't, curl will say so.
|
||||
|
||||
TIME CONDITIONS
|
||||
|
@@ -2,7 +2,7 @@
|
||||
.\" nroff -man curl.1
|
||||
.\" Written by Daniel Stenberg
|
||||
.\"
|
||||
.TH curl 1 "15 March 2001" "Curl 7.7" "Curl Manual"
|
||||
.TH curl 1 "24 March 2001" "Curl 7.7" "Curl Manual"
|
||||
.SH NAME
|
||||
curl \- get a URL with FTP, TELNET, LDAP, GOPHER, DICT, FILE, HTTP or
|
||||
HTTPS syntax.
|
||||
@@ -128,7 +128,7 @@ content-type application/x-www-form-urlencoded. Compare to -F. If more than
|
||||
one -d/--data option is used on the same command line, the data pieces
|
||||
specified will be merged together with a separating &-letter. Thus, using '-d
|
||||
name=daniel -d skill=lousy' would generate a post chunk that looks like
|
||||
'name=daniel&skill=lousy'.
|
||||
\&'name=daniel&skill=lousy'.
|
||||
|
||||
If you start the data with the letter @, the rest should be a file name to
|
||||
read the data from, or - if you want curl to read the data from stdin. The
|
||||
@@ -215,7 +215,7 @@ get attached in the post as a file upload, while the < makes a text field and
|
||||
just get the contents for that text field from a file.
|
||||
|
||||
Example, to send your password file to the server, where
|
||||
'password' is the name of the form-field to which /etc/passwd will be the
|
||||
\&'password' is the name of the form-field to which /etc/passwd will be the
|
||||
input:
|
||||
|
||||
.B curl
|
||||
@@ -325,7 +325,7 @@ directory.
|
||||
A quick and very simple example of how to setup a
|
||||
.I .netrc
|
||||
to allow curl to ftp to the machine host.domain.com with user name
|
||||
'myself' and password 'secret' should look similar to:
|
||||
\&'myself' and password 'secret' should look similar to:
|
||||
|
||||
.B "machine host.domain.com login myself password secret"
|
||||
|
||||
|
@@ -2,13 +2,13 @@
|
||||
.\" nroff -man [file]
|
||||
.\" Written by daniel@haxx.se
|
||||
.\"
|
||||
.TH curl_easy_setopt 3 "13 March 2001" "libcurl 7.7" "libcurl Manual"
|
||||
.TH curl_easy_setopt 3 "30 March 2001" "libcurl 7.7" "libcurl Manual"
|
||||
.SH NAME
|
||||
curl_easy_setopt - Set curl easy-session options
|
||||
.SH SYNOPSIS
|
||||
.B #include <curl/curl.h>
|
||||
.sp
|
||||
.BI "CURLcode curl_easy_setopt(CURL *" handle ", CURLoption "option ", ...);
|
||||
.BI "CURLcode curl_easy_setopt(CURL *" handle ", CURLoption "option ", ...);"
|
||||
.ad
|
||||
.SH DESCRIPTION
|
||||
curl_easy_setopt() is called to tell libcurl how to behave in a number of
|
||||
@@ -274,7 +274,11 @@ curl_slist' structs properly filled in. Use
|
||||
.I curl_slist_append(3)
|
||||
to create the list and
|
||||
.I curl_slist_free_all(3)
|
||||
to clean up an entire list.
|
||||
to clean up an entire list. If you add a header that is otherwise generated
|
||||
and used by libcurl internally, your added one will be used instead. If you
|
||||
add a header with no contents as in 'Accept:', the internally used header will
|
||||
just get disabled. Thus, using this option you can add new headers, replace
|
||||
internal headers and remove internal headers.
|
||||
.TP
|
||||
.B CURLOPT_HTTPPOST
|
||||
Tells libcurl you want a multipart/formdata HTTP POST to be made and you
|
||||
@@ -313,7 +317,9 @@ struct curl_slist structs properly filled in as described for
|
||||
.I "CURLOPT_QUOTE"
|
||||
.TP
|
||||
.B CURLOPT_WRITEHEADER
|
||||
Pass a FILE * to be used to write the header part of the received data to.
|
||||
Pass a FILE * to be used to write the header part of the received data to. The
|
||||
headers are guaranteed to be written one-by-one to this file handle and only
|
||||
complete lines are written. Parsing headers should be easy enough using this.
|
||||
.TP
|
||||
.B CURLOPT_COOKIEFILE
|
||||
Pass a pointer to a zero terminated string as parameter. It should contain the
|
||||
@@ -353,7 +359,7 @@ name. (Added in libcurl 7.3)
|
||||
.B CURLOPT_KRB4LEVEL
|
||||
Pass a char * as parameter. Set the krb4 security level, this also enables
|
||||
krb4 awareness. This is a string, 'clear', 'safe', 'confidential' or
|
||||
'private'. If the string is set but doesn't match one of these, 'private'
|
||||
\&'private'. If the string is set but doesn't match one of these, 'private'
|
||||
will be used. Set the string to NULL to disable kerberos4. The kerberos
|
||||
support only works for FTP. (Added in libcurl 7.3)
|
||||
.TP
|
||||
|
@@ -13,7 +13,10 @@ curl_escape - URL encodes the given string
|
||||
.SH DESCRIPTION
|
||||
This function will convert the given input string to an URL encoded string and
|
||||
return that as a new allocated string. All input characters that are not a-z,
|
||||
A-Z or 0-9 will be converted to their "URL escaped" version.
|
||||
A-Z or 0-9 will be converted to their "URL escaped" version. If a sequence of
|
||||
%NN (where NN is a two-digit hexadecimal number) is found in the string to
|
||||
encode, that 3-letter combination will be copied to the output unmodifed,
|
||||
assuming that it is an already encoded piece of data.
|
||||
|
||||
If the 'length' argument is set to 0, curl_escape() will use strlen() on the
|
||||
input 'url' string to find out the size.
|
||||
|
@@ -6,8 +6,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
EXTRA_DIST =
|
||||
README curlgtk.c sepheaders.c simple.c postit.c \
|
||||
win32sockets.c persistant.c \
|
||||
getpageinvar.php simpleget.php simplepost.php
|
||||
win32sockets.c persistant.c ftpget.c Makefile.example
|
||||
|
||||
all:
|
||||
@echo "done"
|
||||
|
41
docs/examples/Makefile.example
Normal file
41
docs/examples/Makefile.example
Normal file
@@ -0,0 +1,41 @@
|
||||
#############################################################################
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# What to call the final executable
|
||||
TARGET = example
|
||||
|
||||
# Which object files that the executable consists of
|
||||
OBJS= ftpget.o
|
||||
|
||||
# What compiler to use
|
||||
CC = gcc
|
||||
|
||||
# Compiler flags, -g for debug, -c to make an object file
|
||||
CFLAGS = -c -g
|
||||
|
||||
# This should point to a directory that holds libcurl, if it isn't
|
||||
# in the system's standard lib dir
|
||||
# We also set a -L to include the directory where we have the openssl
|
||||
# libraries
|
||||
LDFLAGS = -L/home/dast/lib -L/usr/local/ssl/lib
|
||||
|
||||
# We need -lcurl for the curl stuff
|
||||
# We need -lsocket and -lnsl when on Solaris
|
||||
# We need -lssl and -lcrypto when using libcurl with SSL support
|
||||
# We need -ldl for dlopen() if that is in libdl
|
||||
LIBS = -lcurl -lsocket -lnsl -lssl -lcrypto -dl
|
||||
|
||||
# Link the target with all objects and libraries
|
||||
$(TARGET) : $(OBJS)
|
||||
$(CC) $(LDFLAGS) $(LIBS) -o $(TARGET) $(OBJS)
|
||||
|
||||
# Compile the source files into object files
|
||||
ftpget.o : ftpget.c
|
||||
$(CC) $(CFLAGS) $<
|
@@ -7,4 +7,8 @@ advantage of libcurl.
|
||||
If you end up with other small but still useful example sources, please mail
|
||||
them for submission in future packages and on the web site.
|
||||
|
||||
The Makefile.example is an example makefile that could be used to build these
|
||||
examples. Just edit the file according to your system and requirements first.
|
||||
|
||||
Try the php/examples/ directory for PHP programming snippets!
|
||||
|
||||
|
44
docs/examples/ftpget.c
Normal file
44
docs/examples/ftpget.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.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)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *ftpfile;
|
||||
|
||||
/* local file name to store the file as */
|
||||
ftpfile = fopen("curl.tar.gz", "wb"); /* b is binary for win */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Get curl 7.7 from sunet.se's FTP site: */
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"ftp://ftp.sunet.se/pub/www/utilities/curl/curl-7.7.tar.gz");
|
||||
curl_easy_setopt(curl, CURLOPT_FILE, ftpfile);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
fclose(ftpfile); /* close the local file */
|
||||
|
||||
return 0;
|
||||
}
|
@@ -481,8 +481,8 @@ char *curl_escape(char *string, int length);
|
||||
char *curl_unescape(char *string, int length);
|
||||
|
||||
/* This is the version number */
|
||||
#define LIBCURL_VERSION "7.7"
|
||||
#define LIBCURL_VERSION_NUM 0x070700
|
||||
#define LIBCURL_VERSION "7.7.1"
|
||||
#define LIBCURL_VERSION_NUM 0x070701
|
||||
|
||||
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
||||
struct curl_slist {
|
||||
|
@@ -38,6 +38,7 @@ RELEASE_OBJS= \
|
||||
formdatar.obj \
|
||||
ftpr.obj \
|
||||
httpr.obj \
|
||||
http_chunksr.obj \
|
||||
ldapr.obj \
|
||||
dictr.obj \
|
||||
telnetr.obj \
|
||||
@@ -68,6 +69,7 @@ DEBUG_OBJS= \
|
||||
formdatad.obj \
|
||||
ftpd.obj \
|
||||
httpd.obj \
|
||||
http_chunksd.obj \
|
||||
ldapd.obj \
|
||||
dictd.obj \
|
||||
telnetd.obj \
|
||||
@@ -98,6 +100,7 @@ RELEASE_SSL_OBJS= \
|
||||
formdatars.obj \
|
||||
ftprs.obj \
|
||||
httprs.obj \
|
||||
http_chunksrs.obj \
|
||||
ldaprs.obj \
|
||||
dictrs.obj \
|
||||
telnetrs.obj \
|
||||
@@ -128,6 +131,7 @@ LINK_OBJS= \
|
||||
formdata.obj \
|
||||
ftp.obj \
|
||||
http.obj \
|
||||
http_chunks.obj \
|
||||
ldap.obj \
|
||||
dict.obj \
|
||||
telnet.obj \
|
||||
@@ -176,6 +180,8 @@ ftpr.obj: ftp.c
|
||||
$(CCR) $(CFLAGS) ftp.c
|
||||
httpr.obj: http.c
|
||||
$(CCR) $(CFLAGS) http.c
|
||||
http_chunksr.obj: http_chunks.c
|
||||
$(CCR) $(CFLAGS) http_chunks.c
|
||||
ldapr.obj: ldap.c
|
||||
$(CCR) $(CFLAGS) ldap.c
|
||||
dictr.obj: dict.c
|
||||
@@ -234,6 +240,8 @@ ftpd.obj: ftp.c
|
||||
$(CCD) $(CFLAGS) ftp.c
|
||||
httpd.obj: http.c
|
||||
$(CCD) $(CFLAGS) http.c
|
||||
http_chunksd.obj: http_chunks.c
|
||||
$(CCD) $(CFLAGS) http_chunks.c
|
||||
ldapd.obj: ldap.c
|
||||
$(CCD) $(CFLAGS) ldap.c
|
||||
dictd.obj: dict.c
|
||||
@@ -291,8 +299,8 @@ formdatars.obj: formdata.c
|
||||
$(CCRS) $(CFLAGS) formdata.c
|
||||
ftprs.obj: ftp.c
|
||||
$(CCRS) $(CFLAGS) ftp.c
|
||||
httprs.obj: http.c
|
||||
$(CCRS) $(CFLAGS) http.c
|
||||
http_chunksrs.obj: http_chunks.c
|
||||
$(CCRS) $(CFLAGS) http_chunks.c
|
||||
ldaprs.obj: ldap.c
|
||||
$(CCRS) $(CFLAGS) ldap.c
|
||||
dictrs.obj: dict.c
|
||||
|
15
lib/escape.c
15
lib/escape.c
@@ -25,6 +25,7 @@
|
||||
* allocated string or NULL if an error occurred. */
|
||||
|
||||
#include "setup.h"
|
||||
#include <ctype.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -52,6 +53,19 @@ char *curl_escape(char *string, int length)
|
||||
!(in >= 'A' && in <= 'Z') &&
|
||||
!(in >= '0' && in <= '9')) {
|
||||
/* encode it */
|
||||
if(('%' == in) &&
|
||||
(length>=2) &&
|
||||
isxdigit((int)string[1]) &&
|
||||
isxdigit((int)string[2]) ) {
|
||||
/*
|
||||
* This is an already encoded letter, leave it!
|
||||
*/
|
||||
memcpy(&ns[index], string, 3);
|
||||
string+=2;
|
||||
}
|
||||
else {
|
||||
/* encode this now */
|
||||
|
||||
newlen += 2; /* the size grows with two, since this'll become a %XX */
|
||||
if(newlen > alloc) {
|
||||
alloc *= 2;
|
||||
@@ -60,6 +74,7 @@ char *curl_escape(char *string, int length)
|
||||
return NULL;
|
||||
}
|
||||
sprintf(&ns[index], "%%%02X", in);
|
||||
}
|
||||
index+=3;
|
||||
}
|
||||
else {
|
||||
|
28
lib/ftp.c
28
lib/ftp.c
@@ -78,6 +78,7 @@
|
||||
#endif
|
||||
|
||||
#include "strequal.h"
|
||||
#include "ssluse.h"
|
||||
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
#include <curl/mprintf.h>
|
||||
@@ -316,6 +317,14 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(conn->protocol & PROT_FTPS) {
|
||||
/* FTPS is simply ftp with SSL for the control channel */
|
||||
/* now, perform the SSL initialization for this socket */
|
||||
if(Curl_SSLConnect(conn))
|
||||
return CURLE_SSL_CONNECT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* The first thing we do is wait for the "220*" line: */
|
||||
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
|
||||
if(nread < 0)
|
||||
@@ -337,8 +346,6 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
|
||||
set a valid level */
|
||||
sec_request_prot(conn, data->krb4_level);
|
||||
|
||||
data->cmdchannel = fdopen(conn->firstsocket, "w");
|
||||
|
||||
if(sec_login(conn) != 0)
|
||||
infof(data, "Logging in with password in cleartext!\n");
|
||||
else
|
||||
@@ -1702,16 +1709,9 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
|
||||
|
||||
strcat(s, "\r\n"); /* append a trailing CRLF */
|
||||
|
||||
#ifdef KRB4
|
||||
if(conn->sec_complete && conn->data->cmdchannel) {
|
||||
bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
|
||||
fflush(conn->data->cmdchannel);
|
||||
}
|
||||
else
|
||||
#endif /* KRB4 */
|
||||
{
|
||||
bytes_written = swrite(fd, s, strlen(s));
|
||||
}
|
||||
bytes_written=0;
|
||||
Curl_write(conn, fd, s, strlen(s), &bytes_written);
|
||||
|
||||
return(bytes_written);
|
||||
}
|
||||
|
||||
@@ -1720,12 +1720,14 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
|
||||
{
|
||||
struct FTP *ftp= conn->proto.ftp;
|
||||
|
||||
/* The FTP session may or may not have been allocated/setup at this point! */
|
||||
if(ftp) {
|
||||
if(ftp->user)
|
||||
free(ftp->user);
|
||||
if(ftp->passwd)
|
||||
free(ftp->passwd);
|
||||
if(ftp->entrypath)
|
||||
free(ftp->entrypath);
|
||||
|
||||
}
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
@@ -132,44 +132,44 @@
|
||||
then those parser generators need to be fixed instead of adding those
|
||||
names to this list. */
|
||||
|
||||
#define yymaxdepth gd_maxdepth
|
||||
#define yyparse gd_parse
|
||||
#define yylex gd_lex
|
||||
#define yyerror gd_error
|
||||
#define yylval gd_lval
|
||||
#define yychar gd_char
|
||||
#define yydebug gd_debug
|
||||
#define yypact gd_pact
|
||||
#define yyr1 gd_r1
|
||||
#define yyr2 gd_r2
|
||||
#define yydef gd_def
|
||||
#define yychk gd_chk
|
||||
#define yypgo gd_pgo
|
||||
#define yyact gd_act
|
||||
#define yyexca gd_exca
|
||||
#define yyerrflag gd_errflag
|
||||
#define yynerrs gd_nerrs
|
||||
#define yyps gd_ps
|
||||
#define yypv gd_pv
|
||||
#define yys gd_s
|
||||
#define yy_yys gd_yys
|
||||
#define yystate gd_state
|
||||
#define yytmp gd_tmp
|
||||
#define yyv gd_v
|
||||
#define yy_yyv gd_yyv
|
||||
#define yyval gd_val
|
||||
#define yylloc gd_lloc
|
||||
#define yyreds gd_reds /* With YYDEBUG defined */
|
||||
#define yytoks gd_toks /* With YYDEBUG defined */
|
||||
#define yylhs gd_yylhs
|
||||
#define yylen gd_yylen
|
||||
#define yydefred gd_yydefred
|
||||
#define yydgoto gd_yydgoto
|
||||
#define yysindex gd_yysindex
|
||||
#define yyrindex gd_yyrindex
|
||||
#define yygindex gd_yygindex
|
||||
#define yytable gd_yytable
|
||||
#define yycheck gd_yycheck
|
||||
#define yymaxdepth Curl_gd_maxdepth
|
||||
#define yyparse Curl_gd_parse
|
||||
#define yylex Curl_gd_lex
|
||||
#define yyerror Curl_gd_error
|
||||
#define yylval Curl_gd_lval
|
||||
#define yychar Curl_gd_char
|
||||
#define yydebug Curl_gd_debug
|
||||
#define yypact Curl_gd_pact
|
||||
#define yyr1 Curl_gd_r1
|
||||
#define yyr2 Curl_gd_r2
|
||||
#define yydef Curl_gd_def
|
||||
#define yychk Curl_gd_chk
|
||||
#define yypgo Curl_gd_pgo
|
||||
#define yyact Curl_gd_act
|
||||
#define yyexca Curl_gd_exca
|
||||
#define yyerrflag Curl_gd_errflag
|
||||
#define yynerrs Curl_gd_nerrs
|
||||
#define yyps Curl_gd_ps
|
||||
#define yypv Curl_gd_pv
|
||||
#define yys Curl_gd_s
|
||||
#define yy_yys Curl_gd_yys
|
||||
#define yystate Curl_gd_state
|
||||
#define yytmp Curl_gd_tmp
|
||||
#define yyv Curl_gd_v
|
||||
#define yy_yyv Curl_gd_yyv
|
||||
#define yyval Curl_gd_val
|
||||
#define yylloc Curl_gd_lloc
|
||||
#define yyreds Curl_gd_reds /* With YYDEBUG defined */
|
||||
#define yytoks Curl_gd_toks /* With YYDEBUG defined */
|
||||
#define yylhs Curl_gd_yylhs
|
||||
#define yylen Curl_gd_yylen
|
||||
#define yydefred Curl_gd_yydefred
|
||||
#define yydgoto Curl_gd_yydgoto
|
||||
#define yysindex Curl_gd_yysindex
|
||||
#define yyrindex Curl_gd_yyrindex
|
||||
#define yygindex Curl_gd_yygindex
|
||||
#define yytable Curl_gd_yytable
|
||||
#define yycheck Curl_gd_yycheck
|
||||
|
||||
static int yylex ();
|
||||
static int yyerror ();
|
||||
|
@@ -108,44 +108,44 @@
|
||||
then those parser generators need to be fixed instead of adding those
|
||||
names to this list. */
|
||||
|
||||
#define yymaxdepth gd_maxdepth
|
||||
#define yyparse gd_parse
|
||||
#define yylex gd_lex
|
||||
#define yyerror gd_error
|
||||
#define yylval gd_lval
|
||||
#define yychar gd_char
|
||||
#define yydebug gd_debug
|
||||
#define yypact gd_pact
|
||||
#define yyr1 gd_r1
|
||||
#define yyr2 gd_r2
|
||||
#define yydef gd_def
|
||||
#define yychk gd_chk
|
||||
#define yypgo gd_pgo
|
||||
#define yyact gd_act
|
||||
#define yyexca gd_exca
|
||||
#define yyerrflag gd_errflag
|
||||
#define yynerrs gd_nerrs
|
||||
#define yyps gd_ps
|
||||
#define yypv gd_pv
|
||||
#define yys gd_s
|
||||
#define yy_yys gd_yys
|
||||
#define yystate gd_state
|
||||
#define yytmp gd_tmp
|
||||
#define yyv gd_v
|
||||
#define yy_yyv gd_yyv
|
||||
#define yyval gd_val
|
||||
#define yylloc gd_lloc
|
||||
#define yyreds gd_reds /* With YYDEBUG defined */
|
||||
#define yytoks gd_toks /* With YYDEBUG defined */
|
||||
#define yylhs gd_yylhs
|
||||
#define yylen gd_yylen
|
||||
#define yydefred gd_yydefred
|
||||
#define yydgoto gd_yydgoto
|
||||
#define yysindex gd_yysindex
|
||||
#define yyrindex gd_yyrindex
|
||||
#define yygindex gd_yygindex
|
||||
#define yytable gd_yytable
|
||||
#define yycheck gd_yycheck
|
||||
#define yymaxdepth Curl_gd_maxdepth
|
||||
#define yyparse Curl_gd_parse
|
||||
#define yylex Curl_gd_lex
|
||||
#define yyerror Curl_gd_error
|
||||
#define yylval Curl_gd_lval
|
||||
#define yychar Curl_gd_char
|
||||
#define yydebug Curl_gd_debug
|
||||
#define yypact Curl_gd_pact
|
||||
#define yyr1 Curl_gd_r1
|
||||
#define yyr2 Curl_gd_r2
|
||||
#define yydef Curl_gd_def
|
||||
#define yychk Curl_gd_chk
|
||||
#define yypgo Curl_gd_pgo
|
||||
#define yyact Curl_gd_act
|
||||
#define yyexca Curl_gd_exca
|
||||
#define yyerrflag Curl_gd_errflag
|
||||
#define yynerrs Curl_gd_nerrs
|
||||
#define yyps Curl_gd_ps
|
||||
#define yypv Curl_gd_pv
|
||||
#define yys Curl_gd_s
|
||||
#define yy_yys Curl_gd_yys
|
||||
#define yystate Curl_gd_state
|
||||
#define yytmp Curl_gd_tmp
|
||||
#define yyv Curl_gd_v
|
||||
#define yy_yyv Curl_gd_yyv
|
||||
#define yyval Curl_gd_val
|
||||
#define yylloc Curl_gd_lloc
|
||||
#define yyreds Curl_gd_reds /* With YYDEBUG defined */
|
||||
#define yytoks Curl_gd_toks /* With YYDEBUG defined */
|
||||
#define yylhs Curl_gd_yylhs
|
||||
#define yylen Curl_gd_yylen
|
||||
#define yydefred Curl_gd_yydefred
|
||||
#define yydgoto Curl_gd_yydgoto
|
||||
#define yysindex Curl_gd_yysindex
|
||||
#define yyrindex Curl_gd_yyrindex
|
||||
#define yygindex Curl_gd_yygindex
|
||||
#define yytable Curl_gd_yytable
|
||||
#define yycheck Curl_gd_yycheck
|
||||
|
||||
static int yylex ();
|
||||
static int yyerror ();
|
||||
|
117
lib/transfer.c
117
lib/transfer.c
@@ -356,11 +356,10 @@ Transfer(struct connectdata *c_conn)
|
||||
/*
|
||||
* end-of-headers.
|
||||
*
|
||||
* If we requested a "no body" and this isn't a "close"
|
||||
* connection, this is a good time to get out and return
|
||||
* home.
|
||||
* If we requested a "no body", this is a good time to get
|
||||
* out and return home.
|
||||
*/
|
||||
if(!conn->bits.close && data->bits.no_body)
|
||||
if(data->bits.no_body)
|
||||
return CURLE_OK;
|
||||
break; /* exit header line loop */
|
||||
}
|
||||
@@ -423,6 +422,18 @@ Transfer(struct connectdata *c_conn)
|
||||
conn->bits.close = FALSE; /* don't close when done */
|
||||
infof(data, "HTTP/1.0 proxy connection set to keep alive!\n");
|
||||
}
|
||||
else if((httpversion == 0) &&
|
||||
strnequal("Connection: keep-alive", p,
|
||||
strlen("Connection: keep-alive"))) {
|
||||
/*
|
||||
* A HTTP/1.0 reply with the 'Connection: keep-alive' line
|
||||
* tells us the connection will be kept alive for our
|
||||
* pleasure. Default action for 1.0 is to close.
|
||||
*
|
||||
* [RFC2068, section 19.7.1] */
|
||||
conn->bits.close = FALSE; /* don't close when done */
|
||||
infof(data, "HTTP/1.0 connection set to keep alive!\n");
|
||||
}
|
||||
else if (strnequal("Connection: close", p,
|
||||
strlen("Connection: close"))) {
|
||||
/*
|
||||
@@ -736,6 +747,10 @@ CURLcode Curl_perform(CURL *curl)
|
||||
struct UrlData *data = (struct UrlData *)curl;
|
||||
struct connectdata *conn=NULL;
|
||||
bool port=TRUE; /* allow data->use_port to set port to use */
|
||||
char *newurl = NULL; /* possibly a new URL to follow to! */
|
||||
|
||||
data->followlocation=0; /* reset the location-follow counter */
|
||||
data->bits.this_is_a_follow = FALSE; /* reset this */
|
||||
|
||||
Curl_pgrsStartNow(data);
|
||||
|
||||
@@ -746,11 +761,23 @@ CURLcode Curl_perform(CURL *curl)
|
||||
res = Curl_do(conn);
|
||||
if(res == CURLE_OK) {
|
||||
res = Transfer(conn); /* now fetch that URL please */
|
||||
if(res == CURLE_OK)
|
||||
if(res == CURLE_OK) {
|
||||
/*
|
||||
* We must duplicate the new URL here as the connection data
|
||||
* may be free()ed in the Curl_done() function.
|
||||
*/
|
||||
newurl = conn->newurl?strdup(conn->newurl):NULL;
|
||||
|
||||
res = Curl_done(conn);
|
||||
}
|
||||
}
|
||||
|
||||
if((res == CURLE_OK) && conn->newurl) {
|
||||
/*
|
||||
* Important: 'conn' cannot be used here, since it may have been closed
|
||||
* in 'Curl_done' or other functions.
|
||||
*/
|
||||
|
||||
if((res == CURLE_OK) && newurl) {
|
||||
/* Location: redirect
|
||||
|
||||
This is assumed to happen for HTTP(S) only!
|
||||
@@ -763,9 +790,6 @@ CURLcode Curl_perform(CURL *curl)
|
||||
|
||||
if (data->maxredirs && (data->followlocation >= data->maxredirs)) {
|
||||
failf(data,"Maximum (%d) redirects followed", data->maxredirs);
|
||||
#ifdef USE_OLD_DISCONNECT
|
||||
curl_disconnect(c_connect);
|
||||
#endif
|
||||
res=CURLE_TOO_MANY_REDIRECTS;
|
||||
break;
|
||||
}
|
||||
@@ -790,7 +814,7 @@ CURLcode Curl_perform(CURL *curl)
|
||||
data->bits.http_set_referer = TRUE; /* might have been false */
|
||||
}
|
||||
|
||||
if(2 != sscanf(conn->newurl, "%15[^:]://%c", prot, &letter)) {
|
||||
if(2 != sscanf(newurl, "%15[^:]://%c", prot, &letter)) {
|
||||
/***
|
||||
*DANG* this is an RFC 2068 violation. The URL is supposed
|
||||
to be absolute and this doesn't seem to be that!
|
||||
@@ -803,19 +827,21 @@ CURLcode Curl_perform(CURL *curl)
|
||||
char *pathsep;
|
||||
char *newest;
|
||||
|
||||
/* we must make our own copy of the URL to play with, as it may
|
||||
point to read-only data */
|
||||
char *url_clone=strdup(data->url);
|
||||
|
||||
if(!url_clone)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* protsep points to the start of the host name */
|
||||
protsep=strstr(data->url, "//");
|
||||
protsep=strstr(url_clone, "//");
|
||||
if(!protsep)
|
||||
protsep=data->url;
|
||||
else {
|
||||
port=FALSE; /* we got a full URL and thus we should not obey the
|
||||
port number that might have been set by the user
|
||||
in data->use_port */
|
||||
|
||||
protsep=url_clone;
|
||||
else
|
||||
protsep+=2; /* pass the slashes */
|
||||
}
|
||||
|
||||
if('/' != conn->newurl[0]) {
|
||||
if('/' != newurl[0]) {
|
||||
/* First we need to find out if there's a ?-letter in the URL,
|
||||
and cut it and the right-side of that off */
|
||||
pathsep = strrchr(protsep, '?');
|
||||
@@ -836,16 +862,17 @@ CURLcode Curl_perform(CURL *curl)
|
||||
*pathsep=0;
|
||||
}
|
||||
|
||||
newest=(char *)malloc( strlen(data->url) +
|
||||
newest=(char *)malloc( strlen(url_clone) +
|
||||
1 + /* possible slash */
|
||||
strlen(conn->newurl) + 1/* zero byte */);
|
||||
strlen(newurl) + 1/* zero byte */);
|
||||
|
||||
if(!newest)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
sprintf(newest, "%s%s%s", data->url, ('/' == conn->newurl[0])?"":"/",
|
||||
conn->newurl);
|
||||
free(conn->newurl);
|
||||
conn->newurl = newest;
|
||||
sprintf(newest, "%s%s%s", url_clone, ('/' == newurl[0])?"":"/",
|
||||
newurl);
|
||||
free(newurl);
|
||||
free(url_clone);
|
||||
newurl = newest;
|
||||
}
|
||||
else {
|
||||
/* This is an absolute URL, don't use the custom port number */
|
||||
@@ -856,8 +883,8 @@ CURLcode Curl_perform(CURL *curl)
|
||||
free(data->url);
|
||||
|
||||
/* TBD: set the URL with curl_setopt() */
|
||||
data->url = conn->newurl;
|
||||
conn->newurl = NULL; /* don't show! */
|
||||
data->url = newurl;
|
||||
|
||||
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
|
||||
|
||||
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
|
||||
@@ -871,7 +898,6 @@ CURLcode Curl_perform(CURL *curl)
|
||||
switch(data->progress.httpcode) {
|
||||
case 300: /* Multiple Choices */
|
||||
case 301: /* Moved Permanently */
|
||||
case 302: /* Found */
|
||||
case 306: /* Not used */
|
||||
case 307: /* Temporary Redirect */
|
||||
default: /* for all unknown ones */
|
||||
@@ -879,6 +905,24 @@ CURLcode Curl_perform(CURL *curl)
|
||||
* seem to be OK to POST to.
|
||||
*/
|
||||
break;
|
||||
case 302: /* Found */
|
||||
/* (From 10.3.3)
|
||||
|
||||
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
|
||||
to change the method on the redirected request. However, most
|
||||
existing user agent implementations treat 302 as if it were a 303
|
||||
response, performing a GET on the Location field-value regardless
|
||||
of the original request method. The status codes 303 and 307 have
|
||||
been added for servers that wish to make unambiguously clear which
|
||||
kind of reaction is expected of the client.
|
||||
|
||||
(From 10.3.4)
|
||||
|
||||
Note: Many pre-HTTP/1.1 user agents do not understand the 303
|
||||
status. When interoperability with such clients is a concern, the
|
||||
302 status code may be used instead, since most user agents react
|
||||
to a 302 response as described here for 303.
|
||||
*/
|
||||
case 303: /* See Other */
|
||||
/* Disable both types of POSTs, since doing a second POST when
|
||||
* following isn't what anyone would want! */
|
||||
@@ -902,24 +946,19 @@ CURLcode Curl_perform(CURL *curl)
|
||||
*/
|
||||
break;
|
||||
}
|
||||
#ifdef USE_OLD_DISCONNECT
|
||||
curl_disconnect(c_connect);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_DISCONNECT
|
||||
curl_disconnect(c_connect);
|
||||
#endif
|
||||
}
|
||||
break; /* it only reaches here when this shouldn't loop */
|
||||
|
||||
} while(1); /* loop if Location: */
|
||||
|
||||
if(conn->newurl) {
|
||||
free(conn->newurl);
|
||||
conn->newurl = NULL;
|
||||
}
|
||||
if(newurl)
|
||||
free(newurl);
|
||||
|
||||
/* make sure the alarm is switched off! */
|
||||
if(data->timeout || data->connecttimeout)
|
||||
myalarm(0);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
32
lib/url.c
32
lib/url.c
@@ -816,6 +816,9 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
||||
free(conn->hostent_buf);
|
||||
#endif
|
||||
|
||||
if(conn->newurl)
|
||||
free(conn->newurl);
|
||||
|
||||
if(conn->path) /* the URL path part */
|
||||
free(conn->path);
|
||||
|
||||
@@ -936,9 +939,11 @@ ConnectionExists(struct UrlData *data,
|
||||
data->connects[i]=NULL; /* nothing here */
|
||||
continue; /* try another one now */
|
||||
}
|
||||
}
|
||||
|
||||
*usethis = check;
|
||||
return TRUE; /* yes, we found one to use! */
|
||||
|
||||
}
|
||||
}
|
||||
else { /* The requested needle connection is using a proxy,
|
||||
is the checked one using the same? */
|
||||
@@ -1397,6 +1402,8 @@ static CURLcode Connect(struct UrlData *data,
|
||||
#ifdef USE_SSLEAY
|
||||
else if(strnequal(conn->gname, "HTTPS", 5))
|
||||
strcpy(conn->protostr, "https");
|
||||
else if(strnequal(conn->gname, "FTPS", 4))
|
||||
strcpy(conn->protostr, "ftps");
|
||||
#endif /* USE_SSLEAY */
|
||||
else if(strnequal(conn->gname, "TELNET", 6))
|
||||
strcpy(conn->protostr, "telnet");
|
||||
@@ -1666,8 +1673,19 @@ static CURLcode Connect(struct UrlData *data,
|
||||
conn->curl_done = Curl_http_done;
|
||||
conn->curl_close = Curl_http_close;
|
||||
}
|
||||
else if(strequal(conn->protostr, "FTP")) {
|
||||
else if(strequal(conn->protostr, "FTP") ||
|
||||
strequal(conn->protostr, "FTPS")) {
|
||||
char *type;
|
||||
|
||||
if(strequal(conn->protostr, "FTPS")) {
|
||||
#ifdef USE_SSLEAY
|
||||
conn->protocol |= PROT_FTPS;
|
||||
#else
|
||||
failf(data, "libcurl was built with SSL disabled, ftps: not supported!");
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
#endif /* !USE_SSLEAY */
|
||||
}
|
||||
|
||||
conn->port = (data->use_port && allow_port)?data->use_port:PORT_FTP;
|
||||
conn->remote_port = PORT_FTP;
|
||||
conn->protocol |= PROT_FTP;
|
||||
@@ -1676,6 +1694,12 @@ static CURLcode Connect(struct UrlData *data,
|
||||
!data->bits.tunnel_thru_httpproxy) {
|
||||
/* Unless we have asked to tunnel ftp operations through the proxy, we
|
||||
switch and use HTTP operations only */
|
||||
if(conn->protocol & PROT_FTPS) {
|
||||
/* FTPS is a hacked protocol and does not work through your
|
||||
ordinary http proxy! */
|
||||
failf(data, "ftps does not work through http proxy!");
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
}
|
||||
conn->curl_do = Curl_http;
|
||||
conn->curl_done = Curl_http_done;
|
||||
conn->curl_close = Curl_http_close;
|
||||
@@ -2126,8 +2150,10 @@ CURLcode Curl_connect(struct UrlData *data,
|
||||
/* We're not allowed to return failure with memory left allocated
|
||||
in the connectdata struct, free those here */
|
||||
conn = (struct connectdata *)*in_connect;
|
||||
if(conn)
|
||||
if(conn) {
|
||||
Curl_disconnect(conn); /* close the connection */
|
||||
*in_connect = NULL; /* return a NULL */
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@@ -207,6 +207,7 @@ struct connectdata {
|
||||
#define PROT_DICT (1<<6)
|
||||
#define PROT_LDAP (1<<7)
|
||||
#define PROT_FILE (1<<8)
|
||||
#define PROT_FTPS (1<<9)
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
struct addrinfo *hp; /* host info pointer list */
|
||||
@@ -293,7 +294,6 @@ struct connectdata {
|
||||
document headers */
|
||||
|
||||
#ifdef KRB4
|
||||
|
||||
enum protection_level command_prot;
|
||||
enum protection_level data_prot;
|
||||
enum protection_level request_data_prot;
|
||||
@@ -553,10 +553,6 @@ struct UrlData {
|
||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
|
||||
|
||||
char *krb4_level; /* what security level */
|
||||
#ifdef KRB4
|
||||
FILE *cmdchannel;
|
||||
#endif
|
||||
|
||||
struct timeval keeps_speed; /* this should be request-specific */
|
||||
|
||||
/* 'connects' will be an allocated array with pointers. If the pointer is
|
||||
|
@@ -8,7 +8,7 @@ WriteMakefile(
|
||||
'NAME' => 'Curl::easy',
|
||||
'VERSION_FROM' => 'easy.pm', # finds $VERSION
|
||||
'LIBS' => ['-lcurl '], # e.g., '-lm'
|
||||
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
|
||||
'DEFINE' => '-Wall', # e.g., '-DHAVE_SOMETHING'
|
||||
'INC' => '', # e.g., '-I/usr/include/other'
|
||||
'clean' => {FILES => "head.out body.out"}
|
||||
);
|
||||
|
@@ -205,15 +205,15 @@ CODE:
|
||||
if (option < CURLOPTTYPE_OBJECTPOINT) {
|
||||
/* This is an option specifying an integer value: */
|
||||
long value = (long)SvIV(ST(2));
|
||||
RETVAL = curl_setopt(curl, option, value);
|
||||
RETVAL = curl_easy_setopt(curl, option, value);
|
||||
} else if (option == CURLOPT_FILE || option == CURLOPT_INFILE ||
|
||||
option == CURLOPT_WRITEHEADER) {
|
||||
/* This is an option specifying a FILE * value: */
|
||||
FILE * value = IoIFP(sv_2io(ST(2)));
|
||||
RETVAL = curl_setopt(curl, option, value);
|
||||
RETVAL = curl_easy_setopt(curl, option, value);
|
||||
} else if (option == CURLOPT_ERRORBUFFER) {
|
||||
SV *sv;
|
||||
RETVAL = curl_setopt(curl, option, errbuf);
|
||||
RETVAL = curl_easy_setopt(curl, option, errbuf);
|
||||
if (errbufvarname) free(errbufvarname);
|
||||
errbufvarname = strdup(value);
|
||||
sv = perl_get_sv(errbufvarname, TRUE | GV_ADDMULTI);
|
||||
@@ -224,7 +224,7 @@ CODE:
|
||||
RETVAL = -1;
|
||||
} else {
|
||||
/* default, option specifying a char * value: */
|
||||
RETVAL = curl_setopt(curl, option, value);
|
||||
RETVAL = curl_easy_setopt(curl, option, value);
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
@@ -252,19 +252,19 @@ CODE:
|
||||
switch (option & CURLINFO_TYPEMASK) {
|
||||
case CURLINFO_STRING: {
|
||||
char * value = (char *)SvPV(ST(2), PL_na);
|
||||
RETVAL = curl_getinfo(curl, option, &value);
|
||||
RETVAL = curl_easy_getinfo(curl, option, &value);
|
||||
sv_setpv(ST(2), value);
|
||||
break;
|
||||
}
|
||||
case CURLINFO_LONG: {
|
||||
long value = (long)SvIV(ST(2));
|
||||
RETVAL = curl_getinfo(curl, option, &value);
|
||||
RETVAL = curl_easy_getinfo(curl, option, &value);
|
||||
sv_setiv(ST(2), value);
|
||||
break;
|
||||
}
|
||||
case CURLINFO_DOUBLE: {
|
||||
double value = (double)SvNV(ST(2));
|
||||
RETVAL = curl_getinfo(curl, option, &value);
|
||||
RETVAL = curl_easy_getinfo(curl, option, &value);
|
||||
sv_setnv(ST(2), value);
|
||||
break;
|
||||
}
|
||||
|
@@ -11,7 +11,8 @@ elegantly used from within it. You can either invoke external curl command
|
||||
line or use the curl interface.
|
||||
|
||||
Georg Horn's Perl interface to curl is available in the Curl_easy/
|
||||
subdirectory.
|
||||
subdirectory. Using the Curl::easy module is just straightforward and
|
||||
works much like using libcurl in a C programm, so please refer to the
|
||||
documentation of libcurl. Have a look at test.pl to get an idea of how
|
||||
to start.
|
||||
|
||||
Unfortunately, we don't have any examples nor any documentation for it at
|
||||
this point.
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#define CURL_NAME "curl"
|
||||
#define CURL_VERSION "7.7"
|
||||
#define CURL_VERSION "7.7.1"
|
||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||
|
@@ -2,4 +2,3 @@ HTTP/1.1 200 OK
|
||||
Server: thebest/1.0
|
||||
Connection: close
|
||||
|
||||
no?
|
||||
|
Reference in New Issue
Block a user