| 152 | #endif |
| 153 | |
| 154 | static int h2_protocol_switch(conn_rec *c, request_rec *r, server_rec *s, |
| 155 | const char *protocol) |
| 156 | { |
| 157 | int found = 0; |
| 158 | const char **protos = ap_ssl_conn_is_ssl(c)? h2_protocol_ids_tls : h2_protocol_ids_clear; |
| 159 | const char **p = protos; |
| 160 | |
| 161 | (void)s; |
| 162 | if (!h2_mpm_supported()) { |
| 163 | return DECLINED; |
| 164 | } |
| 165 | |
| 166 | while (*p) { |
| 167 | if (!strcmp(*p, protocol)) { |
| 168 | found = 1; |
| 169 | break; |
| 170 | } |
| 171 | p++; |
| 172 | } |
| 173 | |
| 174 | if (found) { |
| 175 | ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, |
| 176 | "switching protocol to '%s'", protocol); |
| 177 | h2_conn_ctx_create_for_c1(c, s, protocol); |
| 178 | |
| 179 | if (r != NULL) { |
| 180 | apr_status_t status; |
| 181 | #if AP_HAS_RESPONSE_BUCKETS |
| 182 | /* Switching in the middle of a request means that |
| 183 | * we have to send out the response to this one in h2 |
| 184 | * format. So we need to take over the connection |
| 185 | * and remove all old filters with type up to the |
| 186 | * CONNEDCTION/NETWORK ones. |
| 187 | */ |
| 188 | remove_input_filters_below(r->input_filters, AP_FTYPE_CONNECTION); |
| 189 | remove_output_filters_below(r->output_filters, AP_FTYPE_CONNECTION); |
| 190 | #else |
| 191 | /* Switching in the middle of a request means that |
| 192 | * we have to send out the response to this one in h2 |
| 193 | * format. So we need to take over the connection |
| 194 | * right away. |
| 195 | */ |
| 196 | ap_remove_input_filter_byhandle(r->input_filters, "http_in"); |
| 197 | ap_remove_output_filter_byhandle(r->output_filters, "HTTP_HEADER"); |
| 198 | #endif |
| 199 | /* Ok, start an h2_conn on this one. */ |
| 200 | status = h2_c1_setup(c, r, s); |
| 201 | |
| 202 | if (status != APR_SUCCESS) { |
| 203 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(03088) |
| 204 | "session setup"); |
| 205 | h2_conn_ctx_detach(c); |
| 206 | return !OK; |
| 207 | } |
| 208 | |
| 209 | h2_c1_run(c); |
| 210 | } |
| 211 | return OK; |
nothing calls this directly
no test coverage detected