diff -r d27e06e0e404 doc/wget.texi
--- a/doc/wget.texi	Tue Jul 22 13:33:42 2008 -0700
+++ b/doc/wget.texi	Sat Jul 26 13:40:34 2008 +0900
@@ -1397,6 +1397,13 @@
 some few obscure servers, which never send HTTP authentication
 challenges, but accept unsolicited auth info, say, in addition to
 form-based authentication.
+
+@cindex content-type
+@item --content-type @var{acclist}
+@itemx --content-type-exclude @var{rejlist}
+Specify comma-separated lists of content type patterns to
+accept or reject. This will be matched against the content-type header, if
+present.
 
 @end table
 
diff -r d27e06e0e404 src/http.c
--- a/src/http.c	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/http.c	Sat Jul 26 13:40:34 2008 +0900
@@ -2212,8 +2212,15 @@
             logputs (LOG_VERBOSE, "\n");
         }
     }
+  bool is_acceptable_content_type = true;
+  if (type) is_acceptable_content_type = acceptable_content_type (type);
   xfree_null (type);
   type = NULL;                        /* We don't need it any more.  */
+  if (!is_acceptable_content_type)
+    {
+        CLOSE_FINISH (sock);
+	return CTYPEREJECTED;
+    }
 
   /* Return if we have no intention of further downloading.  */
   if (!(*dt & RETROKF) || head_only)
@@ -2508,6 +2515,9 @@
              whether the number of tries was exceeded.  */
           printwhat (count, opt.ntry);
           continue;
+	case CTYPEREJECTED:
+	  ret = err;
+	  goto exit;
         case FWRITEERR: case FOPENERR:
           /* Another fatal error.  */
           logputs (LOG_VERBOSE, "\n");
diff -r d27e06e0e404 src/init.c
--- a/src/init.c	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/init.c	Sat Jul 26 13:40:34 2008 +0900
@@ -132,7 +132,9 @@
   { "checkcertificate", &opt.check_cert,        cmd_boolean },
 #endif
   { "connecttimeout",   &opt.connect_timeout,   cmd_time },
+  { "contentaccepts",   &opt.content_accepts,   cmd_vector },
   { "contentdisposition", &opt.content_disposition, cmd_boolean },
+  { "contentrejects",   &opt.content_rejects,   cmd_vector },
   { "continue",         &opt.always_rest,       cmd_boolean },
   { "convertlinks",     &opt.convert_links,     cmd_boolean },
   { "cookies",          &opt.cookies,           cmd_boolean },
@@ -1518,6 +1520,8 @@
   xfree_null (opt.output_document);
   free_vec (opt.accepts);
   free_vec (opt.rejects);
+  free_vec (opt.content_accepts);
+  free_vec (opt.content_rejects);
   free_vec (opt.excludes);
   free_vec (opt.includes);
   free_vec (opt.domains);
diff -r d27e06e0e404 src/main.c
--- a/src/main.c	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/main.c	Sat Jul 26 13:40:34 2008 +0900
@@ -160,6 +160,8 @@
     { "continue", 'c', OPT_BOOLEAN, "continue", -1 },
     { "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
     { "content-disposition", 0, OPT_BOOLEAN, "contentdisposition", -1 },
+    { "content-type", 0, OPT_VALUE, "contentaccepts", -1 },
+    { "content-type-exclude", 0, OPT_VALUE, "contentrejects", -1 },
     { "cookies", 0, OPT_BOOLEAN, "cookies", -1 },
     { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 },
     { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
@@ -548,6 +550,10 @@
     N_("\
        --content-disposition   honor the Content-Disposition header when\n\
                                choosing local file names (EXPERIMENTAL).\n"),
+    N_("\
+       --content-type=LIST     comma-separated list of accepted content-types.\n"),
+    N_("\
+       --content-type-exclude=LIST  comma-separated list of rejected content-types.\n"),
     N_("\
        --auth-no-challenge     Send Basic HTTP authentication information\n\
                                without first waiting for the server's\n\
@@ -1177,6 +1183,9 @@
       else
         status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt, opt.recursive);
 
+      if (status == CTYPEREJECTED)
+	  logprintf (LOG_VERBOSE, _("Not downloading, content type rejected.\n"));
+
       if (opt.delete_after && file_exists_p(filename))
         {
           DEBUGP (("Removing file due to --delete-after in main():\n"));
diff -r d27e06e0e404 src/options.h
--- a/src/options.h	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/options.h	Sat Jul 26 13:40:34 2008 +0900
@@ -60,6 +60,9 @@
   bool force_html;		/* Is the input file an HTML file? */
 
   bool spider;			/* Is Wget in spider mode? */
+
+  char **content_accepts;	/* List of content-type patterns to accept. */
+  char **content_rejects;	/* List of content-type patterns to reject. */
 
   char **accepts;		/* List of patterns to accept. */
   char **rejects;		/* List of patterns to reject. */
diff -r d27e06e0e404 src/recur.c
--- a/src/recur.c	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/recur.c	Sat Jul 26 13:40:34 2008 +0900
@@ -306,6 +306,9 @@
               url = redirected;
             }
         }
+
+      if (status == CTYPEREJECTED)
+	  logprintf (LOG_VERBOSE, _("Not downloading, content type rejected.\n"));
 
       if (opt.spider)
         {
diff -r d27e06e0e404 src/utils.c
--- a/src/utils.c	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/utils.c	Sat Jul 26 13:40:34 2008 +0900
@@ -715,6 +715,24 @@
     }
   else if (opt.rejects)
     return !in_acclist ((const char *const *)opt.rejects, s, true);
+  return true;
+}
+
+/* Determine whether a content type is acceptable to be downloaded, according to
+ * commandline options. */
+bool
+acceptable_content_type (const char *type)
+{
+  if (opt.content_accepts)
+    {
+      if (opt.content_rejects)
+	return (in_acclist ((const char *const *)opt.content_accepts, type, true)
+		&& !in_acclist ((const char *const *)opt.content_rejects, type, true));
+      else
+	return in_acclist ((const char *const *)opt.content_accepts, type, true);
+    }
+  else if (opt.content_rejects)
+    return !in_acclist ((const char *const *)opt.content_rejects, type, true);
   return true;
 }
 
diff -r d27e06e0e404 src/utils.h
--- a/src/utils.h	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/utils.h	Sat Jul 26 13:40:34 2008 +0900
@@ -93,6 +93,7 @@
 
 int fnmatch_nocase (const char *, const char *, int);
 bool acceptable (const char *);
+bool acceptable_content_type (const char *);
 bool accdir (const char *s);
 char *suffix (const char *s);
 bool match_tail (const char *, const char *, bool);
diff -r d27e06e0e404 src/wget.h
--- a/src/wget.h	Tue Jul 22 13:33:42 2008 -0700
+++ b/src/wget.h	Sat Jul 26 13:40:34 2008 +0900
@@ -342,7 +342,7 @@
   READERR, TRYLIMEXC, URLBADPATTERN, FILEBADFILE, RANGEERR, 
   RETRBADPATTERN, RETNOTSUP, ROBOTSOK, NOROBOTS, PROXERR, 
   /* 50  */
-  AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED
+  AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, CTYPEREJECTED
 } uerr_t;
 
 #endif /* WGET_H */
