RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: [EMAIL PROTECTED]
Module: rpm Date: 04-Jul-2008 21:06:17
Branch: HEAD Handle: 2008070419061601
Modified files:
rpm CHANGES
rpm/rpmio librpmio.vers rpmdav.c rpmdav.h rpmwget.c
Log:
- rpmdav: run OPTIONS once, repeat for every directory, through a URI.
- rpmdav: add global rpmioHttp{Accept,ReadTimeoutSecs,UserAgent} for now.
- rpmwget: wire up --spider to Stat(2) running HEAD.
Summary:
Revision Changes Path
1.2458 +3 -0 rpm/CHANGES
2.66 +3 -0 rpm/rpmio/librpmio.vers
2.76 +55 -22 rpm/rpmio/rpmdav.c
2.29 +9 -0 rpm/rpmio/rpmdav.h
1.10 +43 -15 rpm/rpmio/rpmwget.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2457 -r1.2458 CHANGES
--- rpm/CHANGES 3 Jul 2008 14:27:30 -0000 1.2457
+++ rpm/CHANGES 4 Jul 2008 19:06:16 -0000 1.2458
@@ -1,5 +1,8 @@
5.1.0 -> 5.2a0:
+ - jbj: rpmdav: run OPTIONS once, repeat for every directory, through a
URI.
+ - jbj: rpmdav: add global rpmioHttp{Accept,ReadTimeoutSecs,UserAgent}
for now.
+ - jbj: rpmwget: wire up --spider to Stat(2) running HEAD.
- rpm.org: single point to control how callbacks are made.
- rpm.org: Don't leak memory on python expandMacro().
- jbj: rpmgpg: stub in gpg options using popt.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/librpmio.vers
============================================================================
$ cvs diff -u -r2.65 -r2.66 librpmio.vers
--- rpm/rpmio/librpmio.vers 2 Jul 2008 15:42:26 -0000 2.65
+++ rpm/rpmio/librpmio.vers 4 Jul 2008 19:06:17 -0000 2.66
@@ -290,6 +290,9 @@
rpmioFini;
rpmioFtsOpts;
rpmioFtsPoptTable;
+ rpmioHttpAccept;
+ rpmioHttpReadTimeoutSecs;
+ rpmioHttpUserAgent;
rpmioInit;
rpmioMkpath;
rpmioPipeOutput;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmdav.c
============================================================================
$ cvs diff -u -r2.75 -r2.76 rpmdav.c
--- rpm/rpmio/rpmdav.c 3 Jul 2008 20:52:10 -0000 2.75
+++ rpm/rpmio/rpmdav.c 4 Jul 2008 19:06:17 -0000 2.76
@@ -51,7 +51,6 @@
/* XXX API changes for NEON 0.26 */
#if WITH_NEON_MIN_VERSION >= 0x002600
-#define ne_set_persist(_sess, _flag)
#define ne_propfind_set_private(_pfh, _create_item, NULL) \
ne_propfind_set_private(_pfh, _create_item, NULL, NULL)
#endif
@@ -69,21 +68,34 @@
#include "debug.h"
-/* Should http OPTIONS be run only once? */
-/* XXX TODO: determine precisely when OPTIONS need to be run. */
-int _dav_nooptions = 0;
-
/[EMAIL PROTECTED] DIR @*/
/[EMAIL PROTECTED] FD_t @*/
/[EMAIL PROTECTED] urlinfo @*/
-#if 0 /* HACK: reasonable value needed. */
+/* HACK: reasonable value needed (wget uses 900 as default). */
+#if 0
#define TIMEOUT_SECS 60
#else
#define TIMEOUT_SECS 5
#endif
+
+/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
+static const char _rpmioHttpUserAgent[] = PACKAGE "/" PACKAGE_VERSION;
+
+/[EMAIL PROTECTED]@*/
+static int rpmioHttpPersist = 1;
/[EMAIL PROTECTED]@*/
-static int httpTimeoutSecs = TIMEOUT_SECS;
+int rpmioHttpReadTimeoutSecs = TIMEOUT_SECS;
+#ifdef NOTYET
+int rpmioHttpRetries = 20;
+int rpmioHttpRecurseMax = 5;
+int rpmioHttpMaxRedirect = 20;
+#endif
+
+/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
+const char * rpmioHttpAccept;
+/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
+const char * rpmioHttpUserAgent;
/* =============================================================== */
void * avContextDestroy(avContext ctx)
@@ -556,15 +568,19 @@
if (!(u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS))
return 0;
- if (_dav_nooptions && u->allow & RPMURL_SERVER_OPTIONSDONE)
+ /* HACK: where should server capabilities be read? */
+ (void) urlPath(u->url, &path);
+
+ /* Run OPTIONS once, repeat for every directory. */
+ if (path != NULL && path[strlen(path)-1] == '/')
+ u->allow &= ~RPMURL_SERVER_OPTIONSDONE;
+ if (u->allow & RPMURL_SERVER_OPTIONSDONE)
return 0;
u->allow &= ~(RPMURL_SERVER_HASDAVCLASS1 |
RPMURL_SERVER_HASDAVCLASS2 |
RPMURL_SERVER_HASDAVEXEC);
- /* HACK: where should server capabilities be read? */
- (void) urlPath(u->url, &path);
/* HACK: perhaps capture Allow: tag, look for PUT permitted. */
/* XXX [hdr] Allow: GET,HEAD,POST,OPTIONS,TRACE */
rc = ne_options(u->sess, path, u->capabilities);
@@ -670,9 +686,14 @@
ne_set_status(u->sess, davNotify, u);
#endif
- ne_set_persist(u->sess, 1);
- ne_set_read_timeout(u->sess, httpTimeoutSecs);
- ne_set_useragent(u->sess, PACKAGE "/" PACKAGE_VERSION);
+#if WITH_NEON_MIN_VERSION >= 0x002600
+ ne_set_session_flag(u->sess, NE_SESSFLAG_PERSIST, rpmioHttpPersist);
+#else
+ ne_set_persist(u->sess, rpmioHttpPersist);
+#endif
+ ne_set_read_timeout(u->sess, rpmioHttpReadTimeoutSecs);
+ ne_set_useragent(u->sess,
+ (rpmioHttpUserAgent ? rpmioHttpUserAgent : _rpmioHttpUserAgent));
/* XXX check that neon is ssl enabled. */
if (!strcasecmp(u->scheme, "https"))
@@ -1039,6 +1060,7 @@
const char *htag;
const char *value = NULL;
int rc;
+int printing = 0;
/* XXX HACK: URI's with pesky trailing '/' are directories. */
{ size_t nb = strlen(u->url);
@@ -1051,6 +1073,10 @@
st->st_ctime = -1;
req = ne_request_create(u->sess, "HEAD", u->url);
+ if (rpmioHttpAccept != NULL)
+ ne_add_request_header(req, "Accept", rpmioHttpAccept);
+
+ /* XXX if !defined(HAVE_NEON_NE_GET_RESPONSE_HEADER) handlers? */
rc = ne_request_dispatch(req);
switch (rc) {
@@ -1065,6 +1091,7 @@
break;
}
+#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
#ifdef NOTYET
htag = "ETag";
value = ne_get_response_header(req, htag);
@@ -1074,10 +1101,13 @@
#endif
htag = "Content-Length";
-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
value = ne_get_response_header(req, htag);
-#endif
if (value) {
+printing++;
+/* XXX should wget's "... (1.2K)..." be added? */
+if (_dav_debug)
+fprintf(stderr, "Length: %s", value);
+
/[EMAIL PROTECTED]@*/ /* XXX LCLINT needs stdlib.h update. */
st->st_size = strtoll(value, NULL, 10);
/[EMAIL PROTECTED]@*/
@@ -1085,25 +1115,28 @@
}
htag = "Content-Type";
-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
value = ne_get_response_header(req, htag);
-#endif
if (value) {
+if (_dav_debug && printing++)
+fprintf(stderr, " [%s]", value);
if (!strcmp(value, "text/html")
|| !strcmp(value, "application/xhtml+xml"))
st->st_blksize = 2 * 1024;
}
-
htag = "Last-Modified";
-#if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER)
value = ne_get_response_header(req, htag);
-#endif
if (value) {
+if (_dav_debug && printing++)
+fprintf(stderr, " [%s]", value);
st->st_mtime = ne_httpdate_parse(value);
st->st_atime = st->st_ctime = st->st_mtime; /* HACK */
}
+if (_dav_debug && printing)
+fprintf(stderr, "\n");
+#endif
+
exit:
ne_request_destroy(req);
return rc;
@@ -1452,7 +1485,7 @@
fdSetIo(fd, ufdio);
fd->ftpFileDoneNeeded = 0;
- fd->rd_timeoutsecs = httpTimeoutSecs;
+ fd->rd_timeoutsecs = rpmioHttpReadTimeoutSecs;
fd->contentLength = fd->bytesRemain = -1;
assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType ==
URL_IS_HKP);
fd->urlType = urlType;
@@ -1834,7 +1867,7 @@
if (fd) {
fdSetIo(fd, ufdio);
fd->ftpFileDoneNeeded = 0;
- fd->rd_timeoutsecs = httpTimeoutSecs;
+ fd->rd_timeoutsecs = rpmioHttpReadTimeoutSecs;
fd->contentLength = fd->bytesRemain = -1;
fd->url = urlLink(u, "url (httpOpen)");
fd = fdLink(fd, "grab data (httpOpen)");
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmdav.h
============================================================================
$ cvs diff -u -r2.28 -r2.29 rpmdav.h
--- rpm/rpmio/rpmdav.h 19 Mar 2008 15:19:58 -0000 2.28
+++ rpm/rpmio/rpmdav.h 4 Jul 2008 19:06:17 -0000 2.29
@@ -7,6 +7,15 @@
#include <argv.h>
+/**
+*/
+/[EMAIL PROTECTED]@*/
+extern int rpmioHttpReadTimeoutSecs;
+/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
+extern const char * rpmioHttpAccept;
+/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
+extern const char * rpmioHttpUserAgent;
+
#if defined(_RPMDAV_INTERNAL)
struct __dirstream {
int fd; /* File descriptor. */
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmwget.c
============================================================================
$ cvs diff -u -r1.9 -r1.10 rpmwget.c
--- rpm/rpmio/rpmwget.c 2 Jul 2008 15:15:51 -0000 1.9
+++ rpm/rpmio/rpmwget.c 4 Jul 2008 19:06:17 -0000 1.10
@@ -1,6 +1,7 @@
#include "system.h"
#include <rpmio_internal.h>
+#include <rpmdav.h>
#include <poptIO.h>
#include "debug.h"
@@ -23,6 +24,7 @@
WGET_FLAGS_RESUME = _WFB( 2), /*!< --continue ... */
WGET_FLAGS_PROGRESS = _WFB( 3), /*!< --progress ... */
WGET_FLAGS_NEWERONLY = _WFB( 4), /*!< --timestamping ... */
+ WGET_FLAGS_NODOWNLOAD = _WFB( 5), /*!< --spider ... */
};
enum wgetRFlags_e {
@@ -59,7 +61,6 @@
enum rpmioWDLFlags_e {
WDL_FLAGS_NONE = 0,
WDL_FLAGS_SERVERRESPONSE = _WFB( 5), /*!< --server-response ... */
- WDL_FLAGS_SPIDER = _WFB( 6), /*!< --spider ... */
WDL_FLAGS_NOPROXY = _WFB( 7), /*!< --no-proxy ... */
WDL_FLAGS_NODNSCACHE = _WFB( 8), /*!< --no-dns-cache ... */
WDL_FLAGS_IGNORECASE = _WFB(10), /*!< --ignore-case ... */
@@ -341,18 +342,42 @@
struct stat * st = wget->st;
const char * contentType;
const char * contentDisposition;
- time_t lastModified;
- int rc = 1; /* assume failure */
+ time_t lastModified = 0;
+ int rc;
- /* Verify that input URI exists. */
- wget->ifd = Fopen(wget->ifn, "r.ufdio");
- if (wget->ifd == NULL || Ferror(wget->ifd)) {
+ /* Verify input URI exists, don't transfer content. */
+ if (WF_ISSET(NODOWNLOAD)) {
+if (wget->debug < 0) {
+fprintf(stderr, "Spider mode enabled. Check if remote file exists.\n");
+}
+if (wget->debug < 0) {
+#ifdef DYING /* XXX move to rpmio debugging? */
+char tstamp[32];
+static const char tfmt[] = "%Y-%m-%d %H:%M:%S";
+time_t now = time(NULL);
+struct tm * tm = localtime(&now);
+(void) strftime(tstamp, sizeof(tstamp), tfmt, tm);
+fprintf(stderr, "--%s-- %s\n", tstamp, wget->ifn);
+}
+ rc = Stat(wget->ifn, st);
+if (rc == 0) {
+#ifdef DYING /* XXX rely on rpmio debugging? */
+fprintf(stderr, "Length: %lu %s", (unsigned long)st->st_size,
ctime(&st->st_mtime));
+#endif
+fprintf(stderr, "Remote file exists.\n");
+} else {
+fprintf(stderr, "Remote file does not exist -- broken link!!!\n");
+}
+ goto exit;
+ }
+ /* Open input URI for content transfer. */
+ wget->ifd = Fopen(wget->ifn, "r.ufdio");
+ rc = (wget->ifd == NULL || Ferror(wget->ifd)) ? 1 : 0;
+ if (rc) {
#ifdef NOTYET
if (!WF_ISSET(RETRYCONN) && "connection refused")
- break;
#endif
-
goto exit;
}
@@ -395,8 +420,10 @@
fprintf(stderr, "--> wgetCopyFile(%p) %s => %s\n", wget, wget->ifn,
wget->ofn);
wget->ofd = Fopen(wget->ofn, "w.ufdio");
- if (wget->ofd == NULL || Ferror(wget->ofd))
+ if (wget->ofd == NULL || Ferror(wget->ofd)) {
+ rc = 1;
goto exit;
+ }
#ifdef NOTYET
/* Reposition I/O handles if resuming. */
@@ -421,8 +448,8 @@
#endif
}
- if (nr == 0)
- rc = 0;
+ /* OK iff EOF was read. */
+ rc = (nr != 0 ? 1 : 0);
exit:
@@ -653,7 +680,7 @@
N_("don't re-retrieve files unless newer than local."), NULL },
{ "server-response", 'S', POPT_BIT_SET, &rpmioWDLFlags,
WDL_FLAGS_SERVERRESPONSE,
N_("print server response."), NULL },
- { "spider", '\0', POPT_BIT_SET, &rpmioWDLFlags, WDL_FLAGS_SPIDER,
+ { "spider", '\0', POPT_BIT_SET, &__rpmwget.flags, WGET_FLAGS_NODOWNLOAD,
N_("don't download anything."), NULL },
{ "timeout", 'T', POPT_ARG_INT, &__rpmwget.timeout_secs, 0,
N_("set all timeout values to SECONDS."), N_("SECONDS") },
@@ -949,15 +976,16 @@
wget->b[0] = '\0';
wget->st = xmalloc(sizeof(*wget->st));
-#if 0
+rpmioHttpAccept = "*/*"; /* XXX wget compatible. */
if (wget->debug < 0) {
_av_debug = -1;
-_dav_debug = -1;
_ftp_debug = -1;
+_dav_debug = 1;
+#if 0
_url_debug = -1;
_rpmio_debug = -1;
-}
#endif
+}
optCon = rpmioInit(argc, argv, optionsTable);
if (wget->debug < 0) {
@@ .
______________________________________________________________________
RPM Package Manager http://rpm5.org
CVS Sources Repository [email protected]