Compare commits
46 Commits
curl-7_9_4
...
curl-7_9_5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b40b9677b6 | ||
![]() |
c80ad865db | ||
![]() |
758eae49ab | ||
![]() |
721b05e343 | ||
![]() |
a333bddeeb | ||
![]() |
4c6a52fe90 | ||
![]() |
792d73a9cf | ||
![]() |
9a95a3f8c3 | ||
![]() |
485edb777f | ||
![]() |
a8c3431ae9 | ||
![]() |
6fe4a6fa9a | ||
![]() |
6d8c7356d6 | ||
![]() |
a782c96e81 | ||
![]() |
c795123cd5 | ||
![]() |
0ec370e6fb | ||
![]() |
3d5732d4e0 | ||
![]() |
b795929858 | ||
![]() |
535258ffe4 | ||
![]() |
cc161b96ac | ||
![]() |
5c4b422b18 | ||
![]() |
89bad584c3 | ||
![]() |
e21926f7f0 | ||
![]() |
e452f467d4 | ||
![]() |
dfda7ba456 | ||
![]() |
feb6b6445e | ||
![]() |
0b57fa9c51 | ||
![]() |
55c6f60c90 | ||
![]() |
9def011e8e | ||
![]() |
7cf6e8c9cc | ||
![]() |
cdee43aa59 | ||
![]() |
9c25b58b4c | ||
![]() |
83f35463f5 | ||
![]() |
818cdb879e | ||
![]() |
3eead2d6c4 | ||
![]() |
5cffe055ad | ||
![]() |
3d4511daf3 | ||
![]() |
4748b40ad9 | ||
![]() |
c40b4f6c39 | ||
![]() |
d3b96dd394 | ||
![]() |
f946df640b | ||
![]() |
fef78bd6f1 | ||
![]() |
9e6cc86bf7 | ||
![]() |
b544c5fa5c | ||
![]() |
afa64ee31f | ||
![]() |
e9bfef0eb1 | ||
![]() |
ddbcccd43d |
70
CHANGES
70
CHANGES
@@ -7,6 +7,76 @@
|
||||
History of Changes
|
||||
|
||||
|
||||
Daniel (20 February 2002)
|
||||
- Andr<64>s Garc<72>a provided a solution to bug report #515228. the total time
|
||||
counter was not set correctly when -I was used during some conditions (all
|
||||
headers were read in one single read).
|
||||
|
||||
- Nico Baggus provided a huge patch with minor tweaks all over to make curl
|
||||
compile nicely on VMS.
|
||||
|
||||
Daniel (19 February 2002)
|
||||
- Rick Richardson found out that by replacing PF_UNSPEC with PF_INET in the
|
||||
getaddrinfo() calls, he could speed up some name resolving calls with an
|
||||
order of magnitudes on his Redhat Linux 7.2.
|
||||
|
||||
- Philip Gladstone found a second INADDR_NONE problem where we used long
|
||||
intead of in_addr_t which caused 64bit problemos. We really shouldn't define
|
||||
that on two different places.
|
||||
|
||||
Daniel (18 February 2002)
|
||||
- Philip Gladstone found a problem in how HTTP requests were sent if the
|
||||
request couldn't be sent all at once.
|
||||
|
||||
- Emil found and corrected a bad connection timeout comparison that made curl
|
||||
use the longest of connect-timeout and timout as a timeout value, instead of
|
||||
the shortest as it was supposed to!
|
||||
|
||||
- Aron Roberts provided updated information about LDAP URL syntax to go into
|
||||
the manual as a replacement for the old references.
|
||||
|
||||
Daniel (17 February 2002)
|
||||
- Philip Gladstone pointed out two missing include files that made curl core
|
||||
dump on 64bit architectures. We need to pay more attention on these details.
|
||||
It is *lethal* to for example forget the malloc() prototype, as 'int' is
|
||||
32bit and malloc() must return a 64bit pointer on these platforms.
|
||||
|
||||
- Giaslas Georgios fixed a problem with Host: headers on repeated requests on
|
||||
the same handle using a proxy.
|
||||
|
||||
Daniel (8 February 2002)
|
||||
- Hanno L. Kranzhoff accurately found out that disabling the Expect: header
|
||||
when doing multipart formposts didn't work very well. It disabled other
|
||||
parts of the request header too, resulting in a broken header. When I fixed
|
||||
this, I also noticed that the Content-Type wasn't possible to disable. It is
|
||||
now, even though it probably is really stupid to try to do this (because of
|
||||
the boundary string that is included in the internally generated header,
|
||||
used as form part separator.)
|
||||
|
||||
Daniel (7 February 2002)
|
||||
- I moved the config*.h files from the root directory to the lib/ directory.
|
||||
|
||||
- I've added the new test suite HTTP server to the CVS repository, It seems to
|
||||
work pretty good now, but we must make it get used by the test scripts
|
||||
properly and then we need to make sure that it compiles, builds and runs on
|
||||
most operating systems.
|
||||
|
||||
Version 7.9.5-pre1
|
||||
|
||||
Daniel (6 February 2002)
|
||||
- Miklos Nemeth provided updated windows makefiles and INSTALL docs.
|
||||
|
||||
- Mr Larry Fahnoe found a problem with formposts and I managed to track down
|
||||
and patch this bug. This was actually two bugs, as the posted size was also
|
||||
said to be two bytes too large.
|
||||
|
||||
- Brent Beardsley found out and brought a correction for the
|
||||
CURLINFO_CONTENT_TYPE parser that was off one byte. This was my fault, I
|
||||
accidentaly broke Giaslas Georgios' patch.
|
||||
|
||||
Daniel (5 February 2002)
|
||||
- Kevin Roth found yet another SSL download problem.
|
||||
|
||||
Version 7.9.4
|
||||
|
||||
- no changes since pre-release
|
||||
|
@@ -6,8 +6,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
EXTRA_DIST = \
|
||||
CHANGES LEGAL maketgz MITX.txt MPL-1.1.txt \
|
||||
reconf Makefile.dist curl-config.in build_vms.com curl-mode.el \
|
||||
config-vms.h config-win32.h config-riscos.h config-mac.h
|
||||
reconf Makefile.dist curl-config.in build_vms.com curl-mode.el
|
||||
|
||||
bin_SCRIPTS = curl-config
|
||||
|
||||
|
@@ -51,6 +51,12 @@ vc-ssl:
|
||||
cd lib
|
||||
nmake -f Makefile.vc6 cfg=release-ssl
|
||||
cd ..\src
|
||||
nmake -f Makefile.vc6 cfg=release-ssl
|
||||
|
||||
vc-ssl-dll:
|
||||
cd lib
|
||||
nmake -f Makefile.vc6 cfg=release-ssl-dll
|
||||
cd ..\src
|
||||
nmake -f Makefile.vc6
|
||||
|
||||
cygwin:
|
||||
|
@@ -6,14 +6,16 @@ $ loc = f$environment("PROCEDURE")
|
||||
$ def = f$parse("X.X;1",loc) - "X.X;1"
|
||||
$
|
||||
$ set def 'def'
|
||||
$ cc_qual = "/define=HAVE_CONFIG_H=1/include=(""../include/"",""../"")"
|
||||
$ cc_qual = "/define=HAVE_CONFIG_H=1/include=(""../include/"",""../"",""../../openssl-0_9_6c/include/"")"
|
||||
$ if p1 .eqs. "LISTING" then cc_qual = cc_qual + "/LIST/MACHINE"
|
||||
$ if p1 .eqs. "DEBUG" then cc_qual = cc_qual + "/LIST/MACHINE/DEBUG"
|
||||
$ msg_qual = ""
|
||||
$ call build "[.lib]" "*.c"
|
||||
$ call build "[.src]" "*.c"
|
||||
$ call build "[.src]" "*.msg"
|
||||
$ link /exe=curl.exe [.src]curl/lib/include=main,[.lib]curl/lib
|
||||
$ link /exe=curl.exe [.src]curl/lib/include=main,[.lib]curl/lib, -
|
||||
[-.openssl-0_9_6c.axp.exe.ssl]libssl/lib, -
|
||||
[-.openssl-0_9_6c.axp.exe.crypto]libcrypto/lib
|
||||
$
|
||||
$
|
||||
$ goto Common_Exit
|
||||
|
@@ -8,7 +8,7 @@ AC_PREREQ(2.50)
|
||||
dnl First some basic init macros
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([lib/urldata.h])
|
||||
AM_CONFIG_HEADER(config.h src/config.h)
|
||||
AM_CONFIG_HEADER(lib/config.h src/config.h)
|
||||
|
||||
dnl figure out the libcurl version
|
||||
VERSION=`sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curl.h`
|
||||
|
29
docs/INSTALL
29
docs/INSTALL
@@ -203,15 +203,32 @@ Win32
|
||||
----------------------------
|
||||
Please read the OpenSSL documentation on how to compile and install
|
||||
the OpenSSL library. This generates the libeay32.dll and ssleay32.dll
|
||||
files.
|
||||
files in the out32dll subdirectory in the OpenSSL home directory. If
|
||||
you compiled OpenSSL static libraries (libeay32.lib, ssleay32.lib,
|
||||
RSAglue.lib) they are created in the out32 subdirectory.
|
||||
|
||||
Run the 'vcvars32.bat' file to get the proper environment variables
|
||||
set. Edit the makefile.vc6 in the lib directory and define
|
||||
OPENSSL_PATH. Set the location of the OpenSSL library and run 'nmake
|
||||
vc-ssl' in the root directory.
|
||||
set. The vcvars32.bat file is part of the Microsoft development
|
||||
environment and you may find it in 'C:\Program Files\Microsoft Visual
|
||||
Studio\vc98\bin' if you installed Visual C/C++ 6 in the default
|
||||
directory.
|
||||
|
||||
The vcvars32.bat file is part of the Microsoft development
|
||||
environment.
|
||||
Before running nmake define the OPENSSL_PATH environment variable with
|
||||
the root/base directory of OpenSSL, for example:
|
||||
|
||||
set OPENSSL_PATH=c:\openssl-0.9.6b
|
||||
|
||||
Then run 'nmake vc-ssl' or 'nmake vc-ssl-dll' in the curl's root
|
||||
directory. 'nmake vc-ssl' will create a libcurl static and dynamic
|
||||
libraries in the lib subdirectory, as well as a statically linked
|
||||
version of curl.exe in the scr subdirectory. This statically linked
|
||||
version is a standalone executable not requiring any DLL at
|
||||
runtime. This making method requires that you have build the static
|
||||
libraries of OpenSSL available in OpenSSL's out32 subdirectory.
|
||||
'nmake vc-ssl-dll' creates the libcurl dynamic library and
|
||||
links curl.exe against libcurl and OpenSSL dynamically.
|
||||
This executables requires libcurl.dll and the OpenSSL DLLs
|
||||
at runtime.
|
||||
|
||||
Microsoft / Borland style
|
||||
-------------------------
|
||||
|
10
docs/MANUAL
10
docs/MANUAL
@@ -668,8 +668,14 @@ LDAP
|
||||
and offer ldap:// support.
|
||||
|
||||
LDAP is a complex thing and writing an LDAP query is not an easy task. I do
|
||||
advice you to dig up the syntax description for that elsewhere, RFC 1959 if
|
||||
no other place is better.
|
||||
advice you to dig up the syntax description for that elsewhere. Two places
|
||||
that might suit you are:
|
||||
|
||||
Netscape's "Netscape Directory SDK 3.0 for C Programmer's Guide Chapter 10:
|
||||
Working with LDAP URLs":
|
||||
http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm
|
||||
|
||||
RFC 2255, "The LDAP URL Format" http://www.rfc-editor.org/rfc/rfc2255.txt
|
||||
|
||||
To show you an example, this is now I can get all people from my local LDAP
|
||||
server that has a certain sub-domain in their email address:
|
||||
|
35
docs/TODO
35
docs/TODO
@@ -49,8 +49,8 @@ TODO
|
||||
very long time idle connections.
|
||||
|
||||
* Make sure we don't ever loop because of non-blocking sockets return
|
||||
EWOULDBLOCK or similar. This concerns the HTTP request sending, the FTP
|
||||
command sending etc.
|
||||
EWOULDBLOCK or similar. This concerns the HTTP request sending (and
|
||||
especially regular HTTP POST), the FTP command sending etc.
|
||||
|
||||
* Go through the code and verify that libcurl deals with big files >2GB and
|
||||
>4GB all over. Bug reports indicate that it doesn't currently work
|
||||
@@ -83,6 +83,12 @@ TODO
|
||||
encoding. [http://curl.haxx.se/dev/HTTP-PUT-stdin.txt] When the filter
|
||||
system mentioned above gets real, it'll be a piece of cake to add.
|
||||
|
||||
* Pass a list of host name to libcurl to which we allow the user name and
|
||||
password to get sent to. Currently, it only get sent to the host name that
|
||||
the first URL uses (to prevent others from being able to read it), but this
|
||||
also prevents the authentication info from getting sent when following
|
||||
locations to legitimate other host names.
|
||||
|
||||
* "Content-Encoding: compress/gzip/zlib" HTTP 1.1 clearly defines how to get
|
||||
and decode compressed documents. There is the zlib that is pretty good at
|
||||
decompressing stuff. This work was started in October 1999 but halted again
|
||||
@@ -127,6 +133,14 @@ TODO
|
||||
|
||||
SSL
|
||||
|
||||
* If you really want to improve the SSL situation, you should probably have a
|
||||
look at SSL cafile loading as well - quick traces look to me like these are
|
||||
done on every request as well, when they should only be necessary once per
|
||||
ssl context (or once per handle). Even better would be to support the SSL
|
||||
CAdir option - instead of loading all of the root CA certs for every
|
||||
request, this option allows you to only read the CA chain that is actually
|
||||
required (into the cache)...
|
||||
|
||||
* Add an interface to libcurl that enables "session IDs" to get
|
||||
exported/imported. Cris Bailiff said: "OpenSSL has functions which can
|
||||
serialise the current SSL state to a buffer of your choice, and
|
||||
@@ -135,6 +149,11 @@ TODO
|
||||
idea might become moot if we enable the 'data sharing' as mentioned in the
|
||||
LIBCURL label above.
|
||||
|
||||
* OpenSSL supports a callback for customised verification of the peer
|
||||
certificate, but this doesn't seem to be exposed in the libcurl APIs. Could
|
||||
it be? There's so much that could be done if it were! (brought by Chris
|
||||
Clark)
|
||||
|
||||
* Make curl's SSL layer option capable of using other free SSL libraries.
|
||||
Such as the Mozilla Security Services
|
||||
(http://www.mozilla.org/projects/security/pki/nss/) and GNUTLS
|
||||
@@ -159,6 +178,18 @@ TODO
|
||||
make sure that happens. It should of course not make more than one
|
||||
connection to the same remote host.
|
||||
|
||||
* Extending the capabilities of the multipart formposting. How about leaving
|
||||
the ';type=foo' syntax as it is and adding an extra tag (headers) which
|
||||
works like this: curl -F "coolfiles=@fil1.txt;headers=@fil1.hdr" where
|
||||
fil1.hdr contains extra headers like
|
||||
|
||||
Content-Type: text/plain; charset=KOI8-R"
|
||||
Content-Transfer-Encoding: base64
|
||||
X-User-Comment: Please don't use browser specific HTML code
|
||||
|
||||
which should overwrite the program reasonable defaults (plain/text,
|
||||
8bit...) (Idea brough to us by kromJx)
|
||||
|
||||
TEST SUITE
|
||||
|
||||
* Extend the test suite to include more protocols. The telnet could just do
|
||||
|
@@ -324,7 +324,8 @@ changed with \fICURLOPT_SSLCERTTYPE\fP.
|
||||
.TP
|
||||
.B CURLOPT_SSLCERTTYPE
|
||||
Pass a pointer to a zero terminated string as parameter. The string should be
|
||||
the format of your certificate. Supported formats are "PEM" and "DER".
|
||||
the format of your certificate. Supported formats are "PEM" and "DER". (Added
|
||||
in 7.9.3)
|
||||
.TP
|
||||
.B CURLOPT_SSLCERTPASSWD
|
||||
Pass a pointer to a zero terminated string as parameter. It will be used as
|
||||
@@ -339,11 +340,12 @@ a certificate but you need one to load your private key.
|
||||
.B CURLOPT_SSLKEY
|
||||
Pass a pointer to a zero terminated string as parameter. The string should be
|
||||
the file name of your private key. The default format is "PEM" and can be
|
||||
changed with \fICURLOPT_SSLKEYTYPE\fP.
|
||||
changed with \fICURLOPT_SSLKEYTYPE\fP. (Added in 7.9.3)
|
||||
.TP
|
||||
.B CURLOPT_SSLKEYTYPE
|
||||
Pass a pointer to a zero terminated string as parameter. The string should be
|
||||
the format of your private key. Supported formats are "PEM", "DER" and "ENG".
|
||||
(Added in 7.9.3)
|
||||
|
||||
\fBNOTE:\fPThe format "ENG" enables you to load the private key from a crypto
|
||||
engine. in this case \fICURLOPT_SSLKEY\fP is used as an identifier passed to
|
||||
@@ -351,22 +353,25 @@ the engine. You have to set the crypto engine with \fICURLOPT_SSL_ENGINE\fP.
|
||||
.TP
|
||||
.B CURLOPT_SSLKEYASSWD
|
||||
Pass a pointer to a zero terminated string as parameter. It will be used as
|
||||
the password required to use the \fICURLOPT_SSLKEY\fP private key. If the password
|
||||
is not supplied, you will be prompted for it. \fICURLOPT_PASSWDFUNCTION\fP can
|
||||
be used to set your own prompt function.
|
||||
the password required to use the \fICURLOPT_SSLKEY\fP private key. If the
|
||||
password is not supplied, you will be prompted for
|
||||
it. \fICURLOPT_PASSWDFUNCTION\fP can be used to set your own prompt function.
|
||||
(Added in 7.9.3)
|
||||
.TP
|
||||
.B CURLOPT_SSL_ENGINE
|
||||
Pass a pointer to a zero terminated string as parameter. It will be used as
|
||||
the identifier for the crypto engine you want to use for your private key.
|
||||
the identifier for the crypto engine you want to use for your private
|
||||
key. (Added in 7.9.3)
|
||||
|
||||
\fBNOTE:\fPIf the crypto device cannot be loaded, \fICURLE_SSL_ENGINE_NOTFOUND\fP
|
||||
is returned.
|
||||
\fBNOTE:\fPIf the crypto device cannot be loaded,
|
||||
\fICURLE_SSL_ENGINE_NOTFOUND\fP is returned.
|
||||
.TP
|
||||
.B CURLOPT_SSL_ENGINEDEFAULT
|
||||
Sets the actual crypto engine as the default for (asymetric) crypto operations.
|
||||
Sets the actual crypto engine as the default for (asymetric) crypto
|
||||
operations. (Added in 7.9.3)
|
||||
|
||||
\fBNOTE:\fPIf the crypto device cannot be set, \fICURLE_SSL_ENGINE_SETFAILED\fP
|
||||
is returned.
|
||||
\fBNOTE:\fPIf the crypto device cannot be set,
|
||||
\fICURLE_SSL_ENGINE_SETFAILED\fP is returned.
|
||||
.TP
|
||||
.B CURLOPT_CRLF
|
||||
Convert Unix newlines to CRLF newlines on FTP uploads.
|
||||
|
@@ -6,7 +6,8 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
EXTRA_DIST = getdate.y \
|
||||
Makefile.b32 Makefile.b32.resp Makefile.m32 Makefile.vc6 \
|
||||
libcurl.def dllinit.c curllib.dsp curllib.dsw
|
||||
libcurl.def dllinit.c curllib.dsp curllib.dsw \
|
||||
config-vms.h config-win32.h config-riscos.h config-mac.h
|
||||
|
||||
lib_LTLIBRARIES = libcurl.la
|
||||
|
||||
|
@@ -23,13 +23,18 @@
|
||||
# CHANGE LOG
|
||||
# ------------------------------------------------------------
|
||||
# 05.11.2001 John Lask Initial Release
|
||||
# 02.05.2002 Miklos Nemeth OPENSSL_PATH environment; no need
|
||||
# for OpenSSL libraries when creating a
|
||||
# static libcurl.lib
|
||||
#
|
||||
#
|
||||
##############################################################
|
||||
|
||||
LIB_NAME = libcurl
|
||||
LIB_NAME_DEBUG = libcurld
|
||||
!IFNDEF OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.6
|
||||
!ENDIF
|
||||
|
||||
#############################################################
|
||||
## Nothing more to do below this line!
|
||||
@@ -46,6 +51,8 @@ LFLAGSSSL = /LIBPATH:$(OPENSSL_PATH)/out32dll
|
||||
LINKLIBS = ws2_32.lib
|
||||
SSLLIBS = libeay32.lib ssleay32.lib RSAglue.lib
|
||||
CFGSET = FALSE
|
||||
LFLAGSSSL=
|
||||
SSLLIBS =
|
||||
|
||||
######################
|
||||
# release
|
||||
|
@@ -221,22 +221,22 @@
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define if you have the <openssl/crypto.h> header file. */
|
||||
#undef HAVE_OPENSSL_CRYPTO_H
|
||||
#define HAVE_OPENSSL_CRYPTO_H 1
|
||||
|
||||
/* Define if you have the <openssl/err.h> header file. */
|
||||
#undef HAVE_OPENSSL_ERR_H
|
||||
#define HAVE_OPENSSL_ERR_H 1
|
||||
|
||||
/* Define if you have the <openssl/pem.h> header file. */
|
||||
#undef HAVE_OPENSSL_PEM_H
|
||||
#define HAVE_OPENSSL_PEM_H 1
|
||||
|
||||
/* Define if you have the <openssl/rsa.h> header file. */
|
||||
#undef HAVE_OPENSSL_RSA_H
|
||||
#define HAVE_OPENSSL_RSA_H 1
|
||||
|
||||
/* Define if you have the <openssl/ssl.h> header file. */
|
||||
#undef HAVE_OPENSSL_SSL_H
|
||||
#define HAVE_OPENSSL_SSL_H 1
|
||||
|
||||
/* Define if you have the <openssl/x509.h> header file. */
|
||||
#undef HAVE_OPENSSL_X509_H
|
||||
#define HAVE_OPENSSL_X509_H 1
|
||||
|
||||
/* Define if you have the <pem.h> header file. */
|
||||
#undef HAVE_PEM_H
|
||||
@@ -296,7 +296,7 @@
|
||||
#undef HAVE_X509_H
|
||||
|
||||
/* Define if you have the crypto library (-lcrypto). */
|
||||
#undef HAVE_LIBCRYPTO
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define if you have the dl library (-ldl). */
|
||||
#undef HAVE_LIBDL
|
||||
@@ -314,7 +314,7 @@
|
||||
#define HAVE_LIBSOCKET 1
|
||||
|
||||
/* Define if you have the ssl library (-lssl). */
|
||||
#undef HAVE_LIBSSL
|
||||
#define HAVE_LIBSSL 1
|
||||
|
||||
/* Define if you have the ucb library (-lucb). */
|
||||
#undef HAVE_LIBUCB
|
||||
@@ -346,7 +346,7 @@
|
||||
#undef HAVE_GETPASS
|
||||
|
||||
/* Define if you have a working OpenSSL installation */
|
||||
#undef OPENSSL_ENABLED
|
||||
#define OPENSSL_ENABLED 1
|
||||
|
||||
/* Define if you have the `dlopen' function. */
|
||||
#undef HAVE_DLOPEN
|
||||
@@ -365,3 +365,4 @@
|
||||
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
#define HAVE_FIONBIO 1
|
@@ -48,6 +48,10 @@
|
||||
#include <stdlib.h> /* required for free() prototype, without it, this crashes
|
||||
on macos 68K */
|
||||
#endif
|
||||
#ifdef VMS
|
||||
#include <in.h>
|
||||
#include <inet.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
@@ -361,7 +365,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||
|
||||
/* get the most strict timeout of the ones converted to milliseconds */
|
||||
if(data->set.timeout &&
|
||||
(data->set.timeout>data->set.connecttimeout))
|
||||
(data->set.timeout < data->set.connecttimeout))
|
||||
timeout_ms = data->set.timeout*1000;
|
||||
else
|
||||
timeout_ms = data->set.connecttimeout*1000;
|
||||
|
@@ -38,7 +38,7 @@ struct Cookie {
|
||||
char *value; /* name = <this> */
|
||||
char *path; /* path = <this> */
|
||||
char *domain; /* domain = <this> */
|
||||
time_t expires; /* expires = <this> */
|
||||
long expires; /* expires = <this> */
|
||||
char *expirestr; /* the plain text version */
|
||||
|
||||
char field1; /* read from a cookie file, 1 => FALSE, 2=> TRUE */
|
||||
|
@@ -81,6 +81,10 @@ DllMain (
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
#ifdef VMS
|
||||
int VOID_VAR_DLLINIT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@@ -1065,6 +1065,9 @@ struct FormData *Curl_getFormData(struct HttpPost *post,
|
||||
|
||||
do {
|
||||
|
||||
if(size)
|
||||
size += AddFormDataf(&form, "\r\n");
|
||||
|
||||
/* boundary */
|
||||
size += AddFormDataf(&form, "--%s\r\n", boundary);
|
||||
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef VMS
|
||||
#include <in.h>
|
||||
#include <inet.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -1575,7 +1576,7 @@ CURLcode ftp_perform(struct connectdata *conn)
|
||||
struct tm buffer;
|
||||
tm = (struct tm *)localtime_r(&data->info.filetime, &buffer);
|
||||
#else
|
||||
tm = localtime(&data->info.filetime);
|
||||
tm = localtime((unsigned long *)&data->info.filetime);
|
||||
#endif
|
||||
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
|
||||
strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S %Z\r\n",
|
||||
|
109
lib/getdate.c
109
lib/getdate.c
@@ -34,8 +34,6 @@
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
@@ -43,7 +41,6 @@
|
||||
# ifdef HAVE_TIME_H
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYDEBUG
|
||||
/* to satisfy gcc -Wundef, we set this to 0 */
|
||||
@@ -230,7 +227,7 @@ typedef struct _CONTEXT {
|
||||
#define YYLEX_PARAM cookie
|
||||
#define context ((CONTEXT *) cookie)
|
||||
|
||||
#line 218 "getdate.y"
|
||||
#line 215 "getdate.y"
|
||||
typedef union {
|
||||
int Number;
|
||||
enum _MERIDIAN Meridian;
|
||||
@@ -313,11 +310,11 @@ static const short yyrhs[] = { -1,
|
||||
|
||||
#if YYDEBUG != 0
|
||||
static const short yyrline[] = { 0,
|
||||
234, 235, 238, 241, 244, 247, 250, 253, 256, 262,
|
||||
268, 277, 283, 295, 298, 301, 307, 311, 315, 321,
|
||||
325, 343, 349, 355, 359, 364, 368, 375, 383, 386,
|
||||
389, 392, 395, 398, 401, 404, 407, 410, 413, 416,
|
||||
419, 422, 425, 428, 431, 434, 437, 442, 476, 480
|
||||
231, 232, 235, 238, 241, 244, 247, 250, 253, 259,
|
||||
265, 274, 280, 292, 295, 298, 304, 308, 312, 318,
|
||||
322, 340, 346, 352, 356, 361, 365, 372, 380, 383,
|
||||
386, 389, 392, 395, 398, 401, 404, 407, 410, 413,
|
||||
416, 419, 422, 425, 428, 431, 434, 439, 473, 477
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -943,37 +940,37 @@ yyreduce:
|
||||
switch (yyn) {
|
||||
|
||||
case 3:
|
||||
#line 238 "getdate.y"
|
||||
#line 235 "getdate.y"
|
||||
{
|
||||
context->yyHaveTime++;
|
||||
;
|
||||
break;}
|
||||
case 4:
|
||||
#line 241 "getdate.y"
|
||||
#line 238 "getdate.y"
|
||||
{
|
||||
context->yyHaveZone++;
|
||||
;
|
||||
break;}
|
||||
case 5:
|
||||
#line 244 "getdate.y"
|
||||
#line 241 "getdate.y"
|
||||
{
|
||||
context->yyHaveDate++;
|
||||
;
|
||||
break;}
|
||||
case 6:
|
||||
#line 247 "getdate.y"
|
||||
#line 244 "getdate.y"
|
||||
{
|
||||
context->yyHaveDay++;
|
||||
;
|
||||
break;}
|
||||
case 7:
|
||||
#line 250 "getdate.y"
|
||||
#line 247 "getdate.y"
|
||||
{
|
||||
context->yyHaveRel++;
|
||||
;
|
||||
break;}
|
||||
case 9:
|
||||
#line 256 "getdate.y"
|
||||
#line 253 "getdate.y"
|
||||
{
|
||||
context->yyHour = yyvsp[-1].Number;
|
||||
context->yyMinutes = 0;
|
||||
@@ -982,7 +979,7 @@ case 9:
|
||||
;
|
||||
break;}
|
||||
case 10:
|
||||
#line 262 "getdate.y"
|
||||
#line 259 "getdate.y"
|
||||
{
|
||||
context->yyHour = yyvsp[-3].Number;
|
||||
context->yyMinutes = yyvsp[-1].Number;
|
||||
@@ -991,7 +988,7 @@ case 10:
|
||||
;
|
||||
break;}
|
||||
case 11:
|
||||
#line 268 "getdate.y"
|
||||
#line 265 "getdate.y"
|
||||
{
|
||||
context->yyHour = yyvsp[-3].Number;
|
||||
context->yyMinutes = yyvsp[-1].Number;
|
||||
@@ -1003,7 +1000,7 @@ case 11:
|
||||
;
|
||||
break;}
|
||||
case 12:
|
||||
#line 277 "getdate.y"
|
||||
#line 274 "getdate.y"
|
||||
{
|
||||
context->yyHour = yyvsp[-5].Number;
|
||||
context->yyMinutes = yyvsp[-3].Number;
|
||||
@@ -1012,7 +1009,7 @@ case 12:
|
||||
;
|
||||
break;}
|
||||
case 13:
|
||||
#line 283 "getdate.y"
|
||||
#line 280 "getdate.y"
|
||||
{
|
||||
context->yyHour = yyvsp[-5].Number;
|
||||
context->yyMinutes = yyvsp[-3].Number;
|
||||
@@ -1025,53 +1022,53 @@ case 13:
|
||||
;
|
||||
break;}
|
||||
case 14:
|
||||
#line 295 "getdate.y"
|
||||
#line 292 "getdate.y"
|
||||
{
|
||||
context->yyTimezone = yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 15:
|
||||
#line 298 "getdate.y"
|
||||
#line 295 "getdate.y"
|
||||
{
|
||||
context->yyTimezone = yyvsp[0].Number - 60;
|
||||
;
|
||||
break;}
|
||||
case 16:
|
||||
#line 302 "getdate.y"
|
||||
#line 299 "getdate.y"
|
||||
{
|
||||
context->yyTimezone = yyvsp[-1].Number - 60;
|
||||
;
|
||||
break;}
|
||||
case 17:
|
||||
#line 307 "getdate.y"
|
||||
#line 304 "getdate.y"
|
||||
{
|
||||
context->yyDayOrdinal = 1;
|
||||
context->yyDayNumber = yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 18:
|
||||
#line 311 "getdate.y"
|
||||
#line 308 "getdate.y"
|
||||
{
|
||||
context->yyDayOrdinal = 1;
|
||||
context->yyDayNumber = yyvsp[-1].Number;
|
||||
;
|
||||
break;}
|
||||
case 19:
|
||||
#line 315 "getdate.y"
|
||||
#line 312 "getdate.y"
|
||||
{
|
||||
context->yyDayOrdinal = yyvsp[-1].Number;
|
||||
context->yyDayNumber = yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 20:
|
||||
#line 321 "getdate.y"
|
||||
#line 318 "getdate.y"
|
||||
{
|
||||
context->yyMonth = yyvsp[-2].Number;
|
||||
context->yyDay = yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 21:
|
||||
#line 325 "getdate.y"
|
||||
#line 322 "getdate.y"
|
||||
{
|
||||
/* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
|
||||
The goal in recognizing YYYY/MM/DD is solely to support legacy
|
||||
@@ -1092,7 +1089,7 @@ case 21:
|
||||
;
|
||||
break;}
|
||||
case 22:
|
||||
#line 343 "getdate.y"
|
||||
#line 340 "getdate.y"
|
||||
{
|
||||
/* ISO 8601 format. yyyy-mm-dd. */
|
||||
context->yyYear = yyvsp[-2].Number;
|
||||
@@ -1101,7 +1098,7 @@ case 22:
|
||||
;
|
||||
break;}
|
||||
case 23:
|
||||
#line 349 "getdate.y"
|
||||
#line 346 "getdate.y"
|
||||
{
|
||||
/* e.g. 17-JUN-1992. */
|
||||
context->yyDay = yyvsp[-2].Number;
|
||||
@@ -1110,14 +1107,14 @@ case 23:
|
||||
;
|
||||
break;}
|
||||
case 24:
|
||||
#line 355 "getdate.y"
|
||||
#line 352 "getdate.y"
|
||||
{
|
||||
context->yyMonth = yyvsp[-1].Number;
|
||||
context->yyDay = yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 25:
|
||||
#line 359 "getdate.y"
|
||||
#line 356 "getdate.y"
|
||||
{
|
||||
context->yyMonth = yyvsp[-3].Number;
|
||||
context->yyDay = yyvsp[-2].Number;
|
||||
@@ -1125,14 +1122,14 @@ case 25:
|
||||
;
|
||||
break;}
|
||||
case 26:
|
||||
#line 364 "getdate.y"
|
||||
#line 361 "getdate.y"
|
||||
{
|
||||
context->yyMonth = yyvsp[0].Number;
|
||||
context->yyDay = yyvsp[-1].Number;
|
||||
;
|
||||
break;}
|
||||
case 27:
|
||||
#line 368 "getdate.y"
|
||||
#line 365 "getdate.y"
|
||||
{
|
||||
context->yyMonth = yyvsp[-1].Number;
|
||||
context->yyDay = yyvsp[-2].Number;
|
||||
@@ -1140,7 +1137,7 @@ case 27:
|
||||
;
|
||||
break;}
|
||||
case 28:
|
||||
#line 375 "getdate.y"
|
||||
#line 372 "getdate.y"
|
||||
{
|
||||
context->yyRelSeconds = -context->yyRelSeconds;
|
||||
context->yyRelMinutes = -context->yyRelMinutes;
|
||||
@@ -1151,115 +1148,115 @@ case 28:
|
||||
;
|
||||
break;}
|
||||
case 30:
|
||||
#line 386 "getdate.y"
|
||||
#line 383 "getdate.y"
|
||||
{
|
||||
context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 31:
|
||||
#line 389 "getdate.y"
|
||||
#line 386 "getdate.y"
|
||||
{
|
||||
context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 32:
|
||||
#line 392 "getdate.y"
|
||||
#line 389 "getdate.y"
|
||||
{
|
||||
context->yyRelYear += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 33:
|
||||
#line 395 "getdate.y"
|
||||
#line 392 "getdate.y"
|
||||
{
|
||||
context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 34:
|
||||
#line 398 "getdate.y"
|
||||
#line 395 "getdate.y"
|
||||
{
|
||||
context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 35:
|
||||
#line 401 "getdate.y"
|
||||
#line 398 "getdate.y"
|
||||
{
|
||||
context->yyRelMonth += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 36:
|
||||
#line 404 "getdate.y"
|
||||
#line 401 "getdate.y"
|
||||
{
|
||||
context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 37:
|
||||
#line 407 "getdate.y"
|
||||
#line 404 "getdate.y"
|
||||
{
|
||||
context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 38:
|
||||
#line 410 "getdate.y"
|
||||
#line 407 "getdate.y"
|
||||
{
|
||||
context->yyRelDay += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 39:
|
||||
#line 413 "getdate.y"
|
||||
#line 410 "getdate.y"
|
||||
{
|
||||
context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 40:
|
||||
#line 416 "getdate.y"
|
||||
#line 413 "getdate.y"
|
||||
{
|
||||
context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 41:
|
||||
#line 419 "getdate.y"
|
||||
#line 416 "getdate.y"
|
||||
{
|
||||
context->yyRelHour += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 42:
|
||||
#line 422 "getdate.y"
|
||||
#line 419 "getdate.y"
|
||||
{
|
||||
context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 43:
|
||||
#line 425 "getdate.y"
|
||||
#line 422 "getdate.y"
|
||||
{
|
||||
context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 44:
|
||||
#line 428 "getdate.y"
|
||||
#line 425 "getdate.y"
|
||||
{
|
||||
context->yyRelMinutes += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 45:
|
||||
#line 431 "getdate.y"
|
||||
#line 428 "getdate.y"
|
||||
{
|
||||
context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 46:
|
||||
#line 434 "getdate.y"
|
||||
#line 431 "getdate.y"
|
||||
{
|
||||
context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 47:
|
||||
#line 437 "getdate.y"
|
||||
#line 434 "getdate.y"
|
||||
{
|
||||
context->yyRelSeconds += yyvsp[0].Number;
|
||||
;
|
||||
break;}
|
||||
case 48:
|
||||
#line 443 "getdate.y"
|
||||
#line 440 "getdate.y"
|
||||
{
|
||||
if (context->yyHaveTime && context->yyHaveDate &&
|
||||
!context->yyHaveRel)
|
||||
@@ -1293,13 +1290,13 @@ case 48:
|
||||
;
|
||||
break;}
|
||||
case 49:
|
||||
#line 477 "getdate.y"
|
||||
#line 474 "getdate.y"
|
||||
{
|
||||
yyval.Meridian = MER24;
|
||||
;
|
||||
break;}
|
||||
case 50:
|
||||
#line 481 "getdate.y"
|
||||
#line 478 "getdate.y"
|
||||
{
|
||||
yyval.Meridian = yyvsp[0].Meridian;
|
||||
;
|
||||
@@ -1526,7 +1523,7 @@ yyerrhandle:
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#line 486 "getdate.y"
|
||||
#line 483 "getdate.y"
|
||||
|
||||
|
||||
/* Include this file down here because bison inserts code above which
|
||||
|
@@ -7,9 +7,7 @@
|
||||
** This code is in the public domain and has no copyright.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
# include "setup.h"
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
|
@@ -10,8 +10,6 @@
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# endif
|
||||
@@ -19,7 +17,6 @@
|
||||
# ifdef HAVE_TIME_H
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef YYDEBUG
|
||||
/* to satisfy gcc -Wundef, we set this to 0 */
|
||||
|
@@ -31,6 +31,10 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef VMS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is supposed to be called in the beginning of a permform() session
|
||||
* and should reset all session-info variables
|
||||
@@ -44,6 +48,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
|
||||
pro->t_connect = 0;
|
||||
pro->t_pretransfer = 0;
|
||||
pro->t_starttransfer = 0;
|
||||
pro->timespent = 0;
|
||||
|
||||
info->httpcode = 0;
|
||||
info->httpversion=0;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2001, Daniel Stenberg, <daniel@haxx.se>, et al
|
||||
* Copyright (C) 2002, Daniel Stenberg, <daniel@haxx.se>, et al
|
||||
*
|
||||
* In order to be useful for every potential user, curl and libcurl are
|
||||
* dual-licensed under the MPL and the MIT/X-derivate licenses.
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "setup.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hash.h"
|
||||
#include "llist.h"
|
||||
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <stdlib.h> /* required for free() prototypes */
|
||||
#endif
|
||||
#ifdef VMS
|
||||
#include <in.h>
|
||||
#include <inet.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@@ -292,7 +293,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
|
||||
char sbuf[NI_MAXSERV];
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
hints.ai_family = PF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
snprintf(sbuf, sizeof(sbuf), "%d", port);
|
||||
@@ -409,7 +410,7 @@ static char *MakeIP(unsigned long num,char *addr, int addr_len)
|
||||
considerably. */
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (unsigned long) ~0
|
||||
#define INADDR_NONE (in_addr_t) ~0
|
||||
#endif
|
||||
|
||||
Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
|
||||
@@ -510,7 +511,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
|
||||
/* we make a copy of the hostent right now, right here, as the
|
||||
static one we got a pointer to might get removed when we don't
|
||||
want/expect that */
|
||||
h = pack_hostent(buf, h);
|
||||
h = pack_hostent((char *)buf, h);
|
||||
#endif
|
||||
}
|
||||
return (h);
|
||||
|
23
lib/http.c
23
lib/http.c
@@ -151,7 +151,7 @@ CURLcode add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in,
|
||||
break;
|
||||
|
||||
if(amount != size) {
|
||||
size += amount;
|
||||
size -= amount;
|
||||
ptr += amount;
|
||||
}
|
||||
else
|
||||
@@ -815,8 +815,6 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
}
|
||||
|
||||
if(HTTPREQ_POST_FORM == data->set.httpreq) {
|
||||
char contentType[256];
|
||||
int linelength=0;
|
||||
if(Curl_FormInit(&http->form, http->sendit)) {
|
||||
failf(data, "Internal HTTP POST error!");
|
||||
return CURLE_HTTP_POST_ERROR;
|
||||
@@ -831,7 +829,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
data->set.in = (FILE *)&http->form;
|
||||
|
||||
add_bufferf(req_buffer,
|
||||
"Content-Length: %d\r\n", http->postsize-2);
|
||||
"Content-Length: %d\r\n", http->postsize);
|
||||
|
||||
if(!checkheaders(data, "Expect:")) {
|
||||
/* if not disabled explicitly we add a Expect: 100-continue
|
||||
@@ -840,10 +838,19 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
add_bufferf(req_buffer,
|
||||
"Expect: 100-continue\r\n");
|
||||
data->set.expect100header = TRUE;
|
||||
}
|
||||
|
||||
if(!checkheaders(data, "Content-Type:")) {
|
||||
/* Get Content-Type: line from Curl_FormReadOneLine, which happens
|
||||
to always be the first line. We can know this for sure since
|
||||
we always build the formpost linked list the same way! */
|
||||
we always build the formpost linked list the same way!
|
||||
|
||||
The Content-Type header line also contains the MIME boundary
|
||||
string etc why disabling this header is likely to not make things
|
||||
work, but we support it anyway.
|
||||
*/
|
||||
char contentType[256];
|
||||
int linelength=0;
|
||||
linelength = Curl_FormReadOneLine (contentType,
|
||||
sizeof(contentType),
|
||||
1,
|
||||
@@ -853,11 +860,11 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
return CURLE_HTTP_POST_ERROR;
|
||||
}
|
||||
add_buffer(req_buffer, contentType, linelength);
|
||||
|
||||
/* make the request end in a true CRLF */
|
||||
add_buffer(req_buffer, "\r\n", 2);
|
||||
}
|
||||
|
||||
/* make the request end in a true CRLF */
|
||||
add_buffer(req_buffer, "\r\n", 2);
|
||||
|
||||
/* set upload size to the progress meter */
|
||||
Curl_pgrsSetUploadSize(data, http->postsize);
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2001, Daniel Stenberg, <daniel@haxx.se>, et al
|
||||
* Copyright (C) 2002, Daniel Stenberg, <daniel@haxx.se>, et al
|
||||
*
|
||||
* In order to be useful for every potential user, curl and libcurl are
|
||||
* dual-licensed under the MPL and the MIT/X-derivate licenses.
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "llist.h"
|
||||
|
||||
|
@@ -168,7 +168,10 @@ int curl_fclose(FILE *file, int line, const char *source)
|
||||
source, line, file);
|
||||
return res;
|
||||
}
|
||||
|
||||
#else
|
||||
#ifdef VMS
|
||||
int VOID_VAR_MEMDEBUG;
|
||||
#endif
|
||||
#endif /* MALLOCDEBUG */
|
||||
|
||||
/*
|
||||
|
@@ -699,9 +699,8 @@ static int dprintf_formatf(
|
||||
#if SIZEOF_LONG_LONG
|
||||
if(p->flags & FLAGS_LONGLONG) {
|
||||
/* long long */
|
||||
num = p->data.lnum;
|
||||
is_neg = num < 0;
|
||||
num = is_neg ? (- num) : num;
|
||||
is_neg = p->data.lnum < 0;
|
||||
num = is_neg ? (- p->data.lnum) : p->data.lnum;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@@ -44,12 +44,16 @@
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
Example source using this interface: http://curl.haxx.se/dev/multi-app.c
|
||||
Example sources using this interface is here: ../multi/
|
||||
|
||||
*/
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK_H
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
typedef void CURLM;
|
||||
|
@@ -310,7 +310,7 @@ int Curl_read(struct connectdata *conn,
|
||||
do {
|
||||
nread = SSL_read(conn->ssl.handle, buf, buffersize);
|
||||
|
||||
if(nread > 0)
|
||||
if(nread >= 0)
|
||||
/* successful read */
|
||||
break;
|
||||
|
||||
|
13
lib/setup.h
13
lib/setup.h
@@ -34,19 +34,19 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
#ifdef VMS
|
||||
#include "../config-vms.h"
|
||||
#include "config-vms.h"
|
||||
#else
|
||||
#include "../config.h" /* the configure script results */
|
||||
#include "config.h" /* the configure script results */
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifdef WIN32
|
||||
/* hand-modified win32 config.h! */
|
||||
#include "../config-win32.h"
|
||||
#include "config-win32.h"
|
||||
#endif
|
||||
#ifdef macintosh
|
||||
/* hand-modified MacOS config.h! */
|
||||
#include "../config-mac.h"
|
||||
#include "config-mac.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -94,11 +94,12 @@ defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
|
||||
#ifdef VMS
|
||||
#include "../include/curl/stdcheaders.h"
|
||||
#else
|
||||
#include "curl/stdcheaders.h"
|
||||
#include <curl/stdcheaders.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifdef _AIX
|
||||
#include "curl/stdcheaders.h"
|
||||
#include <curl/stdcheaders.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@@ -380,6 +380,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
/* we make sure that this socket isn't read more now */
|
||||
k->keepon &= ~KEEP_READ;
|
||||
FD_ZERO(&k->rkeepfd);
|
||||
/* for a progress meter/info update before going away */
|
||||
Curl_pgrsUpdate(conn);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
@@ -478,7 +480,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
start++);
|
||||
|
||||
/* count all non-space letters following */
|
||||
for(end=start+1, len=0;
|
||||
for(end=start, len=0;
|
||||
*end && !isspace((int)*end);
|
||||
end++, len++);
|
||||
|
||||
|
@@ -1984,6 +1984,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
||||
|
||||
/* we need these pointers if we speak over a proxy */
|
||||
conn->hostname = old_conn->gname;
|
||||
conn->name = old_conn->name;
|
||||
|
||||
free(conn->path); /* free the previously allocated path pointer */
|
||||
|
||||
|
@@ -13,6 +13,7 @@ bin_PROGRAMS = curl #memtest
|
||||
noinst_HEADERS = setup.h \
|
||||
config-win32.h \
|
||||
config-mac.h \
|
||||
config-vms.h \
|
||||
urlglob.h \
|
||||
version.h \
|
||||
writeout.h
|
||||
|
@@ -1,10 +1,13 @@
|
||||
########################################################
|
||||
## Makefile for building curl.exe with MSVC6
|
||||
## Use: nmake -f makefile.vc6 [release | debug]
|
||||
## Use: nmake -f makefile.vc6 [release | debug] [CFG=release-ssl]
|
||||
## (default is release)
|
||||
## "nmake -f makefile.vc6 CFG=release-ssl" statically links OpenSSL
|
||||
## into curl.exe producing a standalone SSL-enabled executable.
|
||||
##
|
||||
## Comments to: Troy Engel <tengel@sonic.net>
|
||||
## Updated by: Craig Davison <cd@securityfocus.com>
|
||||
## release-ssl added by Miklos Nemeth <mnemeth@kfkisystems.com>
|
||||
|
||||
PROGRAM_NAME = curl.exe
|
||||
|
||||
|
21
src/config-vms.h
Normal file
21
src/config-vms.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* src/config.h. Generated automatically by configure. */
|
||||
/* Define cpu-machine-OS */
|
||||
#define OS "ALPHA-COMPAQ-VMS"
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if you have the <io.h> header file. */
|
||||
#undef HAVE_IO_H
|
||||
|
||||
/* Define if you have strdup() */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have utime() */
|
||||
#undef HAVE_UTIME
|
||||
|
||||
/* Define if you have the <utime.h> header file */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Define if you have thhe <sys/utime.h> header file */
|
||||
#undef HAVE_SYS_UTIME_H
|
@@ -32,7 +32,11 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#ifdef VMS
|
||||
#include "config-vms.h"
|
||||
#else
|
||||
#include "config.h" /* the configure script results */
|
||||
#endif
|
||||
#else
|
||||
#ifdef WIN32
|
||||
/* include the hand-modified win32 adjusted config.h! */
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#define CURL_NAME "curl"
|
||||
#define CURL_VERSION "7.9.4"
|
||||
#define CURL_VERSION "7.9.5-pre1"
|
||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||
|
@@ -1,15 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
use Socket;
|
||||
use Carp;
|
||||
use FileHandle;
|
||||
#!/usr/bin/env perl
|
||||
|
||||
#use strict;
|
||||
|
||||
require "getpart.pm";
|
||||
|
||||
sub spawn; # forward declaration
|
||||
sub logmsg { #print "$0 $$: @_ at ", scalar localtime, "\n"
|
||||
}
|
||||
use strict;
|
||||
|
||||
my $verbose=0; # set to 1 for debugging
|
||||
|
||||
@@ -23,204 +14,4 @@ do {
|
||||
}
|
||||
} while(shift @ARGV);
|
||||
|
||||
my $proto = getprotobyname('tcp') || 6;
|
||||
|
||||
socket(Server, PF_INET, SOCK_STREAM, $proto)|| die "socket: $!";
|
||||
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
|
||||
pack("l", 1)) || die "setsockopt: $!";
|
||||
bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
|
||||
listen(Server,SOMAXCONN) || die "listen: $!";
|
||||
|
||||
if($verbose) {
|
||||
print "HTTP server started on port $port\n";
|
||||
}
|
||||
|
||||
open(PID, ">.http.pid");
|
||||
print PID $$;
|
||||
close(PID);
|
||||
|
||||
my $PID=$$;
|
||||
|
||||
my $waitedpid = 0;
|
||||
my $paddr;
|
||||
|
||||
sub REAPER {
|
||||
$waitedpid = wait;
|
||||
$SIG{CHLD} = \&REAPER; # loathe sysV
|
||||
logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
|
||||
}
|
||||
|
||||
sub performcmd {
|
||||
my @cmd = @_;
|
||||
for(@cmd) {
|
||||
if($_ =~ /^ *wait *(\d*)/) {
|
||||
# instructed to sleep!
|
||||
sleep($1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$SIG{CHLD} = \&REAPER;
|
||||
|
||||
for ( $waitedpid = 0;
|
||||
($paddr = accept(Client,Server)) || $waitedpid;
|
||||
$waitedpid = 0, close Client)
|
||||
{
|
||||
next if $waitedpid and not $paddr;
|
||||
my($port,$iaddr) = sockaddr_in($paddr);
|
||||
my $name = gethostbyaddr($iaddr,AF_INET);
|
||||
|
||||
logmsg "connection from $name [", inet_ntoa($iaddr), "] at port $port";
|
||||
|
||||
# this code is forked and run
|
||||
spawn sub {
|
||||
my ($request, $path, $ver, $left, $cl);
|
||||
|
||||
my @headers;
|
||||
|
||||
while(<STDIN>) {
|
||||
if($_ =~ /([A-Z]*) (.*) HTTP\/1.(\d)/) {
|
||||
$request=$1;
|
||||
$path=$2;
|
||||
$ver=$3;
|
||||
}
|
||||
elsif($_ =~ /^Content-Length: (\d*)/) {
|
||||
$cl=$1;
|
||||
}
|
||||
|
||||
if($verbose) {
|
||||
print STDERR "IN: $_";
|
||||
}
|
||||
|
||||
push @headers, $_;
|
||||
|
||||
if($left > 0) {
|
||||
$left -= length($_);
|
||||
if($left == 0) {
|
||||
$left = -1; # just to force a loop break here
|
||||
}
|
||||
}
|
||||
# print STDERR "RCV ($left): $_";
|
||||
|
||||
if(!$left &&
|
||||
($_ eq "\r\n") or ($_ eq "")) {
|
||||
if($request =~ /^(POST|PUT)$/) {
|
||||
$left=$cl;
|
||||
}
|
||||
elsif($request =~ /^CONNECT$/) {
|
||||
if($verbose) {
|
||||
print STDERR "We're emulating a SSL proxy!\n";
|
||||
}
|
||||
$left = -1;
|
||||
}
|
||||
else {
|
||||
$left = -1; # force abort
|
||||
}
|
||||
}
|
||||
if($left < 0) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if($request =~ /^CONNECT$/) {
|
||||
# ssl proxy mode
|
||||
print "HTTP/1.1 400 WE CANNOT ROOL NOW\r\n",
|
||||
"Server: bahoooba\r\n\r\n";
|
||||
exit;
|
||||
}
|
||||
elsif($path =~ /verifiedserver/) {
|
||||
# this is a hard-coded query-string for the test script
|
||||
# to verify that this is the server actually running!
|
||||
print "HTTP/1.1 999 WE ROOLZ: $PID\r\n";
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
|
||||
#
|
||||
# we always start the path with a number, this is the
|
||||
# test number that this server will use to know what
|
||||
# contents to pass back to the client
|
||||
#
|
||||
my $testnum;
|
||||
if($path =~ /.*\/(\d*)/) {
|
||||
$testnum=$1;
|
||||
}
|
||||
else {
|
||||
$testnum=0;
|
||||
}
|
||||
open(INPUT, ">>log/server.input");
|
||||
|
||||
binmode(INPUT,":raw"); # this makes it work better on cygwin
|
||||
|
||||
for(@headers) {
|
||||
print INPUT $_;
|
||||
}
|
||||
close(INPUT);
|
||||
|
||||
if(0 == $testnum ) {
|
||||
print "HTTP/1.1 200 OK\r\n",
|
||||
"header: yes\r\n",
|
||||
"\r\n",
|
||||
"You must enter a test number to get good data back\r\n";
|
||||
}
|
||||
else {
|
||||
my $part="";
|
||||
if($testnum > 10000) {
|
||||
$part = $testnum % 10000;
|
||||
$testnum = sprintf("%d", $testnum/10000);
|
||||
}
|
||||
if($verbose) {
|
||||
print STDERR "OUT: sending reply $testnum (part $part)\n";
|
||||
}
|
||||
|
||||
loadtest("data/test$testnum");
|
||||
|
||||
|
||||
my @cmd = getpart("reply", "cmd");
|
||||
performcmd(@cmd);
|
||||
|
||||
# flush data:
|
||||
$| = 1;
|
||||
|
||||
# send a custom reply to the client
|
||||
my @data = getpart("reply", "data$part");
|
||||
for(@data) {
|
||||
print $_;
|
||||
if($verbose) {
|
||||
print STDERR "OUT: $_";
|
||||
}
|
||||
}
|
||||
my @postcmd = getpart("reply", "postcmd");
|
||||
performcmd(@postcmd);
|
||||
}
|
||||
}
|
||||
# print "Hello there, $name, it's now ", scalar localtime, "\r\n";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
sub spawn {
|
||||
my $coderef = shift;
|
||||
|
||||
|
||||
unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
|
||||
confess "usage: spawn CODEREF";
|
||||
}
|
||||
|
||||
|
||||
my $pid;
|
||||
if (!defined($pid = fork)) {
|
||||
logmsg "cannot fork: $!";
|
||||
return;
|
||||
} elsif ($pid) {
|
||||
logmsg "begat $pid";
|
||||
return; # I'm the parent
|
||||
}
|
||||
# else I'm the child -- go spawn
|
||||
|
||||
|
||||
open(STDIN, "<&Client") || die "can't dup client to stdin";
|
||||
open(STDOUT, ">&Client") || die "can't dup client to stdout";
|
||||
## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
|
||||
exit &$coderef();
|
||||
}
|
||||
exec("server/sws $port");
|
||||
|
@@ -22,7 +22,7 @@ my $FTPSPORT=8821; # this is the FTPS server port
|
||||
my $CURL="../src/curl"; # what curl executable to run on the tests
|
||||
my $LOGDIR="log";
|
||||
my $TESTDIR="data";
|
||||
my $SERVERIN="$LOGDIR/server.input"; # what curl sent the server
|
||||
my $SERVERIN="$LOGDIR/http-request.dump"; # what curl sent the server
|
||||
my $CURLLOG="$LOGDIR/curl.log"; # all command lines run
|
||||
my $FTPDCMD="$LOGDIR/ftpserver.cmd"; # copy ftp server instructions here
|
||||
|
||||
@@ -852,14 +852,13 @@ print <<EOM
|
||||
*PLEASE* help us fixing this. We have to make our new test server written
|
||||
in C work and get used instead of the perl version previously used.
|
||||
|
||||
The working version of the test server is found here:
|
||||
The working version of the test server is found in the tests/server
|
||||
directory in the CVS tree.
|
||||
|
||||
http://curl.haxx.se/dev/sws-0.2.tar.gz
|
||||
|
||||
If you unpack this in the tests/ directory and run the server in there, you
|
||||
If you run this in the tests/ directory and run the server in there, you
|
||||
can actually get test-responses if you do like this:
|
||||
|
||||
\$ ./sws 8080 &
|
||||
\$ ./server/sws 8080 &
|
||||
\$ curl localhost:8080/3
|
||||
|
||||
EOM
|
||||
|
16
tests/server/Makefile
Normal file
16
tests/server/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
TARGET = sws
|
||||
OBJS= sws.o getpart.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
-rm -f $(OBJS) *~ $(TARGET) core logfile
|
||||
|
147
tests/server/getpart.c
Normal file
147
tests/server/getpart.c
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define EAT_SPACE(ptr) while( ptr && *ptr && isspace(*ptr) ) ptr++
|
||||
#define EAT_WORD(ptr) while( ptr && *ptr && !isspace(*ptr) && ('>' != *ptr)) ptr++
|
||||
|
||||
char *appendstring(char *string, /* original string */
|
||||
char *buffer, /* to append */
|
||||
int *stringlen, int *stralloc)
|
||||
{
|
||||
int len = strlen(buffer);
|
||||
|
||||
if((len + *stringlen) > *stralloc) {
|
||||
char *newptr= realloc(string, *stralloc*2);
|
||||
if(newptr) {
|
||||
string = newptr;
|
||||
*stralloc *= 2;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
strcpy(&string[*stringlen], buffer);
|
||||
*stringlen += len;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
char *spitout(FILE *stream, char *main, char *sub, int *size)
|
||||
{
|
||||
char buffer[8192]; /* big enough for anything */
|
||||
char cmain[128]=""; /* current main section */
|
||||
char csub[128]=""; /* current sub section */
|
||||
char *ptr;
|
||||
char *end;
|
||||
char display = 0;
|
||||
|
||||
char *string;
|
||||
int stringlen=0;
|
||||
int stralloc=256;
|
||||
int len;
|
||||
|
||||
enum {
|
||||
STATE_OUTSIDE,
|
||||
STATE_INMAIN,
|
||||
STATE_INSUB,
|
||||
STATE_ILLEGAL
|
||||
} state = STATE_OUTSIDE;
|
||||
|
||||
string = (char *)malloc(stralloc);
|
||||
|
||||
while(fgets(buffer, sizeof(buffer), stream)) {
|
||||
|
||||
ptr = buffer;
|
||||
|
||||
/* pass white spaces */
|
||||
EAT_SPACE(ptr);
|
||||
|
||||
if('<' != *ptr) {
|
||||
if(display) {
|
||||
printf("=> %s", buffer);
|
||||
string = appendstring(string, buffer, &stringlen, &stralloc);
|
||||
printf("* %s\n", buffer);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
EAT_SPACE(ptr);
|
||||
|
||||
if('/' == *ptr) {
|
||||
/* end of a section */
|
||||
ptr++;
|
||||
EAT_SPACE(ptr);
|
||||
|
||||
end = ptr;
|
||||
EAT_WORD(end);
|
||||
*end = 0;
|
||||
|
||||
if((state == STATE_INSUB) &&
|
||||
!strcmp(csub, ptr)) {
|
||||
/* this is the end of the currently read sub section */
|
||||
state--;
|
||||
csub[0]=0; /* no sub anymore */
|
||||
display=0;
|
||||
}
|
||||
else if((state == STATE_INMAIN) &&
|
||||
!strcmp(cmain, ptr)) {
|
||||
/* this is the end of the currently read main section */
|
||||
state--;
|
||||
cmain[0]=0; /* no main anymore */
|
||||
display=0;
|
||||
}
|
||||
}
|
||||
else if(!display) {
|
||||
/* this is the beginning of a section */
|
||||
end = ptr;
|
||||
EAT_WORD(end);
|
||||
|
||||
*end = 0;
|
||||
switch(state) {
|
||||
case STATE_OUTSIDE:
|
||||
strcpy(cmain, ptr);
|
||||
state = STATE_INMAIN;
|
||||
break;
|
||||
case STATE_INMAIN:
|
||||
strcpy(csub, ptr);
|
||||
state = STATE_INSUB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(display) {
|
||||
string = appendstring(string, buffer, &stringlen, &stralloc);
|
||||
printf("* %s\n", buffer);
|
||||
}
|
||||
|
||||
if((STATE_INSUB == state) &&
|
||||
!strcmp(cmain, main) &&
|
||||
!strcmp(csub, sub)) {
|
||||
printf("* (%d bytes) %s\n", stringlen, buffer);
|
||||
display = 1; /* start displaying */
|
||||
}
|
||||
else {
|
||||
printf("%d (%s/%s): %s\n", state, cmain, csub, buffer);
|
||||
display = 0; /* no display */
|
||||
}
|
||||
}
|
||||
|
||||
*size = stringlen;
|
||||
return string;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc< 3) {
|
||||
printf("./moo main sub\n");
|
||||
}
|
||||
else {
|
||||
int size;
|
||||
char *buffer = spitout(stdin, argv[1], argv[2], &size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
343
tests/server/sws.c
Normal file
343
tests/server/sws.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/* sws.c: simple (silly?) web server */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define DEFAULT_PORT 8999
|
||||
|
||||
#ifndef DEFAULT_LOGFILE
|
||||
#define DEFAULT_LOGFILE "/dev/null"
|
||||
#endif
|
||||
|
||||
#define DOCBUFSIZE 4
|
||||
#define BUFFERSIZE (DOCBUFSIZE * 1024)
|
||||
|
||||
#define VERSION "cURL test suite HTTP server/0.1"
|
||||
|
||||
#define REQUEST_DUMP "http-request.dump"
|
||||
|
||||
#define TEST_DATA_PATH "data/test%d"
|
||||
|
||||
static char *docfriends = "WE ROOLZ\r\n";
|
||||
static char *doc404 = "HTTP/1.1 404 Not Found\n"
|
||||
"Server: " VERSION "\n"
|
||||
"Connection: close\n"
|
||||
"Content-Type: text/html\n"
|
||||
"\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
|
||||
"<HTML><HEAD>\n"
|
||||
"<TITLE>404 Not Found</TITLE>\n"
|
||||
"</HEAD><BODY>\n"
|
||||
"<H1>Not Found</H1>\n"
|
||||
"The requested URL was not found on this server.\n"
|
||||
"<P><HR><ADDRESS>" VERSION "</ADDRESS>\n" "</BODY></HTML>\n";
|
||||
|
||||
static volatile int sigpipe, sigterm;
|
||||
static FILE *logfp;
|
||||
|
||||
|
||||
static void logmsg(const char *msg)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
struct tm *curr_time = localtime(&t);
|
||||
char loctime[80];
|
||||
|
||||
strcpy(loctime, asctime(curr_time));
|
||||
loctime[strlen(loctime) - 1] = '\0';
|
||||
fprintf(logfp, "%s: pid %d: %s\n", loctime, getpid(), msg);
|
||||
fprintf(stderr, "%s: pid %d: %s\n", loctime, getpid(), msg);
|
||||
fflush(logfp);
|
||||
}
|
||||
|
||||
|
||||
static void sigpipe_handler(int sig)
|
||||
{
|
||||
sigpipe = 1;
|
||||
}
|
||||
|
||||
|
||||
static void sigterm_handler(int sig)
|
||||
{
|
||||
char logbuf[100];
|
||||
snprintf(logbuf, 100, "Got signal %d, terminating", sig);
|
||||
logmsg(logbuf);
|
||||
sigterm = 1;
|
||||
}
|
||||
|
||||
int ProcessRequest(char *request)
|
||||
{
|
||||
char *line=request;
|
||||
long contentlength=-1;
|
||||
|
||||
#define END_OF_HEADERS "\r\n\r\n"
|
||||
|
||||
char *end;
|
||||
end = strstr(request, END_OF_HEADERS);
|
||||
|
||||
if(!end)
|
||||
/* we don't have a complete request yet! */
|
||||
return 0;
|
||||
|
||||
/* **** Persistancy ****
|
||||
*
|
||||
* If the request is a HTTP/1.0 one, we close the connection unconditionally
|
||||
* when we're done.
|
||||
*
|
||||
* If the request is a HTTP/1.1 one, we MUST check for a "Connection:"
|
||||
* header that might say "close". If it does, we close a connection when
|
||||
* this request is processed. Otherwise, we keep the connection alive for X
|
||||
* seconds.
|
||||
*/
|
||||
|
||||
do {
|
||||
if(!strncasecmp("Content-Length:", line, 15))
|
||||
contentlength = strtol(line+15, &line, 10);
|
||||
|
||||
line = strchr(line, '\n');
|
||||
if(line)
|
||||
line++;
|
||||
} while(line);
|
||||
|
||||
if(contentlength > -1 ) {
|
||||
if(contentlength <= strlen(end+strlen(END_OF_HEADERS)))
|
||||
return 1; /* done */
|
||||
else
|
||||
return 0; /* not complete yet */
|
||||
}
|
||||
return 1; /* done */
|
||||
}
|
||||
|
||||
/* store the entire request in a file */
|
||||
void storerequest(char *reqbuf)
|
||||
{
|
||||
FILE *dump;
|
||||
|
||||
dump = fopen(REQUEST_DUMP, "wb"); /* b is for windows-preparing */
|
||||
if(dump) {
|
||||
fwrite(reqbuf, 1, strlen(reqbuf), dump);
|
||||
|
||||
fclose(dump);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define REQBUFSIZ 4096
|
||||
#define MAXDOCNAMELEN 1024
|
||||
#define REQUEST_KEYWORD_SIZE 256
|
||||
static int get_request(int sock)
|
||||
{
|
||||
char reqbuf[REQBUFSIZ], doc[MAXDOCNAMELEN];
|
||||
char request[REQUEST_KEYWORD_SIZE];
|
||||
unsigned int offset = 0;
|
||||
int prot_major, prot_minor;
|
||||
|
||||
while (offset < REQBUFSIZ) {
|
||||
int got = recv(sock, reqbuf + offset, REQBUFSIZ - offset, 0);
|
||||
if (got <= 0) {
|
||||
if (got < 0) {
|
||||
perror("recv");
|
||||
return -1;
|
||||
}
|
||||
logmsg("Connection closed by client");
|
||||
return -1;
|
||||
}
|
||||
offset += got;
|
||||
|
||||
reqbuf[offset] = 0;
|
||||
|
||||
if(ProcessRequest(reqbuf))
|
||||
break;
|
||||
}
|
||||
|
||||
if (offset >= REQBUFSIZ) {
|
||||
logmsg("Request buffer overflow, closing connection");
|
||||
return -1;
|
||||
}
|
||||
reqbuf[offset]=0;
|
||||
|
||||
logmsg("Received a request");
|
||||
|
||||
/* dump the request to an external file */
|
||||
storerequest(reqbuf);
|
||||
|
||||
if (sscanf(reqbuf, "%s %s HTTP/%d.%d",
|
||||
request,
|
||||
doc,
|
||||
&prot_major,
|
||||
&prot_minor) == 4) {
|
||||
char *ptr;
|
||||
int test_no=0;
|
||||
|
||||
/* find the last slash */
|
||||
ptr = strrchr(doc, '/');
|
||||
|
||||
/* get the number after it */
|
||||
if(ptr) {
|
||||
if(!strcmp("/verifiedserver", ptr)) {
|
||||
logmsg("Are-we-friendly question received");
|
||||
return -2;
|
||||
}
|
||||
test_no = strtol(ptr+1, &ptr, 10);
|
||||
|
||||
logmsg("Found test number in PATH");
|
||||
}
|
||||
else {
|
||||
|
||||
logmsg("Did not find test number in PATH");
|
||||
}
|
||||
|
||||
return test_no;
|
||||
}
|
||||
|
||||
logmsg("Got illegal request");
|
||||
fprintf(stderr, "Got illegal request\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int send_doc(int sock, int doc)
|
||||
{
|
||||
int written;
|
||||
int count;
|
||||
char *buffer;
|
||||
char *ptr;
|
||||
FILE *stream;
|
||||
|
||||
char filename[256];
|
||||
|
||||
if(doc < 0) {
|
||||
if(-2 == doc)
|
||||
/* we got a "friends?" question, reply back that we sure are */
|
||||
buffer = docfriends;
|
||||
else
|
||||
buffer = doc404;
|
||||
ptr = NULL;
|
||||
stream=NULL;
|
||||
}
|
||||
else {
|
||||
sprintf(filename, TEST_DATA_PATH, doc);
|
||||
|
||||
stream=fopen(filename, "rb");
|
||||
if(!stream) {
|
||||
logmsg("Couldn't open test file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr = buffer = spitout(stream, "reply", "data", &count);
|
||||
}
|
||||
|
||||
do {
|
||||
written = send(sock, buffer, count, 0);
|
||||
if (written < 0) {
|
||||
fclose(stream);
|
||||
return -1;
|
||||
}
|
||||
count -= written;
|
||||
buffer += written;
|
||||
} while(count>0);
|
||||
|
||||
if(ptr)
|
||||
free(ptr);
|
||||
if(stream)
|
||||
fclose(stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct sockaddr_in me;
|
||||
int sock, msgsock, flag;
|
||||
unsigned short port = DEFAULT_PORT;
|
||||
char *logfile = DEFAULT_LOGFILE;
|
||||
|
||||
if(argc>1)
|
||||
port = atoi(argv[1]);
|
||||
|
||||
logfile = "logfile";
|
||||
|
||||
/* FIX: write our pid to a file name */
|
||||
|
||||
logfp = fopen(logfile, "a");
|
||||
if (!logfp) {
|
||||
perror(logfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
signal(SIGPIPE, sigpipe_handler);
|
||||
signal(SIGINT, sigterm_handler);
|
||||
signal(SIGTERM, sigterm_handler);
|
||||
|
||||
siginterrupt(SIGPIPE, 1);
|
||||
siginterrupt(SIGINT, 1);
|
||||
siginterrupt(SIGTERM, 1);
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
perror("opening stream socket");
|
||||
fprintf(logfp, "Error opening socket -- aborting\n");
|
||||
fclose(logfp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
flag = 1;
|
||||
if (setsockopt
|
||||
(sock, SOL_SOCKET, SO_REUSEADDR, (const void *) &flag,
|
||||
sizeof(int)) < 0) {
|
||||
perror("setsockopt(SO_REUSEADDR)");
|
||||
}
|
||||
|
||||
me.sin_family = AF_INET;
|
||||
me.sin_addr.s_addr = INADDR_ANY;
|
||||
me.sin_port = htons(port);
|
||||
if (bind(sock, (struct sockaddr *) &me, sizeof me) < 0) {
|
||||
perror("binding stream socket");
|
||||
fprintf(logfp, "Error binding socket -- aborting\n");
|
||||
fclose(logfp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* start accepting connections */
|
||||
listen(sock, 5);
|
||||
|
||||
printf("*** %s listening on port %u ***\n", VERSION, port);
|
||||
|
||||
while (!sigterm) {
|
||||
int doc;
|
||||
|
||||
msgsock = accept(sock, NULL, NULL);
|
||||
|
||||
if (msgsock == -1) {
|
||||
if (sigterm) {
|
||||
break;
|
||||
}
|
||||
/* perror("accept"); */
|
||||
continue;
|
||||
}
|
||||
|
||||
logmsg("New client connected");
|
||||
|
||||
doc = get_request(msgsock);
|
||||
send_doc(msgsock, doc);
|
||||
|
||||
close(msgsock);
|
||||
}
|
||||
|
||||
close(sock);
|
||||
fclose(logfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user