httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject [PATCH] byterange handling with filters
Date Thu, 02 Nov 2000 23:26:44 GMT

I am pretty sure that this is incorrect, and that the correct solution is
a filter, but this is at least an attempt at getting byte-ranges working
with filters.  This is completely untested, so feel free to yell and
scream at me.  :-)

Ryan

? build.log
? build.err
? lib/pcre/pcre.h
Index: main/http_protocol.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
retrieving revision 1.221
diff -u -d -b -w -u -r1.221 http_protocol.c
--- main/http_protocol.c	2000/11/02 21:10:29	1.221
+++ main/http_protocol.c	2000/11/02 22:13:49
@@ -104,43 +104,6 @@
   } while (0)
 
 
-/* if this is the first error, then log an INFO message and shut down the
- * connection.
- */
-static void check_first_conn_error(const request_rec *r, const char *operation,
-                                   apr_status_t status)
-{
-    if (!r->connection->aborted) {
-        if (status == 0)
-            status = ap_berror(r->connection->client);
-        ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r,
-                      "client stopped connection before %s completed",
-                      operation);
-        r->connection->aborted = 1;
-    }
-}
-
-static int checked_bputstrs(request_rec *r, ...)
-{
-    va_list va;
-    int n;
-
-    if (r->connection->aborted)
-        return EOF;
-
-    va_start(va, r);
-    n = ap_vbputstrs(r->connection->client, va);
-    va_end(va);
-
-    if (n < 0) {
-        check_first_conn_error(r, "checked_bputstrs", 0);
-        return EOF;
-    }
-
-    SET_BYTES_SENT(r);
-    return n;
-}
-
 /*
  * Builds the content-type that should be sent to the client from the
  * content-type specified.  The following rules are followed:
@@ -323,13 +286,22 @@
     if (!**r_range) {
         if (r->byterange > 1) {
             if (realreq) {
+                ap_bucket *e;
+                ap_bucket_brigade *bb = ap_brigade_create(r->pool);
+                char *str;                
+
                 /* ### this isn't "content" so we can't use ap_rvputs(), but
-                 * ### it should be processed by non-processing filters. We
-                 * ### have no "in-between" APIs yet, so send it to the
-                 * ### network for now
+                 * ### it should be processed by non-processing filters, to
+                 * ### make sure things arrive in the right order, we have to
+                 * ### flush all the rest of the data that has been sent.
                  */
-                (void) checked_bputstrs(r, CRLF "--", r->boundary, "--" CRLF,
+                str = apr_pstrcat(r->pool, CRLF "--", r->boundary, "--" CRLF,
                                         NULL);
+
+                ap_rflush(r);
+                e = ap_bucket_create_pool(str, strlen(str), r->pool);
+                AP_BRIGADE_INSERT_HEAD(bb, e);
+                ap_pass_brigade(r->connection->output_filters, bb);
             }
 	    else {
                 *tlength += 4 + strlen(r->boundary) + 4;
@@ -350,11 +322,21 @@
 
         apr_snprintf(ts, sizeof(ts), "%ld-%ld/%ld", range_start, range_end,
                     r->clength);
-        if (realreq)
-            (void) checked_bputstrs(r, CRLF "--", r->boundary,
+        if (realreq) {
+            ap_bucket *e;
+            ap_bucket_brigade *bb = ap_brigade_create(r->pool);
+            char *str;                
+
+            str = apr_pstrcat(r->pool, CRLF "--", r->boundary,
                                     CRLF "Content-type: ", ct,
                                     CRLF "Content-range: bytes ", ts,
                                     CRLF CRLF, NULL);
+
+            ap_rflush(r);
+            e = ap_bucket_create_pool(str, strlen(str), r->pool);
+            AP_BRIGADE_INSERT_HEAD(bb, e);
+            ap_pass_brigade(r->connection->output_filters, bb);
+        }
         else
             *tlength += 4 + strlen(r->boundary) + 16 + strlen(ct) + 23 +
                         strlen(ts) + 4;


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Mime
View raw message