> Am 24.07.2015 um 15:40 schrieb Ruediger Pluem <[email protected]>:
>
>
>
> On 07/24/2015 02:09 PM, [email protected] wrote:
>> Author: icing
>> Date: Fri Jul 24 12:09:44 2015
>> New Revision: 1692486
>>
>> +
>> static const char *set_http_protocol(cmd_parms *cmd, void *dummy,
>> const char *arg)
>> {
>> core_server_config *conf =
>> ap_get_core_module_config(cmd->server->module_config);
>>
>> + if (!conf->protocols) {
>> +
>> + }
>
> What is the purpose of the above?
Arg, good catch. Removed in r1692516.
>
>> +static int core_upgrade_handler(request_rec *r)
>> +{
>> + conn_rec *c = r->connection;
>> + const char *upgrade = apr_table_get(r->headers_in, "Upgrade");
>> +
>> + if (upgrade && *upgrade) {
>> + const char *conn = apr_table_get(r->headers_in, "Connection");
>> + if (ap_find_token(r->pool, conn, "upgrade")) {
>> + apr_array_header_t *offers = NULL;
>> + const char *err;
>> +
>> + err = ap_parse_token_list_strict(r->pool, upgrade, &offers, 0);
>> + if (err) {
>> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02910)
>> + "parsing Upgrade header: %s", err);
>> + return DECLINED;
>> + }
>> +
>> + if (offers && offers->nelts > 0) {
>> + const char *protocol = ap_select_protocol(c, r, r->server,
>> + offers);
>> + if (strcmp(protocol, ap_run_protocol_get(c))) {
>> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
>> APLOGNO(02909)
>> + "Upgrade selects '%s'", protocol);
>> + /* Let the client know what we are upgrading to. */
>> + apr_table_clear(r->headers_out);
>> + apr_table_setn(r->headers_out, "Upgrade", protocol);
>> + apr_table_setn(r->headers_out, "Connection", "Upgrade");
>> +
>> + r->status = HTTP_SWITCHING_PROTOCOLS;
>> + r->status_line = ap_get_status_line(r->status);
>> + ap_send_interim_response(r, 1);
>> +
>> + ap_switch_protocol(c, r, r->server, protocol);
>> +
>> + /* make sure httpd closes the connection after this */
>> + c->keepalive = AP_CONN_CLOSE;
>> + ap_lingering_close(c);
>> +
>> + if (c->sbh) {
>> + ap_update_child_status_from_conn(c->sbh,
>> + SERVER_CLOSING, c);
>> + }
>
> The c->keepalive = AP_CONN_CLOSE looks fine to me, but why should we do the
> other stuff in a handler.
> IMHO that should be done by the existing code.
Not sure I understand. You mean the interim response or the whole handler?
>> +static int core_upgrade_storage(request_rec *r)
>> +{
>> + if ((r->method_number == M_OPTIONS) && r->uri && (r->uri[0] == '*') &&
>> + (r->uri[1] == '\0')) {
>> + return core_upgrade_handler(r);
>> + }
>> + return DECLINED;
>> +}
>> +
>
> Why do we need to handle upgrades on OPTIONS requests?
There are clients that try Upgrade: h2c on OPTIONS * before a POST. As upgrades
on requests with bodies are not implemented (agreement by several implememtors
on the http wg mailing list).
Cheers,
Stefan
<green/>bytes GmbH
Hafenweg 16, 48155 Münster, Germany
Phone: +49 251 2807760. Amtsgericht Münster: HRB5782