dovecot-2.2: lib-http: Updated comments to RFC7230/RFC7231.

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 1 21:12:00 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9511372c7c18
changeset: 17549:9511372c7c18
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Wed Jul 02 00:10:16 2014 +0300
description:
lib-http: Updated comments to RFC7230/RFC7231.

diffstat:

 src/lib-http/http-client-connection.c |   26 ++---
 src/lib-http/http-client-request.c    |   23 +++--
 src/lib-http/http-client.c            |    2 +-
 src/lib-http/http-date.c              |  128 +++++++++++++++-----------------
 src/lib-http/http-header-parser.c     |   16 ++-
 src/lib-http/http-message-parser.c    |  132 ++++++++++++++++++++-------------
 src/lib-http/http-parser.c            |    3 +-
 src/lib-http/http-parser.h            |    3 +-
 src/lib-http/http-request-parser.c    |   40 +++------
 src/lib-http/http-response-parser.c   |   47 ++++++-----
 src/lib-http/http-transfer-chunked.c  |   22 ++---
 src/lib-http/http-url.c               |   30 +++----
 12 files changed, 237 insertions(+), 235 deletions(-)

diffs (truncated from 908 to 300 lines):

diff -r 3e0e4dd7fb65 -r 9511372c7c18 src/lib-http/http-client-connection.c
--- a/src/lib-http/http-client-connection.c	Tue Jul 01 23:24:08 2014 +0300
+++ b/src/lib-http/http-client-connection.c	Wed Jul 02 00:10:16 2014 +0300
@@ -308,16 +308,14 @@
 	if (req->connect_tunnel)
 		conn->tunneling = TRUE;
 
-	/* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21;
-			Section 6.1.2.1:
+	/* RFC 7231, Section 5.1.1: Expect
 
-	   Because of the presence of older implementations, the protocol allows
-	   ambiguous situations in which a client might send "Expect: 100-continue"
-	   without receiving either a 417 (Expectation Failed) or a 100 (Continue)
-	   status code.  Therefore, when a client sends this header field to an
-	   origin server (possibly via a proxy) from which it has never seen a 100
-	   (Continue) status code, the client SHOULD NOT wait for an indefinite
-	   period before sending the payload body.
+		 o  A client that sends a 100-continue expectation is not required to
+		    wait for any specific length of time; such a client MAY proceed to
+		    send the message body even if it has not yet received a response.
+		    Furthermore, since 100 (Continue) responses cannot be sent through
+		    an HTTP/1.0 intermediary, such a client SHOULD NOT wait for an
+		    indefinite period before sending the message body.
 	 */
 	if (req->payload_sync && !conn->peer->seen_100_response) {
 		i_assert(req->payload_chunked || req->payload_size > 0);
@@ -551,13 +549,11 @@
 		if (conn->to_response != NULL)
 			timeout_remove(&conn->to_response);
 
-		/* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21
-		     Section 7.2:
+		/* RFC 7231, Section 6.2:
 
-		   A client MUST be prepared to accept one or more 1xx status responses
-		   prior to a regular response, even if the client does not expect a 100
-		   (Continue) status message.  Unexpected 1xx status responses MAY be
-		   ignored by a user agent.
+		   A client MUST be able to parse one or more 1xx responses received
+		   prior to a final response, even if the client does not expect one.  A
+		   user agent MAY ignore unexpected 1xx responses.
 		 */
 		if (req->payload_sync && response.status == 100) {
 			if (conn->payload_continue) {
diff -r 3e0e4dd7fb65 -r 9511372c7c18 src/lib-http/http-client-request.c
--- a/src/lib-http/http-client-request.c	Tue Jul 01 23:24:08 2014 +0300
+++ b/src/lib-http/http-client-request.c	Wed Jul 02 00:10:16 2014 +0300
@@ -350,16 +350,18 @@
 enum http_response_payload_type
 http_client_request_get_payload_type(struct http_client_request *req)
 {
-	/* https://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-23
-	     Section 3.3:
+	/* RFC 7230, Section 3.3:
 
-	   The presence of a message body in a response depends on both the
-	   request method to which it is responding and the response status code.
-	   Responses to the HEAD request method never include a message body
-	   because the associated response header fields, if present, indicate only
-	   what their values would have been if the request method had been GET
-	   2xx (Successful) responses to CONNECT switch to tunnel mode instead of
-	   having a message body (Section 4.3.6 of [Part2]).
+		 The presence of a message body in a response depends on both the
+		 request method to which it is responding and the response status code
+		 (Section 3.1.2 of [RFC7230]). Responses to the HEAD request method
+	   (Section 4.3.2 of [RFC7231]) never include a message body because the
+	   associated response header fields (e.g., Transfer-Encoding,
+	   Content-Length, etc.), if present, indicate only what their values
+	   would have been if the request method had been GET (Section 4.3.1 of
+	   [RFC7231]). 2xx (Successful) responses to a CONNECT request method
+	   (Section 4.3.6 of [RFC7231]) switch to tunnel mode instead of having a
+	   message body.
 	 */
 	if (strcmp(req->method, "HEAD") == 0)
 		return HTTP_RESPONSE_PAYLOAD_TYPE_NOT_PRESENT;
@@ -933,8 +935,7 @@
 	req->label = p_strdup_printf(req->pool, "[%s %s%s]",
 		req->method, origin_url, req->target);
 
-	/* https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21
-	      Section-7.4.4
+	/* RFC 7231, Section 6.4.4:
 	
 	   -> A 303 `See Other' redirect status response is handled a bit differently.
 	   Basically, the response content is located elsewhere, but the original
diff -r 3e0e4dd7fb65 -r 9511372c7c18 src/lib-http/http-client.c
--- a/src/lib-http/http-client.c	Tue Jul 01 23:24:08 2014 +0300
+++ b/src/lib-http/http-client.c	Wed Jul 02 00:10:16 2014 +0300
@@ -54,7 +54,7 @@
    http-client-connection:
 
    This is an actual connection to a server. Once a connection is ready to
-   handle requests, it claims a request from a host object. One connection can
+   handle requests, it claims a request from a queue object. One connection can
    service multiple hosts and one host can have multiple associated connections,
    possibly to different ips and ports.
 
diff -r 3e0e4dd7fb65 -r 9511372c7c18 src/lib-http/http-date.c
--- a/src/lib-http/http-date.c	Tue Jul 01 23:24:08 2014 +0300
+++ b/src/lib-http/http-date.c	Wed Jul 02 00:10:16 2014 +0300
@@ -7,75 +7,65 @@
 
 #include <ctype.h>
 
-/*
-	Official specification is still RFC261, Section 3.3, but we anticipate
-	HTTPbis and use the draft Part 2, Section 5.1 as reference for our
-	parser:
- 
-	http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-20#section-5.1
+/* RFC 7231, Section 7.1.1.1: Date/Time Formats	
 
 	The defined syntax is as follows:
 
-	 HTTP-date    = rfc1123-date / obs-date
+   HTTP-date    = IMF-fixdate / obs-date
 
 	Preferred format:
 
-	 rfc1123-date = day-name "," SP date1 SP time-of-day SP GMT
-	                ; fixed length subset of the format defined in
-	                ; Section 5.2.14 of [RFC1123]
-	 day-name     = %x4D.6F.6E ; "Mon", case-sensitive
-	              / %x54.75.65 ; "Tue", case-sensitive
-	              / %x57.65.64 ; "Wed", case-sensitive
-	              / %x54.68.75 ; "Thu", case-sensitive
-	              / %x46.72.69 ; "Fri", case-sensitive
-	              / %x53.61.74 ; "Sat", case-sensitive
-	              / %x53.75.6E ; "Sun", case-sensitive
-	 date1        = day SP month SP year
-	                ; e.g., 02 Jun 1982
-	 day          = 2DIGIT
-	 month        = %x4A.61.6E ; "Jan", case-sensitive
+   IMF-fixdate  = day-name "," SP date1 SP time-of-day SP GMT
+                ; fixed length/zone/capitalization subset of the format
+                ; see Section 3.3 of [RFC5322]
+   day-name     = %x4D.6F.6E ; "Mon", case-sensitive
+                / %x54.75.65 ; "Tue", case-sensitive
+                / %x57.65.64 ; "Wed", case-sensitive
+                / %x54.68.75 ; "Thu", case-sensitive
+                / %x46.72.69 ; "Fri", case-sensitive
+                / %x53.61.74 ; "Sat", case-sensitive
+                / %x53.75.6E ; "Sun", case-sensitive
+   date1        = day SP month SP year
+                ; e.g., 02 Jun 1982
+   day          = 2DIGIT
+   month        = %x4A.61.6E ; "Jan", case-sensitive
                 / %x46.65.62 ; "Feb", case-sensitive
-	              / %x4D.61.72 ; "Mar", case-sensitive
-	              / %x41.70.72 ; "Apr", case-sensitive
-	              / %x4D.61.79 ; "May", case-sensitive
-	              / %x4A.75.6E ; "Jun", case-sensitive
-	              / %x4A.75.6C ; "Jul", case-sensitive
-	              / %x41.75.67 ; "Aug", case-sensitive
-	              / %x53.65.70 ; "Sep", case-sensitive
-	              / %x4F.63.74 ; "Oct", case-sensitive
-	              / %x4E.6F.76 ; "Nov", case-sensitive
-	              / %x44.65.63 ; "Dec", case-sensitive
-	 year         = 4DIGIT
-	 GMT          = %x47.4D.54 ; "GMT", case-sensitive
-	 time-of-day  = hour ":" minute ":" second
-	 	              ; 00:00:00 - 23:59:59
-	 hour         = 2DIGIT
-	 minute       = 2DIGIT
-	 second       = 2DIGIT
-
-  The semantics of day-name, day, month, year, and time-of-day are the
-  same as those defined for the RFC 5322 constructs with the
-  corresponding name ([RFC5322], Section 3.3).
+                / %x4D.61.72 ; "Mar", case-sensitive
+                / %x41.70.72 ; "Apr", case-sensitive
+                / %x4D.61.79 ; "May", case-sensitive
+                / %x4A.75.6E ; "Jun", case-sensitive
+                / %x4A.75.6C ; "Jul", case-sensitive
+                / %x41.75.67 ; "Aug", case-sensitive
+                / %x53.65.70 ; "Sep", case-sensitive
+                / %x4F.63.74 ; "Oct", case-sensitive
+                / %x4E.6F.76 ; "Nov", case-sensitive
+                / %x44.65.63 ; "Dec", case-sensitive
+   year         = 4DIGIT
+   GMT          = %x47.4D.54 ; "GMT", case-sensitive
+   time-of-day  = hour ":" minute ":" second
+                ; 00:00:00 - 23:59:60 (leap second)
+   hour         = 2DIGIT
+   minute       = 2DIGIT
+   second       = 2DIGIT
 
   Obsolete formats:
 
-	 obs-date     = rfc850-date / asctime-date
+   obs-date     = rfc850-date / asctime-date
 
-	 rfc850-date  = day-name-l "," SP date2 SP time-of-day SP GMT
-	 date2        = day "-" month "-" 2DIGIT
-		              ; day-month-year (e.g., 02-Jun-82)
-	 day-name-l   = %x4D.6F.6E.64.61.79 ; "Monday", case-sensitive
-	              / %x54.75.65.73.64.61.79 ; "Tuesday", case-sensitive
-	              / %x57.65.64.6E.65.73.64.61.79 ; "Wednesday", case-sensitive
-	              / %x54.68.75.72.73.64.61.79 ; "Thursday", case-sensitive
-	              / %x46.72.69.64.61.79 ; "Friday", case-sensitive
-	              / %x53.61.74.75.72.64.61.79 ; "Saturday", case-sensitive
-	              / %x53.75.6E.64.61.79 ; "Sunday", case-sensitive
+   rfc850-date  = day-name-l "," SP date2 SP time-of-day SP GMT
+   date2        = day "-" month "-" 2DIGIT
+                ; e.g., 02-Jun-82
+   day-name-l   = %x4D.6F.6E.64.61.79    ; "Monday", case-sensitive
+                / %x54.75.65.73.64.61.79       ; "Tuesday", case-sensitive
+                / %x57.65.64.6E.65.73.64.61.79 ; "Wednesday", case-sensitive
+                / %x54.68.75.72.73.64.61.79    ; "Thursday", case-sensitive
+                / %x46.72.69.64.61.79          ; "Friday", case-sensitive
+                / %x53.61.74.75.72.64.61.79    ; "Saturday", case-sensitive
+                / %x53.75.6E.64.61.79          ; "Sunday", case-sensitive
 
-	 asctime-date = day-name SP date3 SP time-of-day SP year
-	 date3        = month SP ( 2DIGIT / ( SP 1DIGIT ))
-		              ; month day (e.g., Jun  2)
-
+   asctime-date = day-name SP date3 SP time-of-day SP year
+   date3        = month SP ( 2DIGIT / ( SP 1DIGIT ))
+                  ; e.g., Jun  2
  */
 
 static const char *month_names[] = {
@@ -257,14 +247,14 @@
 }
 
 static int
-http_date_parse_format_rfc1123(struct http_date_parser *parser)
+http_date_parse_format_imf_fixdate(struct http_date_parser *parser)
 {
 	/*
-	 rfc1123-date = day-name "," SP date1 SP time-of-day SP GMT
-	                ; fixed length subset of the format defined in
-	                ; Section 5.2.14 of [RFC1123]
+	 IMF-fixdate  = day-name "," SP date1 SP time-of-day SP GMT
+		            ; fixed length/zone/capitalization subset of the format
+		            ; see Section 3.3 of [RFC5322]
 	 date1        = day SP month SP year
-	                ; e.g., 02 Jun 1982
+	              ; e.g., 02 Jun 1982
 	 
 	 Remaining: 	 {...} SP day SP month SP year SP time-of-day SP GMT
 
@@ -390,10 +380,10 @@
 	int i;
 
 	/*
-	 HTTP-date    = rfc1123-date / obs-date
-	 rfc1123-date = day-name "," SP date1 SP time-of-day SP GMT
-	                ; fixed length subset of the format defined in
-	                ; Section 5.2.14 of [RFC1123]
+	 HTTP-date    = IMF-fixdate / obs-date
+	 IMF-fixdate  = day-name "," SP date1 SP time-of-day SP GMT
+		            ; fixed length/zone/capitalization subset of the format
+		            ; see Section 3.3 of [RFC5322]
 	 obs-date     = rfc850-date / asctime-date
 	 rfc850-date  = day-name-l "," SP date2 SP time-of-day SP GMT
 	 asctime-date = day-name SP date3 SP time-of-day SP year
@@ -414,7 +404,7 @@
 		return http_date_parse_format_rfc850(parser);
 	}
 
-	/* rfc1123-date / asctime-date */
+	/* IMF-fixdate / asctime-date */
 	for (i = 0; i < 7; i++) {
 		if (strcmp(weekday_names[i], str_c(dayname)) == 0) {
 			break;
@@ -433,9 +423,9 @@
 	if (parser->cur[0] != ',')
 		return -1;
 
-	/* rfc1123-date */
+	/* IMF-fixdate */
 	parser->cur++;
-	return http_date_parse_format_rfc1123(parser);
+	return http_date_parse_format_imf_fixdate(parser);
 }
 
 bool http_date_parse(const unsigned char *data, size_t size,
diff -r 3e0e4dd7fb65 -r 9511372c7c18 src/lib-http/http-header-parser.c
--- a/src/lib-http/http-header-parser.c	Tue Jul 01 23:24:08 2014 +0300
+++ b/src/lib-http/http-header-parser.c	Wed Jul 02 00:10:16 2014 +0300
@@ -120,7 +120,8 @@
 {
 	const unsigned char *first;
 
-	/* field-content  = *( HTAB / SP / VCHAR / obs-text )
+	/* field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
+	   field-vchar    = VCHAR / obs-text
 	 */
 	do {
 		first = parser->cur;
@@ -156,14 +157,19 @@
 {
 	int ret;
 
-	/* 'header'       = *( header-field CRLF ) CRLF
+	/* RFC 7230, Section 3.2: Header Fields
+


More information about the dovecot-cvs mailing list