Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 0605995 | 2015-02-18 08:34:56 -0800 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include "src/core/channel/http_server_filter.h" |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 35 | |
| 36 | #include <string.h> |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 37 | #include <grpc/support/alloc.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 38 | #include <grpc/support/log.h> |
| 39 | |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 40 | typedef struct call_data { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 41 | gpr_uint8 got_initial_metadata; |
| 42 | gpr_uint8 seen_path; |
| 43 | gpr_uint8 seen_post; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 44 | gpr_uint8 sent_status; |
| 45 | gpr_uint8 seen_scheme; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 46 | gpr_uint8 seen_te_trailers; |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 47 | gpr_uint8 seen_authority; |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 48 | grpc_linked_mdelem status; |
Craig Tiller | cb01417 | 2015-09-08 16:40:26 -0700 | [diff] [blame] | 49 | grpc_linked_mdelem content_type; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 50 | |
| 51 | grpc_stream_op_buffer *recv_ops; |
Craig Tiller | 98bf7e6 | 2015-06-24 08:47:07 -0700 | [diff] [blame] | 52 | /** Closure to call when finished with the hs_on_recv hook */ |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame^] | 53 | grpc_closure *on_done_recv; |
Craig Tiller | 98bf7e6 | 2015-06-24 08:47:07 -0700 | [diff] [blame] | 54 | /** Receive closures are chained: we inject this closure as the on_done_recv |
| 55 | up-call on transport_op, and remember to call our on_done_recv member |
| 56 | after handling it. */ |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame^] | 57 | grpc_closure hs_on_recv; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 58 | } call_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 59 | |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 60 | typedef struct channel_data { |
| 61 | grpc_mdelem *te_trailers; |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 62 | grpc_mdelem *method_post; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 63 | grpc_mdelem *http_scheme; |
| 64 | grpc_mdelem *https_scheme; |
| 65 | /* TODO(klempner): Remove this once we stop using it */ |
| 66 | grpc_mdelem *grpc_scheme; |
| 67 | grpc_mdelem *content_type; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 68 | grpc_mdelem *status_ok; |
| 69 | grpc_mdelem *status_not_found; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 70 | grpc_mdstr *path_key; |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 71 | grpc_mdstr *authority_key; |
| 72 | grpc_mdstr *host_key; |
| 73 | |
| 74 | grpc_mdctx *mdctx; |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 75 | } channel_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 76 | |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 77 | static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { |
| 78 | grpc_call_element *elem = user_data; |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 79 | channel_data *channeld = elem->channel_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 80 | call_data *calld = elem->call_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 81 | |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 82 | /* Check if it is one of the headers we care about. */ |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 83 | if (md == channeld->te_trailers || md == channeld->method_post || |
| 84 | md == channeld->http_scheme || md == channeld->https_scheme || |
| 85 | md == channeld->grpc_scheme || md == channeld->content_type) { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 86 | /* swallow it */ |
| 87 | if (md == channeld->method_post) { |
| 88 | calld->seen_post = 1; |
| 89 | } else if (md->key == channeld->http_scheme->key) { |
| 90 | calld->seen_scheme = 1; |
| 91 | } else if (md == channeld->te_trailers) { |
| 92 | calld->seen_te_trailers = 1; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 93 | } |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 94 | /* TODO(klempner): Track that we've seen all the headers we should |
| 95 | require */ |
| 96 | return NULL; |
| 97 | } else if (md->key == channeld->content_type->key) { |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 98 | if (strncmp(grpc_mdstr_as_c_string(md->value), "application/grpc+", 17) == |
| 99 | 0) { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 100 | /* Although the C implementation doesn't (currently) generate them, |
Craig Tiller | 9c9d4e0 | 2015-04-20 09:03:29 -0700 | [diff] [blame] | 101 | any custom +-suffix is explicitly valid. */ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 102 | /* TODO(klempner): We should consider preallocating common values such |
| 103 | as +proto or +json, or at least stashing them if we see them. */ |
| 104 | /* TODO(klempner): Should we be surfacing this to application code? */ |
| 105 | } else { |
| 106 | /* TODO(klempner): We're currently allowing this, but we shouldn't |
| 107 | see it without a proxy so log for now. */ |
| 108 | gpr_log(GPR_INFO, "Unexpected content-type %s", |
| 109 | channeld->content_type->key); |
| 110 | } |
| 111 | return NULL; |
| 112 | } else if (md->key == channeld->te_trailers->key || |
| 113 | md->key == channeld->method_post->key || |
| 114 | md->key == channeld->http_scheme->key || |
| 115 | md->key == channeld->content_type->key) { |
| 116 | gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 117 | grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)); |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 118 | /* swallow it and error everything out. */ |
| 119 | /* TODO(klempner): We ought to generate more descriptive error messages |
| 120 | on the wire here. */ |
| 121 | grpc_call_element_send_cancel(elem); |
| 122 | return NULL; |
| 123 | } else if (md->key == channeld->path_key) { |
| 124 | if (calld->seen_path) { |
| 125 | gpr_log(GPR_ERROR, "Received :path twice"); |
| 126 | return NULL; |
| 127 | } |
| 128 | calld->seen_path = 1; |
| 129 | return md; |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 130 | } else if (md->key == channeld->authority_key) { |
| 131 | calld->seen_authority = 1; |
| 132 | return md; |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 133 | } else if (md->key == channeld->host_key) { |
| 134 | /* translate host to :authority since :authority may be |
| 135 | omitted */ |
| 136 | grpc_mdelem *authority = grpc_mdelem_from_metadata_strings( |
Craig Tiller | 1a65a23 | 2015-07-06 10:22:32 -0700 | [diff] [blame] | 137 | channeld->mdctx, GRPC_MDSTR_REF(channeld->authority_key), |
| 138 | GRPC_MDSTR_REF(md->value)); |
| 139 | GRPC_MDELEM_UNREF(md); |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 140 | calld->seen_authority = 1; |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 141 | return authority; |
| 142 | } else { |
| 143 | return md; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 144 | } |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 147 | static void hs_on_recv(void *user_data, int success) { |
| 148 | grpc_call_element *elem = user_data; |
| 149 | call_data *calld = elem->call_data; |
| 150 | if (success) { |
| 151 | size_t i; |
| 152 | size_t nops = calld->recv_ops->nops; |
| 153 | grpc_stream_op *ops = calld->recv_ops->ops; |
| 154 | for (i = 0; i < nops; i++) { |
| 155 | grpc_stream_op *op = &ops[i]; |
| 156 | if (op->type != GRPC_OP_METADATA) continue; |
| 157 | calld->got_initial_metadata = 1; |
| 158 | grpc_metadata_batch_filter(&op->data.metadata, server_filter, elem); |
| 159 | /* Have we seen the required http2 transport headers? |
| 160 | (:method, :scheme, content-type, with :path and :authority covered |
| 161 | at the channel level right now) */ |
| 162 | if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers && |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 163 | calld->seen_path && calld->seen_authority) { |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 164 | /* do nothing */ |
| 165 | } else { |
Craig Tiller | 77979b0 | 2015-04-22 07:56:09 -0700 | [diff] [blame] | 166 | if (!calld->seen_path) { |
| 167 | gpr_log(GPR_ERROR, "Missing :path header"); |
| 168 | } |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 169 | if (!calld->seen_authority) { |
| 170 | gpr_log(GPR_ERROR, "Missing :authority header"); |
| 171 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 172 | if (!calld->seen_post) { |
| 173 | gpr_log(GPR_ERROR, "Missing :method header"); |
| 174 | } |
| 175 | if (!calld->seen_scheme) { |
| 176 | gpr_log(GPR_ERROR, "Missing :scheme header"); |
| 177 | } |
| 178 | if (!calld->seen_te_trailers) { |
| 179 | gpr_log(GPR_ERROR, "Missing te trailers header"); |
| 180 | } |
| 181 | /* Error this call out */ |
| 182 | success = 0; |
| 183 | grpc_call_element_send_cancel(elem); |
| 184 | } |
| 185 | } |
| 186 | } |
Craig Tiller | 1e6facb | 2015-06-11 22:47:11 -0700 | [diff] [blame] | 187 | calld->on_done_recv->cb(calld->on_done_recv->cb_arg, success); |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Craig Tiller | b7959a0 | 2015-06-25 08:50:54 -0700 | [diff] [blame] | 190 | static void hs_mutate_op(grpc_call_element *elem, |
| 191 | grpc_transport_stream_op *op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 192 | /* grab pointers to our data from the call element */ |
| 193 | call_data *calld = elem->call_data; |
| 194 | channel_data *channeld = elem->channel_data; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 195 | size_t i; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 196 | |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 197 | if (op->send_ops && !calld->sent_status) { |
| 198 | size_t nops = op->send_ops->nops; |
| 199 | grpc_stream_op *ops = op->send_ops->ops; |
| 200 | for (i = 0; i < nops; i++) { |
| 201 | grpc_stream_op *op = &ops[i]; |
| 202 | if (op->type != GRPC_OP_METADATA) continue; |
| 203 | calld->sent_status = 1; |
| 204 | grpc_metadata_batch_add_head(&op->data.metadata, &calld->status, |
Craig Tiller | 1a65a23 | 2015-07-06 10:22:32 -0700 | [diff] [blame] | 205 | GRPC_MDELEM_REF(channeld->status_ok)); |
Craig Tiller | cb01417 | 2015-09-08 16:40:26 -0700 | [diff] [blame] | 206 | grpc_metadata_batch_add_tail(&op->data.metadata, &calld->content_type, |
| 207 | GRPC_MDELEM_REF(channeld->content_type)); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 208 | break; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 209 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 210 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 211 | |
| 212 | if (op->recv_ops && !calld->got_initial_metadata) { |
| 213 | /* substitute our callback for the higher callback */ |
| 214 | calld->recv_ops = op->recv_ops; |
| 215 | calld->on_done_recv = op->on_done_recv; |
Craig Tiller | 1e6facb | 2015-06-11 22:47:11 -0700 | [diff] [blame] | 216 | op->on_done_recv = &calld->hs_on_recv; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 217 | } |
Craig Tiller | 50d9db5 | 2015-04-23 10:52:14 -0700 | [diff] [blame] | 218 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 219 | |
Craig Tiller | 06aeea7 | 2015-04-23 10:54:45 -0700 | [diff] [blame] | 220 | static void hs_start_transport_op(grpc_call_element *elem, |
Craig Tiller | b7959a0 | 2015-06-25 08:50:54 -0700 | [diff] [blame] | 221 | grpc_transport_stream_op *op) { |
Craig Tiller | 50d9db5 | 2015-04-23 10:52:14 -0700 | [diff] [blame] | 222 | GRPC_CALL_LOG_OP(GPR_INFO, elem, op); |
| 223 | hs_mutate_op(elem, op); |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 224 | grpc_call_next_op(elem, op); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 227 | /* Constructor for call_data */ |
| 228 | static void init_call_elem(grpc_call_element *elem, |
Craig Tiller | 06aeea7 | 2015-04-23 10:54:45 -0700 | [diff] [blame] | 229 | const void *server_transport_data, |
Craig Tiller | b7959a0 | 2015-06-25 08:50:54 -0700 | [diff] [blame] | 230 | grpc_transport_stream_op *initial_op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 231 | /* grab pointers to our data from the call element */ |
| 232 | call_data *calld = elem->call_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 233 | /* initialize members */ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 234 | memset(calld, 0, sizeof(*calld)); |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame^] | 235 | grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem); |
Craig Tiller | 50d9db5 | 2015-04-23 10:52:14 -0700 | [diff] [blame] | 236 | if (initial_op) hs_mutate_op(elem, initial_op); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /* Destructor for call_data */ |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 240 | static void destroy_call_elem(grpc_call_element *elem) {} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 241 | |
| 242 | /* Constructor for channel_data */ |
Craig Tiller | 079a11b | 2015-06-30 10:07:15 -0700 | [diff] [blame] | 243 | static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master, |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 244 | const grpc_channel_args *args, grpc_mdctx *mdctx, |
| 245 | int is_first, int is_last) { |
| 246 | /* grab pointers to our data from the channel element */ |
| 247 | channel_data *channeld = elem->channel_data; |
| 248 | |
| 249 | /* The first and the last filters tend to be implemented differently to |
| 250 | handle the case that there's no 'next' filter to call on the up or down |
| 251 | path */ |
| 252 | GPR_ASSERT(!is_first); |
| 253 | GPR_ASSERT(!is_last); |
| 254 | |
| 255 | /* initialize members */ |
| 256 | channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers"); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 257 | channeld->status_ok = grpc_mdelem_from_strings(mdctx, ":status", "200"); |
| 258 | channeld->status_not_found = |
| 259 | grpc_mdelem_from_strings(mdctx, ":status", "404"); |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 260 | channeld->method_post = grpc_mdelem_from_strings(mdctx, ":method", "POST"); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 261 | channeld->http_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "http"); |
| 262 | channeld->https_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "https"); |
| 263 | channeld->grpc_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "grpc"); |
Craig Tiller | 6999c09 | 2015-07-22 08:14:12 -0700 | [diff] [blame] | 264 | channeld->path_key = grpc_mdstr_from_string(mdctx, ":path", 0); |
| 265 | channeld->authority_key = grpc_mdstr_from_string(mdctx, ":authority", 0); |
| 266 | channeld->host_key = grpc_mdstr_from_string(mdctx, "host", 0); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 267 | channeld->content_type = |
| 268 | grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 269 | |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 270 | channeld->mdctx = mdctx; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | /* Destructor for channel data */ |
| 274 | static void destroy_channel_elem(grpc_channel_element *elem) { |
| 275 | /* grab pointers to our data from the channel element */ |
| 276 | channel_data *channeld = elem->channel_data; |
| 277 | |
Craig Tiller | 1a65a23 | 2015-07-06 10:22:32 -0700 | [diff] [blame] | 278 | GRPC_MDELEM_UNREF(channeld->te_trailers); |
| 279 | GRPC_MDELEM_UNREF(channeld->status_ok); |
| 280 | GRPC_MDELEM_UNREF(channeld->status_not_found); |
| 281 | GRPC_MDELEM_UNREF(channeld->method_post); |
| 282 | GRPC_MDELEM_UNREF(channeld->http_scheme); |
| 283 | GRPC_MDELEM_UNREF(channeld->https_scheme); |
| 284 | GRPC_MDELEM_UNREF(channeld->grpc_scheme); |
| 285 | GRPC_MDELEM_UNREF(channeld->content_type); |
| 286 | GRPC_MDSTR_UNREF(channeld->path_key); |
| 287 | GRPC_MDSTR_UNREF(channeld->authority_key); |
| 288 | GRPC_MDSTR_UNREF(channeld->host_key); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | const grpc_channel_filter grpc_http_server_filter = { |
Craig Tiller | e039f03 | 2015-06-25 12:54:23 -0700 | [diff] [blame] | 292 | hs_start_transport_op, grpc_channel_next_op, sizeof(call_data), |
| 293 | init_call_elem, destroy_call_elem, sizeof(channel_data), |
Craig Tiller | 1b22b9d | 2015-07-20 13:42:22 -0700 | [diff] [blame] | 294 | init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, |
| 295 | "http-server"}; |