Bump copyright
[privoxy.git] / parsers.c
index 6e66861..7056aba 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,11 +1,11 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.284 2014/02/10 14:42:42 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.287 2014/07/25 11:55:11 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
  *
  * Purpose     :  Declares functions to parse/crunch headers and pages.
  *
- * Copyright   :  Written by and Copyright (C) 2001-2012 the
+ * Copyright   :  Written by and Copyright (C) 2001-2014 the
  *                Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
@@ -116,6 +116,7 @@ static jb_err client_if_none_match      (struct client_state *csp, char **header
 static jb_err crunch_client_header      (struct client_state *csp, char **header);
 static jb_err client_x_filter           (struct client_state *csp, char **header);
 static jb_err client_range              (struct client_state *csp, char **header);
+static jb_err client_expect             (struct client_state *csp, char **header);
 static jb_err server_set_cookie         (struct client_state *csp, char **header);
 static jb_err server_connection         (struct client_state *csp, char **header);
 static jb_err server_content_type       (struct client_state *csp, char **header);
@@ -203,6 +204,7 @@ static const struct parsers client_patterns[] = {
 #if 0
    { "Transfer-Encoding:",       18,   client_transfer_encoding },
 #endif
+   { "Expect:",                   7,   client_expect },
    { "*",                         0,   crunch_client_header },
    { "*",                         0,   filter_header },
    { NULL,                        0,   NULL }
@@ -754,9 +756,6 @@ jb_err decompress_iob(struct client_state *csp)
  *                to a single space in accordance with RFC 2616 2.2.
  *                This simplifies parsing and filtering later on.
  *
- *                XXX: Remove log messages before
- *                     the next stable release?
- *
  * Parameters  :
  *          1  :  header = A header with linear white space to reduce.
  *
@@ -2009,6 +2008,40 @@ jb_err client_transfer_encoding(struct client_state *csp, char **header)
 }
 
 
+/*********************************************************************
+ *
+ * Function    :  client_expect
+ *
+ * Description :  Raise the CSP_FLAG_UNSUPPORTED_CLIENT_EXPECTATION
+ *                if the Expect header value is unsupported.
+ *
+ *                Rejecting unsupported expectations is a RFC 7231 5.1.1
+ *                MAY and a RFC 2616 (obsolete) MUST.
+ *
+ * Parameters  :
+ *          1  :  csp = Current client state (buffers, headers, etc...)
+ *          2  :  header = On input, pointer to header to modify.
+ *                On output, pointer to the modified header, or NULL
+ *                to remove the header.  This function frees the
+ *                original string if necessary.
+ *
+ * Returns     :  JB_ERR_OK on success, or
+ *
+ *********************************************************************/
+jb_err client_expect(struct client_state *csp, char **header)
+{
+   if (0 != strcmpic(*header, "Expect: 100-continue"))
+   {
+      csp->flags |= CSP_FLAG_UNSUPPORTED_CLIENT_EXPECTATION;
+      log_error(LOG_LEVEL_HEADER,
+         "Unsupported client expectaction: %s", *header);
+   }
+
+   return JB_ERR_OK;
+
+}
+
+
 /*********************************************************************
  *
  * Function    :  crumble