diff options
author | Daniel Stenberg <daniel@haxx.se> | 2000-08-24 12:33:16 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2000-08-24 12:33:16 +0000 |
commit | 1b1f143cd65cb86138e3083790d89f959e3ecc87 (patch) | |
tree | 8f1f2128b6176c5f3019620af721747e13abb4d1 /lib | |
parent | 31b8eea0414bfb9188f6beea94ea72b26c33894f (diff) | |
download | curl-1b1f143cd65cb86138e3083790d89f959e3ecc87.tar.gz |
hostname and large file support added
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hostip.c | 2 | ||||
-rw-r--r-- | lib/http.c | 22 | ||||
-rw-r--r-- | lib/if2ip.c | 2 | ||||
-rw-r--r-- | lib/sendf.c | 20 | ||||
-rw-r--r-- | lib/sendf.h | 3 | ||||
-rw-r--r-- | lib/url.c | 3 | ||||
-rw-r--r-- | lib/urldata.h | 3 |
7 files changed, 43 insertions, 12 deletions
diff --git a/lib/hostip.c b/lib/hostip.c index fe8a7743f..ecfb59de3 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -69,7 +69,7 @@ #include "urldata.h" #include "sendf.h" -#ifndef HAVE_INET_NTOA_R_DECL +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) #include "inet_ntoa_r.h" #endif diff --git a/lib/http.c b/lib/http.c index 0632f6084..5e3f1b10c 100644 --- a/lib/http.c +++ b/lib/http.c @@ -38,12 +38,6 @@ * ------------------------------------------------------------ ****************************************************************************/ -#ifdef NEED_REENTRANT -#define _REENTRANT /* Necessary to use in Solaris, since the silly guys at Sun - made the localtime_r() prototype dependent on it (or - _POSIX_C_SOURCE or _POSIX_PTHREAD_SEMANTICS). */ -#endif - /* -- WIN32 approved -- */ #include <stdio.h> #include <string.h> @@ -57,6 +51,12 @@ #include "setup.h" +#ifdef NEED_REENTRANT +#define _REENTRANT /* Necessary to use in Solaris, since the silly guys at Sun + made the localtime_r() prototype dependent on it (or + _POSIX_C_SOURCE or _POSIX_PTHREAD_SEMANTICS). */ +#endif + #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) #include <winsock.h> #include <time.h> @@ -378,7 +378,7 @@ CURLcode http(struct connectdata *conn) #ifdef HAVE_LOCALTIME_R /* thread-safe version */ struct tm keeptime; - thistime = localtime_r(&data->timevalue, &keeptime); + thistime = (struct tm *)localtime_r(&data->timevalue, &keeptime); #else thistime = localtime(&data->timevalue); #endif @@ -492,13 +492,19 @@ CURLcode http(struct connectdata *conn) actually set your own */ sendf(data->firstsocket, data, "Content-Length: %d\r\n", - strlen(data->postfields)); + (data->postfieldsize?data->postfieldsize: + strlen(data->postfields)) ); if(!checkheaders(data, "Content-Type:")) sendf(data->firstsocket, data, "Content-Type: application/x-www-form-urlencoded\r\n"); /* and here comes the actual data */ + if(data->postfieldsize) { + ssend(data->firstsocket, data, "\r\n", 2); + ssend(data->firstsocket, data, data->postfields, data->postfieldsize); + ssend(data->firstsocket, data, "\r\n", 2); + } sendf(data->firstsocket, data, "\r\n" "%s\r\n", diff --git a/lib/if2ip.c b/lib/if2ip.c index ede5cf08c..25b2c40c2 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -82,7 +82,7 @@ #include <sys/sockio.h> #endif -#ifndef HAVE_INET_NTOA_R_DECL +#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL) #include "inet_ntoa_r.h" #endif diff --git a/lib/sendf.c b/lib/sendf.c index 87416775c..e048637be 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -84,7 +84,6 @@ void failf(struct UrlData *data, char *fmt, ...) } /* sendf() sends the formated data to the server */ - int sendf(int fd, struct UrlData *data, char *fmt, ...) { size_t bytes_written; @@ -110,6 +109,25 @@ int sendf(int fd, struct UrlData *data, char *fmt, ...) return(bytes_written); } +/* ssend() sends plain (binary) data to the server */ +size_t ssend(int fd, struct UrlData *data, void *mem, size_t len) +{ + size_t bytes_written; + + if(data->bits.verbose) + fprintf(data->err, "> [binary output]\n"); +#ifndef USE_SSLEAY + bytes_written = swrite(fd, mem, len); +#else + if (data->use_ssl) { + bytes_written = SSL_write(data->ssl, mem, len); + } else { + bytes_written = swrite(fd, mem, len); + } +#endif /* USE_SSLEAY */ + return bytes_written; +} + diff --git a/lib/sendf.h b/lib/sendf.h index c6c7bdb97..79eff1c40 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -40,7 +40,8 @@ * ------------------------------------------------------------ ****************************************************************************/ -int sendf(int fd, struct UrlData *, char *fmt, ...); +size_t sendf(int fd, struct UrlData *, char *fmt, ...); +size_t ssend(int fd, struct UrlData *, void *fmt, size_t len); void infof(struct UrlData *, char *fmt, ...); void failf(struct UrlData *, char *fmt, ...); @@ -421,6 +421,9 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...) case CURLOPT_POSTFIELDS: data->postfields = va_arg(param, char *); break; + case CURLOPT_POSTFIELDSIZE: + data->postfieldsize = va_arg(param, long); + break; case CURLOPT_REFERER: data->referer = va_arg(param, char *); data->bits.http_set_referer = (data->referer && *data->referer)?1:0; diff --git a/lib/urldata.h b/lib/urldata.h index 3d03bfce7..226237db2 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -345,6 +345,9 @@ struct UrlData { char *range; /* range, if used. See README for detailed specification on this syntax. */ char *postfields; /* if POST, set the fields' values here */ + long postfieldsize; /* if POST, this might have a size to use instead of + strlen(), and then the data *may* be binary (contain + zero bytes) */ bool free_referer; /* set TRUE if 'referer' points to a string we allocated */ |