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> |
Craig Tiller | 1f41b6b | 2015-10-09 15:07:02 -0700 | [diff] [blame^] | 39 | #include "src/core/profiling/timers.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 40 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 41 | typedef struct call_data { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 42 | gpr_uint8 got_initial_metadata; |
| 43 | gpr_uint8 seen_path; |
| 44 | gpr_uint8 seen_post; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 45 | gpr_uint8 sent_status; |
| 46 | gpr_uint8 seen_scheme; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 47 | gpr_uint8 seen_te_trailers; |
Craig Tiller | c4b56b6 | 2015-07-23 17:44:11 -0700 | [diff] [blame] | 48 | gpr_uint8 seen_authority; |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 49 | grpc_linked_mdelem status; |
Craig Tiller | cb01417 | 2015-09-08 16:40:26 -0700 | [diff] [blame] | 50 | grpc_linked_mdelem content_type; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 51 | |
| 52 | grpc_stream_op_buffer *recv_ops; |
Craig Tiller | 98bf7e6 | 2015-06-24 08:47:07 -0700 | [diff] [blame] | 53 | /** Closure to call when finished with the hs_on_recv hook */ |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame] | 54 | grpc_closure *on_done_recv; |
Craig Tiller | 98bf7e6 | 2015-06-24 08:47:07 -0700 | [diff] [blame] | 55 | /** Receive closures are chained: we inject this closure as the on_done_recv |
| 56 | up-call on transport_op, and remember to call our on_done_recv member |
| 57 | after handling it. */ |
Craig Tiller | 3382511 | 2015-09-18 07:44:19 -0700 | [diff] [blame] | 58 | grpc_closure hs_on_recv; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 59 | } call_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 60 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 61 | typedef struct channel_data { |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 62 | grpc_mdelem *te_trailers; |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 63 | grpc_mdelem *method_post; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 64 | grpc_mdelem *http_scheme; |
| 65 | grpc_mdelem *https_scheme; |
| 66 | /* TODO(klempner): Remove this once we stop using it */ |
| 67 | grpc_mdelem *grpc_scheme; |
| 68 | grpc_mdelem *content_type; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 69 | grpc_mdelem *status_ok; |
| 70 | grpc_mdelem *status_not_found; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 71 | grpc_mdstr *path_key; |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 72 | grpc_mdstr *authority_key; |
| 73 | grpc_mdstr *host_key; |
| 74 | |
| 75 | grpc_mdctx *mdctx; |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 76 | } channel_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 77 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 78 | typedef struct { |
Craig Tiller | d1bec03 | 2015-09-18 17:29:00 -0700 | [diff] [blame] | 79 | grpc_call_element *elem; |
Craig Tiller | 8af4c33 | 2015-09-22 12:32:31 -0700 | [diff] [blame] | 80 | grpc_exec_ctx *exec_ctx; |
Craig Tiller | d1bec03 | 2015-09-18 17:29:00 -0700 | [diff] [blame] | 81 | } server_filter_args; |
| 82 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 83 | static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { |
Craig Tiller | d1bec03 | 2015-09-18 17:29:00 -0700 | [diff] [blame] | 84 | server_filter_args *a = user_data; |
| 85 | grpc_call_element *elem = a->elem; |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 86 | channel_data *channeld = elem->channel_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 87 | call_data *calld = elem->call_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 88 | |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 89 | /* Check if it is one of the headers we care about. */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 90 | if (md == channeld->te_trailers || md == channeld->method_post || |
| 91 | md == channeld->http_scheme || md == channeld->https_scheme || |
| 92 | md == channeld->grpc_scheme || md == channeld->content_type) { |
| 93 | /* swallow it */ |
| 94 | if (md == channeld->method_post) { |
| 95 | calld->seen_post = 1; |
| 96 | } else if (md->key == channeld->http_scheme->key) { |
| 97 | calld->seen_scheme = 1; |
| 98 | } else if (md == channeld->te_trailers) { |
| 99 | calld->seen_te_trailers = 1; |
| 100 | } |
| 101 | /* TODO(klempner): Track that we've seen all the headers we should |
| 102 | require */ |
| 103 | return NULL; |
| 104 | } else if (md->key == channeld->content_type->key) { |
| 105 | if (strncmp(grpc_mdstr_as_c_string(md->value), "application/grpc+", 17) == |
| 106 | 0) { |
| 107 | /* Although the C implementation doesn't (currently) generate them, |
| 108 | any custom +-suffix is explicitly valid. */ |
| 109 | /* TODO(klempner): We should consider preallocating common values such |
| 110 | as +proto or +json, or at least stashing them if we see them. */ |
| 111 | /* TODO(klempner): Should we be surfacing this to application code? */ |
| 112 | } else { |
| 113 | /* TODO(klempner): We're currently allowing this, but we shouldn't |
| 114 | see it without a proxy so log for now. */ |
| 115 | gpr_log(GPR_INFO, "Unexpected content-type %s", |
| 116 | channeld->content_type->key); |
| 117 | } |
| 118 | return NULL; |
| 119 | } else if (md->key == channeld->te_trailers->key || |
| 120 | md->key == channeld->method_post->key || |
| 121 | md->key == channeld->http_scheme->key) { |
| 122 | gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", |
| 123 | grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)); |
| 124 | /* swallow it and error everything out. */ |
| 125 | /* TODO(klempner): We ought to generate more descriptive error messages |
| 126 | on the wire here. */ |
| 127 | grpc_call_element_send_cancel(a->exec_ctx, elem); |
| 128 | return NULL; |
| 129 | } else if (md->key == channeld->path_key) { |
| 130 | if (calld->seen_path) { |
| 131 | gpr_log(GPR_ERROR, "Received :path twice"); |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 132 | return NULL; |
| 133 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 134 | calld->seen_path = 1; |
| 135 | return md; |
| 136 | } else if (md->key == channeld->authority_key) { |
| 137 | calld->seen_authority = 1; |
| 138 | return md; |
| 139 | } else if (md->key == channeld->host_key) { |
| 140 | /* translate host to :authority since :authority may be |
| 141 | omitted */ |
| 142 | grpc_mdelem *authority = grpc_mdelem_from_metadata_strings( |
| 143 | channeld->mdctx, GRPC_MDSTR_REF(channeld->authority_key), |
| 144 | GRPC_MDSTR_REF(md->value)); |
| 145 | GRPC_MDELEM_UNREF(md); |
| 146 | calld->seen_authority = 1; |
| 147 | return authority; |
| 148 | } else { |
| 149 | return md; |
| 150 | } |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 153 | static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data, int success) { |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 154 | grpc_call_element *elem = user_data; |
| 155 | call_data *calld = elem->call_data; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 156 | if (success) { |
| 157 | size_t i; |
| 158 | size_t nops = calld->recv_ops->nops; |
| 159 | grpc_stream_op *ops = calld->recv_ops->ops; |
| 160 | for (i = 0; i < nops; i++) { |
| 161 | grpc_stream_op *op = &ops[i]; |
| 162 | server_filter_args a; |
| 163 | if (op->type != GRPC_OP_METADATA) continue; |
| 164 | calld->got_initial_metadata = 1; |
| 165 | a.elem = elem; |
| 166 | a.exec_ctx = exec_ctx; |
| 167 | grpc_metadata_batch_filter(&op->data.metadata, server_filter, &a); |
| 168 | /* Have we seen the required http2 transport headers? |
| 169 | (:method, :scheme, content-type, with :path and :authority covered |
| 170 | at the channel level right now) */ |
| 171 | if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers && |
| 172 | calld->seen_path && calld->seen_authority) { |
| 173 | /* do nothing */ |
| 174 | } else { |
| 175 | if (!calld->seen_path) { |
| 176 | gpr_log(GPR_ERROR, "Missing :path header"); |
| 177 | } |
| 178 | if (!calld->seen_authority) { |
| 179 | gpr_log(GPR_ERROR, "Missing :authority header"); |
| 180 | } |
| 181 | if (!calld->seen_post) { |
| 182 | gpr_log(GPR_ERROR, "Missing :method header"); |
| 183 | } |
| 184 | if (!calld->seen_scheme) { |
| 185 | gpr_log(GPR_ERROR, "Missing :scheme header"); |
| 186 | } |
| 187 | if (!calld->seen_te_trailers) { |
| 188 | gpr_log(GPR_ERROR, "Missing te trailers header"); |
| 189 | } |
| 190 | /* Error this call out */ |
| 191 | success = 0; |
| 192 | grpc_call_element_send_cancel(exec_ctx, elem); |
| 193 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 194 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 195 | } |
| 196 | calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg, success); |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 199 | static void hs_mutate_op(grpc_call_element *elem, |
| 200 | grpc_transport_stream_op *op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 201 | /* grab pointers to our data from the call element */ |
| 202 | call_data *calld = elem->call_data; |
| 203 | channel_data *channeld = elem->channel_data; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 204 | size_t i; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 205 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 206 | if (op->send_ops && !calld->sent_status) { |
| 207 | size_t nops = op->send_ops->nops; |
| 208 | grpc_stream_op *ops = op->send_ops->ops; |
| 209 | for (i = 0; i < nops; i++) { |
Craig Tiller | b9d3596 | 2015-09-11 13:31:16 -0700 | [diff] [blame] | 210 | grpc_stream_op *stream_op = &ops[i]; |
| 211 | if (stream_op->type != GRPC_OP_METADATA) continue; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 212 | calld->sent_status = 1; |
Craig Tiller | b9d3596 | 2015-09-11 13:31:16 -0700 | [diff] [blame] | 213 | grpc_metadata_batch_add_head(&stream_op->data.metadata, &calld->status, |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 214 | GRPC_MDELEM_REF(channeld->status_ok)); |
Craig Tiller | 8dc0971 | 2015-09-24 13:58:16 -0700 | [diff] [blame] | 215 | grpc_metadata_batch_add_tail(&stream_op->data.metadata, |
| 216 | &calld->content_type, |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 217 | GRPC_MDELEM_REF(channeld->content_type)); |
| 218 | break; |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 219 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 220 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 221 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 222 | if (op->recv_ops && !calld->got_initial_metadata) { |
| 223 | /* substitute our callback for the higher callback */ |
| 224 | calld->recv_ops = op->recv_ops; |
| 225 | calld->on_done_recv = op->on_done_recv; |
| 226 | op->on_done_recv = &calld->hs_on_recv; |
| 227 | } |
Craig Tiller | 50d9db5 | 2015-04-23 10:52:14 -0700 | [diff] [blame] | 228 | } |
Craig Tiller | 83f88d9 | 2015-04-21 16:02:05 -0700 | [diff] [blame] | 229 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 230 | static void hs_start_transport_op(grpc_exec_ctx *exec_ctx, |
| 231 | grpc_call_element *elem, |
| 232 | grpc_transport_stream_op *op) { |
| 233 | GRPC_CALL_LOG_OP(GPR_INFO, elem, op); |
Craig Tiller | 1f41b6b | 2015-10-09 15:07:02 -0700 | [diff] [blame^] | 234 | GRPC_TIMER_BEGIN("hs_start_transport_op", 0); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 235 | hs_mutate_op(elem, op); |
| 236 | grpc_call_next_op(exec_ctx, elem, op); |
Craig Tiller | 1f41b6b | 2015-10-09 15:07:02 -0700 | [diff] [blame^] | 237 | GRPC_TIMER_END("hs_start_transport_op", 0); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 240 | /* Constructor for call_data */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 241 | static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, |
| 242 | const void *server_transport_data, |
| 243 | grpc_transport_stream_op *initial_op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 244 | /* grab pointers to our data from the call element */ |
| 245 | call_data *calld = elem->call_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 246 | /* initialize members */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 247 | memset(calld, 0, sizeof(*calld)); |
| 248 | grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem); |
| 249 | if (initial_op) hs_mutate_op(elem, initial_op); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /* Destructor for call_data */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 253 | static void destroy_call_elem(grpc_exec_ctx *exec_ctx, |
| 254 | grpc_call_element *elem) {} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 255 | |
| 256 | /* Constructor for channel_data */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 257 | static void init_channel_elem(grpc_exec_ctx *exec_ctx, |
| 258 | grpc_channel_element *elem, grpc_channel *master, |
| 259 | const grpc_channel_args *args, grpc_mdctx *mdctx, |
| 260 | int is_first, int is_last) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 261 | /* grab pointers to our data from the channel element */ |
| 262 | channel_data *channeld = elem->channel_data; |
| 263 | |
| 264 | /* The first and the last filters tend to be implemented differently to |
| 265 | handle the case that there's no 'next' filter to call on the up or down |
| 266 | path */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 267 | GPR_ASSERT(!is_first); |
| 268 | GPR_ASSERT(!is_last); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 269 | |
| 270 | /* initialize members */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 271 | channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers"); |
| 272 | channeld->status_ok = grpc_mdelem_from_strings(mdctx, ":status", "200"); |
| 273 | channeld->status_not_found = |
| 274 | grpc_mdelem_from_strings(mdctx, ":status", "404"); |
| 275 | channeld->method_post = grpc_mdelem_from_strings(mdctx, ":method", "POST"); |
| 276 | channeld->http_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "http"); |
| 277 | channeld->https_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "https"); |
| 278 | channeld->grpc_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "grpc"); |
Craig Tiller | 4dbdd6a | 2015-09-25 15:12:16 -0700 | [diff] [blame] | 279 | channeld->path_key = grpc_mdstr_from_string(mdctx, ":path"); |
| 280 | channeld->authority_key = grpc_mdstr_from_string(mdctx, ":authority"); |
| 281 | channeld->host_key = grpc_mdstr_from_string(mdctx, "host"); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 282 | channeld->content_type = |
| 283 | grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 284 | |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 285 | channeld->mdctx = mdctx; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /* Destructor for channel data */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 289 | static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, |
| 290 | grpc_channel_element *elem) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 291 | /* grab pointers to our data from the channel element */ |
| 292 | channel_data *channeld = elem->channel_data; |
| 293 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 294 | GRPC_MDELEM_UNREF(channeld->te_trailers); |
| 295 | GRPC_MDELEM_UNREF(channeld->status_ok); |
| 296 | GRPC_MDELEM_UNREF(channeld->status_not_found); |
| 297 | GRPC_MDELEM_UNREF(channeld->method_post); |
| 298 | GRPC_MDELEM_UNREF(channeld->http_scheme); |
| 299 | GRPC_MDELEM_UNREF(channeld->https_scheme); |
| 300 | GRPC_MDELEM_UNREF(channeld->grpc_scheme); |
| 301 | GRPC_MDELEM_UNREF(channeld->content_type); |
| 302 | GRPC_MDSTR_UNREF(channeld->path_key); |
| 303 | GRPC_MDSTR_UNREF(channeld->authority_key); |
| 304 | GRPC_MDSTR_UNREF(channeld->host_key); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | const grpc_channel_filter grpc_http_server_filter = { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 308 | hs_start_transport_op, grpc_channel_next_op, sizeof(call_data), |
| 309 | init_call_elem, destroy_call_elem, sizeof(channel_data), |
| 310 | init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, |
| 311 | "http-server"}; |