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/grpc_http.h> |
| 38 | #include <grpc/support/alloc.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 39 | #include <grpc/support/log.h> |
| 40 | |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 41 | typedef struct { |
| 42 | grpc_mdelem *path; |
| 43 | grpc_mdelem *content_type; |
| 44 | grpc_byte_buffer *content; |
| 45 | } gettable; |
| 46 | |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 47 | typedef struct call_data { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 48 | gpr_uint8 got_initial_metadata; |
| 49 | gpr_uint8 seen_path; |
| 50 | gpr_uint8 seen_post; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 51 | gpr_uint8 sent_status; |
| 52 | gpr_uint8 seen_scheme; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 53 | gpr_uint8 seen_te_trailers; |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 54 | grpc_linked_mdelem status; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 55 | } call_data; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 56 | |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 57 | typedef struct channel_data { |
| 58 | grpc_mdelem *te_trailers; |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 59 | grpc_mdelem *method_post; |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 60 | grpc_mdelem *http_scheme; |
| 61 | grpc_mdelem *https_scheme; |
| 62 | /* TODO(klempner): Remove this once we stop using it */ |
| 63 | grpc_mdelem *grpc_scheme; |
| 64 | grpc_mdelem *content_type; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 65 | grpc_mdelem *status_ok; |
| 66 | grpc_mdelem *status_not_found; |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 67 | grpc_mdstr *path_key; |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 68 | grpc_mdstr *authority_key; |
| 69 | grpc_mdstr *host_key; |
| 70 | |
| 71 | grpc_mdctx *mdctx; |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 72 | |
| 73 | size_t gettable_count; |
| 74 | gettable *gettables; |
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 | |
| 77 | /* used to silence 'variable not used' warnings */ |
| 78 | static void ignore_unused(void *ignored) {} |
| 79 | |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 80 | static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { |
| 81 | grpc_call_element *elem = user_data; |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 82 | channel_data *channeld = elem->channel_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 83 | call_data *calld = elem->call_data; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 84 | |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 85 | /* Check if it is one of the headers we care about. */ |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 86 | if (md == channeld->te_trailers || md == channeld->method_post || |
| 87 | md == channeld->http_scheme || md == channeld->https_scheme || |
| 88 | md == channeld->grpc_scheme || md == channeld->content_type) { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 89 | /* swallow it */ |
| 90 | if (md == channeld->method_post) { |
| 91 | calld->seen_post = 1; |
| 92 | } else if (md->key == channeld->http_scheme->key) { |
| 93 | calld->seen_scheme = 1; |
| 94 | } else if (md == channeld->te_trailers) { |
| 95 | calld->seen_te_trailers = 1; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 96 | } |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 97 | /* TODO(klempner): Track that we've seen all the headers we should |
| 98 | require */ |
| 99 | return NULL; |
| 100 | } else if (md->key == channeld->content_type->key) { |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 101 | if (strncmp(grpc_mdstr_as_c_string(md->value), "application/grpc+", 17) == |
| 102 | 0) { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 103 | /* Although the C implementation doesn't (currently) generate them, |
Craig Tiller | 9c9d4e0 | 2015-04-20 09:03:29 -0700 | [diff] [blame^] | 104 | any custom +-suffix is explicitly valid. */ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 105 | /* TODO(klempner): We should consider preallocating common values such |
| 106 | as +proto or +json, or at least stashing them if we see them. */ |
| 107 | /* TODO(klempner): Should we be surfacing this to application code? */ |
| 108 | } else { |
| 109 | /* TODO(klempner): We're currently allowing this, but we shouldn't |
| 110 | see it without a proxy so log for now. */ |
| 111 | gpr_log(GPR_INFO, "Unexpected content-type %s", |
| 112 | channeld->content_type->key); |
| 113 | } |
| 114 | return NULL; |
| 115 | } else if (md->key == channeld->te_trailers->key || |
| 116 | md->key == channeld->method_post->key || |
| 117 | md->key == channeld->http_scheme->key || |
| 118 | md->key == channeld->content_type->key) { |
| 119 | gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 120 | 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] | 121 | /* swallow it and error everything out. */ |
| 122 | /* TODO(klempner): We ought to generate more descriptive error messages |
| 123 | on the wire here. */ |
| 124 | grpc_call_element_send_cancel(elem); |
| 125 | return NULL; |
| 126 | } else if (md->key == channeld->path_key) { |
| 127 | if (calld->seen_path) { |
| 128 | gpr_log(GPR_ERROR, "Received :path twice"); |
| 129 | return NULL; |
| 130 | } |
| 131 | calld->seen_path = 1; |
| 132 | return md; |
| 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( |
| 137 | channeld->mdctx, grpc_mdstr_ref(channeld->authority_key), |
| 138 | grpc_mdstr_ref(md->value)); |
| 139 | grpc_mdelem_unref(md); |
| 140 | return authority; |
| 141 | } else { |
| 142 | return md; |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 143 | } |
Craig Tiller | ce6e350 | 2015-01-19 18:04:42 -0800 | [diff] [blame] | 144 | } |
| 145 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 146 | /* Called either: |
| 147 | - in response to an API call (or similar) from above, to send something |
| 148 | - a network event (or similar) from below, to receive something |
| 149 | op contains type and call direction information, in addition to the data |
| 150 | that is being sent or received. */ |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 151 | static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, |
| 152 | grpc_call_op *op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 153 | /* grab pointers to our data from the call element */ |
| 154 | call_data *calld = elem->call_data; |
| 155 | channel_data *channeld = elem->channel_data; |
| 156 | GRPC_CALL_LOG_OP(GPR_INFO, elem, op); |
| 157 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 158 | switch (op->type) { |
| 159 | case GRPC_RECV_METADATA: |
Craig Tiller | 205aee1 | 2015-04-16 14:46:41 -0700 | [diff] [blame] | 160 | grpc_metadata_batch_filter(&op->data.metadata, server_filter, elem); |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 161 | if (!calld->got_initial_metadata) { |
| 162 | calld->got_initial_metadata = 1; |
| 163 | /* Have we seen the required http2 transport headers? |
| 164 | (:method, :scheme, content-type, with :path and :authority covered |
| 165 | at the channel level right now) */ |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 166 | if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers && |
| 167 | calld->seen_path) { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 168 | grpc_call_next_op(elem, op); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 169 | } else { |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 170 | if (!calld->seen_post) { |
| 171 | gpr_log(GPR_ERROR, "Missing :method header"); |
| 172 | } |
| 173 | if (!calld->seen_scheme) { |
| 174 | gpr_log(GPR_ERROR, "Missing :scheme header"); |
| 175 | } |
| 176 | if (!calld->seen_te_trailers) { |
| 177 | gpr_log(GPR_ERROR, "Missing te trailers header"); |
| 178 | } |
| 179 | /* Error this call out */ |
Craig Tiller | eb40a53 | 2015-04-17 16:46:20 -0700 | [diff] [blame] | 180 | grpc_metadata_batch_destroy(&op->data.metadata); |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 181 | op->done_cb(op->user_data, GRPC_OP_OK); |
| 182 | grpc_call_element_send_cancel(elem); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 183 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 184 | } else { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 185 | grpc_call_next_op(elem, op); |
| 186 | } |
| 187 | break; |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 188 | case GRPC_SEND_METADATA: |
| 189 | /* If we haven't sent status 200 yet, we need to so so because it needs to |
| 190 | come before any non : prefixed metadata. */ |
Craig Tiller | 8b282cb | 2015-04-17 14:57:44 -0700 | [diff] [blame] | 191 | if (!calld->sent_status) { |
| 192 | calld->sent_status = 1; |
| 193 | grpc_metadata_batch_add_head(&op->data.metadata, &calld->status, |
Craig Tiller | 76f5d46 | 2015-04-17 14:58:12 -0700 | [diff] [blame] | 194 | grpc_mdelem_ref(channeld->status_ok)); |
Craig Tiller | 8b282cb | 2015-04-17 14:57:44 -0700 | [diff] [blame] | 195 | } |
klempner | 1e27328 | 2014-12-10 13:55:41 -0800 | [diff] [blame] | 196 | grpc_call_next_op(elem, op); |
| 197 | break; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 198 | default: |
| 199 | /* pass control up or down the stack depending on op->dir */ |
| 200 | grpc_call_next_op(elem, op); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /* Called on special channel events, such as disconnection or new incoming |
| 206 | calls on the server */ |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 207 | static void channel_op(grpc_channel_element *elem, |
| 208 | grpc_channel_element *from_elem, grpc_channel_op *op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 209 | /* grab pointers to our data from the channel element */ |
| 210 | channel_data *channeld = elem->channel_data; |
| 211 | |
| 212 | ignore_unused(channeld); |
| 213 | |
| 214 | switch (op->type) { |
| 215 | default: |
| 216 | /* pass control up or down the stack depending on op->dir */ |
| 217 | grpc_channel_next_op(elem, op); |
| 218 | break; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | /* Constructor for call_data */ |
| 223 | static void init_call_elem(grpc_call_element *elem, |
| 224 | const void *server_transport_data) { |
| 225 | /* grab pointers to our data from the call element */ |
| 226 | call_data *calld = elem->call_data; |
| 227 | channel_data *channeld = elem->channel_data; |
| 228 | |
| 229 | ignore_unused(channeld); |
| 230 | |
| 231 | /* initialize members */ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 232 | memset(calld, 0, sizeof(*calld)); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /* Destructor for call_data */ |
Craig Tiller | 87d5b19 | 2015-04-16 14:37:57 -0700 | [diff] [blame] | 236 | static void destroy_call_elem(grpc_call_element *elem) {} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 237 | |
| 238 | /* Constructor for channel_data */ |
| 239 | static void init_channel_elem(grpc_channel_element *elem, |
| 240 | const grpc_channel_args *args, grpc_mdctx *mdctx, |
| 241 | int is_first, int is_last) { |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 242 | size_t i; |
| 243 | size_t gettable_capacity = 0; |
| 244 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 245 | /* grab pointers to our data from the channel element */ |
| 246 | channel_data *channeld = elem->channel_data; |
| 247 | |
| 248 | /* The first and the last filters tend to be implemented differently to |
| 249 | handle the case that there's no 'next' filter to call on the up or down |
| 250 | path */ |
| 251 | GPR_ASSERT(!is_first); |
| 252 | GPR_ASSERT(!is_last); |
| 253 | |
| 254 | /* initialize members */ |
| 255 | channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers"); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 256 | channeld->status_ok = grpc_mdelem_from_strings(mdctx, ":status", "200"); |
| 257 | channeld->status_not_found = |
| 258 | grpc_mdelem_from_strings(mdctx, ":status", "404"); |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 259 | channeld->method_post = grpc_mdelem_from_strings(mdctx, ":method", "POST"); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 260 | channeld->http_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "http"); |
| 261 | channeld->https_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "https"); |
| 262 | channeld->grpc_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "grpc"); |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 263 | channeld->path_key = grpc_mdstr_from_string(mdctx, ":path"); |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 264 | channeld->authority_key = grpc_mdstr_from_string(mdctx, ":authority"); |
| 265 | channeld->host_key = grpc_mdstr_from_string(mdctx, "host"); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 266 | channeld->content_type = |
| 267 | grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 268 | |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 269 | channeld->mdctx = mdctx; |
| 270 | |
Craig Tiller | 53d5f9d | 2015-01-21 13:03:18 -0800 | [diff] [blame] | 271 | /* initialize http download support */ |
| 272 | channeld->gettable_count = 0; |
| 273 | channeld->gettables = NULL; |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 274 | for (i = 0; i < args->num_args; i++) { |
| 275 | if (0 == strcmp(args->args[i].key, GRPC_ARG_SERVE_OVER_HTTP)) { |
| 276 | gettable *g; |
| 277 | gpr_slice slice; |
| 278 | grpc_http_server_page *p = args->args[i].value.pointer.p; |
| 279 | if (channeld->gettable_count == gettable_capacity) { |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 280 | gettable_capacity = |
| 281 | GPR_MAX(gettable_capacity * 3 / 2, gettable_capacity + 1); |
Craig Tiller | 5a8a807 | 2015-01-30 09:41:25 -0800 | [diff] [blame] | 282 | channeld->gettables = gpr_realloc(channeld->gettables, |
| 283 | gettable_capacity * sizeof(gettable)); |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 284 | } |
| 285 | g = &channeld->gettables[channeld->gettable_count++]; |
| 286 | g->path = grpc_mdelem_from_strings(mdctx, ":path", p->path); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 287 | g->content_type = |
| 288 | grpc_mdelem_from_strings(mdctx, "content-type", p->content_type); |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 289 | slice = gpr_slice_from_copied_string(p->content); |
| 290 | g->content = grpc_byte_buffer_create(&slice, 1); |
Craig Tiller | d375663 | 2015-01-30 09:45:50 -0800 | [diff] [blame] | 291 | gpr_slice_unref(slice); |
Craig Tiller | c50e398 | 2015-01-20 16:30:54 -0800 | [diff] [blame] | 292 | } |
| 293 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /* Destructor for channel data */ |
| 297 | static void destroy_channel_elem(grpc_channel_element *elem) { |
Craig Tiller | 5a8a807 | 2015-01-30 09:41:25 -0800 | [diff] [blame] | 298 | size_t i; |
| 299 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 300 | /* grab pointers to our data from the channel element */ |
| 301 | channel_data *channeld = elem->channel_data; |
| 302 | |
Craig Tiller | 5a8a807 | 2015-01-30 09:41:25 -0800 | [diff] [blame] | 303 | for (i = 0; i < channeld->gettable_count; i++) { |
| 304 | grpc_mdelem_unref(channeld->gettables[i].path); |
| 305 | grpc_mdelem_unref(channeld->gettables[i].content_type); |
Craig Tiller | d375663 | 2015-01-30 09:45:50 -0800 | [diff] [blame] | 306 | grpc_byte_buffer_destroy(channeld->gettables[i].content); |
Craig Tiller | 5a8a807 | 2015-01-30 09:41:25 -0800 | [diff] [blame] | 307 | } |
| 308 | gpr_free(channeld->gettables); |
| 309 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 310 | grpc_mdelem_unref(channeld->te_trailers); |
Craig Tiller | fd7d3ec | 2015-01-21 13:37:09 -0800 | [diff] [blame] | 311 | grpc_mdelem_unref(channeld->status_ok); |
| 312 | grpc_mdelem_unref(channeld->status_not_found); |
Craig Tiller | c923cd7 | 2015-01-19 16:14:31 -0800 | [diff] [blame] | 313 | grpc_mdelem_unref(channeld->method_post); |
ctiller | d74729d | 2015-01-12 13:31:36 -0800 | [diff] [blame] | 314 | grpc_mdelem_unref(channeld->http_scheme); |
| 315 | grpc_mdelem_unref(channeld->https_scheme); |
| 316 | grpc_mdelem_unref(channeld->grpc_scheme); |
| 317 | grpc_mdelem_unref(channeld->content_type); |
Craig Tiller | d2d0a11 | 2015-01-19 16:07:52 -0800 | [diff] [blame] | 318 | grpc_mdstr_unref(channeld->path_key); |
Tatsuhiro Tsujikawa | 229000f | 2015-03-13 23:52:56 +0900 | [diff] [blame] | 319 | grpc_mdstr_unref(channeld->authority_key); |
| 320 | grpc_mdstr_unref(channeld->host_key); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | const grpc_channel_filter grpc_http_server_filter = { |
Craig Tiller | 5a8a807 | 2015-01-30 09:41:25 -0800 | [diff] [blame] | 324 | call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, |
| 325 | sizeof(channel_data), init_channel_elem, destroy_channel_elem, |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 326 | "http-server"}; |