1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <http_core.h>
22 #include <http_connection.h>
25 #include "h2_private.h"
27 #include "h2_stream.h"
28 #include "h2_bucket_eos.h"
31 apr_bucket_refcount refcount;
35 static apr_status_t bucket_cleanup(void *data)
37 h2_stream **pstream = data;
41 * If bucket_destroy is called after us, this prevents
42 * bucket_destroy from trying to destroy the pool again.
49 static apr_status_t bucket_read(apr_bucket *b, const char **str,
50 apr_size_t *len, apr_read_type_e block)
57 AP_DECLARE(apr_bucket *) h2_bucket_eos_make(apr_bucket *b,
62 h = apr_bucket_alloc(sizeof(*h), b->list);
65 b = apr_bucket_shared_make(b, h, 0, 0);
66 b->type = &ap_bucket_type_h2_eos;
71 AP_DECLARE(apr_bucket *) h2_bucket_eos_create(apr_bucket_alloc_t *list,
74 apr_bucket *b = apr_bucket_alloc(sizeof(*b), list);
77 b->free = apr_bucket_free;
79 b = h2_bucket_eos_make(b, stream);
81 h2_bucket_eos *h = b->data;
82 apr_pool_pre_cleanup_register(stream->pool, &h->stream, bucket_cleanup);
87 static void bucket_destroy(void *data)
89 h2_bucket_eos *h = data;
91 if (apr_bucket_shared_destroy(h)) {
92 h2_stream *stream = h->stream;
94 h2_stream_cleanup(stream);
100 AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_h2_eos = {
101 "H2EOS", 5, APR_BUCKET_METADATA,
104 apr_bucket_setaside_noop,
105 apr_bucket_split_notimpl,
106 apr_bucket_shared_copy