You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tsuyoshi SASAMOTO <na...@super.win.ne.jp> on 2005/04/15 17:01:16 UTC

[patch] http_protocol.c

1. RFC 2616 says "The response (= 205 Reset Content) MUST NOT include an entity",
   and "entity" would be "message body".
2. "<p />" shouldn't be used. (cf. http://www.w3.org/TR/xhtml1/#C3 )


Tsuyoshi SASAMOTO
nazonazo@super.win.ne.jp

--- httpd/trunk/modules/http/http_protocol.c	Sat Apr 16 00:00:00 2005
+++ httpd/trunk/modules/http/http_protocol.c	Sat Apr 16 00:00:00 2005
@@ -173,7 +173,7 @@
      *
      *   IF  we have not marked this connection as errored;
      *   and the response body has a defined length due to the status code
-     *       being 304 or 204, the request method being HEAD, already
+     *       being 204, 205 or 304, the request method being HEAD, already
      *       having defined Content-Length or Transfer-Encoding: chunked, or
      *       the request version being HTTP/1.1 and thus capable of being set
      *       as chunked [we know the (r->chunked = 1) side-effect is ugly];
@@ -194,6 +194,7 @@
     if ((r->connection->keepalive != AP_CONN_CLOSE)
         && ((r->status == HTTP_NOT_MODIFIED)
             || (r->status == HTTP_NO_CONTENT)
+            || (r->status == HTTP_RESET_CONTENT)
             || r->header_only
             || apr_table_get(r->headers_out, "Content-Length")
             || ap_find_last_token(r->pool,
@@ -1043,7 +1044,7 @@
                                           "error-notes")) != NULL)
             && (h1 = apr_table_get(r->notes, "verbose-error-to")) != NULL
             && (strcmp(h1, "*") == 0)) {
-            return(apr_pstrcat(p, error_notes, "<p />\n", NULL));
+            return(apr_pstrcat(p, "<p>", error_notes, "</p>\n", NULL));
         }
         else {
             return(apr_pstrcat(p,
@@ -1076,7 +1077,7 @@
          *
          * if ((error_notes = apr_table_get(r->notes,
          *                                  "error-notes")) != NULL) {
-         *     return(apr_pstrcat(p, error_notes, "<p />\n", NULL);
+         *     return(apr_pstrcat(p, "<p>", error_notes, "</p>\n", NULL));
          * }
          * else {
          *     return "";
@@ -1087,9 +1088,9 @@
 
 /* We should have named this send_canned_response, since it is used for any
  * response that can be generated by the server from the request record.
- * This includes all 204 (no content), 3xx (redirect), 4xx (client error),
- * and 5xx (server error) messages that have not been redirected to another
- * handler via the ErrorDocument feature.
+ * This includes all 204 (no content), 205 (reset content), 3xx (redirect),
+ * 4xx (client error), and 5xx (server error) messages that have not been
+ * redirected to another handler via the ErrorDocument feature.
  */
 AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error)
 {
@@ -1119,18 +1120,15 @@
     if (location == NULL) {
         location = apr_table_get(r->err_headers_out, "Location");
     }
-    /* We need to special-case the handling of 204 and 304 responses,
+    /* We need to special-case the handling of 204, 205 and 304 responses,
      * since they have specific HTTP requirements and do not include a
      * message body.  Note that being assbackwards here is not an option.
      */
-    if (status == HTTP_NOT_MODIFIED) {
+    if (status == HTTP_NOT_MODIFIED
+        || status == HTTP_NO_CONTENT
+        || status == HTTP_RESET_CONTENT) {
         ap_finalize_request_protocol(r);
         return;
-    }
-
-    if (status == HTTP_NO_CONTENT) {
-        ap_finalize_request_protocol(r);
-        return;
     }
 
     if (!r->assbackwards) {