]> granicus.if.org Git - apache/blobdiff - modules/http/byterange_filter.c
Make sure to not destroy bucket brigades that have been created by earlier
[apache] / modules / http / byterange_filter.c
index bf4bd54c101ec0ea4c0ceced83390bc8905a97d0..92048ab75d75f5d3cf6a544609de35ab0806f031 100644 (file)
@@ -1,9 +1,9 @@
-/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -29,7 +29,6 @@
 #define APR_WANT_MEMFUNC
 #include "apr_want.h"
 
-#define CORE_PRIVATE
 #include "util_filter.h"
 #include "ap_config.h"
 #include "httpd.h"
@@ -193,12 +192,21 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
                                            "byteranges; boundary=",
                                            ctx->boundary, NULL));
 
-        ctx->bound_head = apr_pstrcat(r->pool,
-                                      CRLF "--", ctx->boundary,
-                                      CRLF "Content-type: ",
-                                      orig_ct,
-                                      CRLF "Content-range: bytes ",
-                                      NULL);
+        if (orig_ct) {
+            ctx->bound_head = apr_pstrcat(r->pool,
+                                          CRLF "--", ctx->boundary,
+                                          CRLF "Content-type: ",
+                                          orig_ct,
+                                          CRLF "Content-range: bytes ",
+                                          NULL);
+        }
+        else {
+            /* if we have no type for the content, do our best */
+            ctx->bound_head = apr_pstrcat(r->pool,
+                                          CRLF "--", ctx->boundary,
+                                          CRLF "Content-range: bytes ",
+                                          NULL);
+        }
         ap_xlate_proto_to_ascii(ctx->bound_head, strlen(ctx->bound_head));
     }
 
@@ -299,7 +307,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
     APR_BRIGADE_INSERT_TAIL(bsend, e);
 
     /* we're done with the original content - all of our data is in bsend. */
-    apr_brigade_destroy(bb);
+    apr_brigade_cleanup(bb);
 
     /* send our multipart output */
     return ap_pass_brigade(f->next, bsend);