From 01af6ea70c466b8ace7f22c25737418babddb8b5 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 22 Mar 2015 23:22:06 +0900 Subject: [PATCH] Remove ALTSVC related code HTTP/2 and HPACK are going to be published as RFC, but ALTSVC is still in draft state. To make our API stable, it would be better to remove ALTSVC API for 1.0.0 release. --- lib/includes/nghttp2/nghttp2.h | 73 +--------------------------------- lib/nghttp2_frame.h | 2 +- lib/nghttp2_submit.c | 9 ----- src/app_helper.cc | 30 -------------- src/shrpx.cc | 8 ++-- src/shrpx_http2_upstream.cc | 18 --------- 6 files changed, 7 insertions(+), 133 deletions(-) diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 32b9b2d6..98c1d4f0 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -495,21 +495,6 @@ typedef enum { NGHTTP2_CONTINUATION = 0x09 } nghttp2_frame_type; -/** - * @enum - * - * The extension frame types. - * - * TODO: The assigned frame types were carried from draft-12, and now - * actually TBD. - */ -typedef enum { - /** - * The ALTSVC extension frame. - */ - NGHTTP2_EXT_ALTSVC = 0x0a -} nghttp2_ext_frame_type; - /** * @enum * @@ -1078,52 +1063,12 @@ typedef struct { * The pointer to extension payload. The exact pointer type is * determined by hd.type. * - * If hd.type == :enum:`NGHTTP2_EXT_ALTSVC`, it is a pointer to - * :type:`nghttp2_ext_altsvc`. + * Currently, no extension is supported. This is a place holder for + * the future extensions. */ void *payload; } nghttp2_extension; -/** - * @struct - * - * The ALTSVC extension frame payload. It has following members: - */ -typedef struct { - /** - * Protocol ID - */ - uint8_t *protocol_id; - /** - * Host - */ - uint8_t *host; - /** - * Origin - */ - uint8_t *origin; - /** - * The length of |protocol_id| - */ - size_t protocol_id_len; - /** - * The length of |host| - */ - size_t host_len; - /** - * The length of |origin| - */ - size_t origin_len; - /** - * Max-Age - */ - uint32_t max_age; - /** - * Port - */ - uint16_t port; -} nghttp2_ext_altsvc; - /** * @union * @@ -3419,20 +3364,6 @@ NGHTTP2_EXTERN int nghttp2_submit_window_update(nghttp2_session *session, int32_t stream_id, int32_t window_size_increment); -/** - * @function - * - * This function previously submits ALTSVC frame with given - * parameters, but is deprecated and will be removed in a future - * release. This function does nothing and just return 0. - */ -NGHTTP2_EXTERN int -nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags, - int32_t stream_id, uint32_t max_age, uint16_t port, - const uint8_t *protocol_id, size_t protocol_id_len, - const uint8_t *host, size_t host_len, - const uint8_t *origin, size_t origin_len); - /** * @function * diff --git a/lib/nghttp2_frame.h b/lib/nghttp2_frame.h index 2c4d6e9c..7fc336c1 100644 --- a/lib/nghttp2_frame.h +++ b/lib/nghttp2_frame.h @@ -75,7 +75,7 @@ #define NGHTTP2_MAX_PADLEN 256 /* Union of extension frame payload */ -typedef union { nghttp2_ext_altsvc altsvc; } nghttp2_ext_frame_payload; +typedef union { int dummy; } nghttp2_ext_frame_payload; void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd); diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index bde78a20..40d82ac5 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -376,15 +376,6 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags, return 0; } -int nghttp2_submit_altsvc(nghttp2_session *session _U_, uint8_t flags _U_, - int32_t stream_id _U_, uint32_t max_age _U_, - uint16_t port _U_, const uint8_t *protocol_id _U_, - size_t protocol_id_len _U_, const uint8_t *host _U_, - size_t host_len _U_, const uint8_t *origin _U_, - size_t origin_len _U_) { - return 0; -} - static uint8_t set_request_flags(const nghttp2_priority_spec *pri_spec, const nghttp2_data_provider *data_prd) { uint8_t flags = NGHTTP2_FLAG_NONE; diff --git a/src/app_helper.cc b/src/app_helper.cc index af7653c1..e23fddd2 100644 --- a/src/app_helper.cc +++ b/src/app_helper.cc @@ -130,8 +130,6 @@ const char *strframetype(uint8_t type) { return "GOAWAY"; case NGHTTP2_WINDOW_UPDATE: return "WINDOW_UPDATE"; - case NGHTTP2_EXT_ALTSVC: - return "ALTSVC"; default: return "UNKNOWN"; } @@ -362,34 +360,6 @@ void print_frame(print_type ptype, const nghttp2_frame *frame) { fprintf(outfile, "(window_size_increment=%d)\n", frame->window_update.window_size_increment); break; - case NGHTTP2_EXT_ALTSVC: { - print_frame_attr_indent(); - - auto altsvc = static_cast(frame->ext.payload); - - fprintf(outfile, "(max-age=%u, port=%u, protocol_id=", altsvc->max_age, - altsvc->port); - - if (altsvc->protocol_id_len) { - fwrite(altsvc->protocol_id, altsvc->protocol_id_len, 1, outfile); - } - - fprintf(outfile, ", host="); - - if (altsvc->host_len) { - fwrite(altsvc->host, altsvc->host_len, 1, outfile); - } - - fprintf(outfile, ", origin="); - - if (altsvc->origin_len) { - fwrite(altsvc->origin, altsvc->origin_len, 1, outfile); - } - - fprintf(outfile, ")\n"); - - break; - } default: break; } diff --git a/src/shrpx.cc b/src/shrpx.cc index 9273f7e9..86e4a637 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1342,10 +1342,10 @@ HTTP: --altsvc= Specify protocol ID, port, host and origin of alternative service. and are optional. - They are advertised in alt-svc header field or HTTP/2 - ALTSVC frame. This option can be used multiple times to - specify multiple alternative services. Example: - --altsvc=h2,443 + They are advertised in alt-svc header field only in + HTTP/1.1 frontend. This option can be used multiple + times to specify multiple alternative services. + Example: --altsvc=h2,443 --add-response-header=
Specify additional header field to add to response header set. This option just appends header field and diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index f7915561..64af8afa 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -734,24 +734,6 @@ Http2Upstream::Http2Upstream(ClientHandler *handler) } } - if (!get_config()->altsvcs.empty()) { - // Set max_age to 24hrs, which is default for alt-svc header - // field. - for (auto &altsvc : get_config()->altsvcs) { - rv = nghttp2_submit_altsvc( - session_, NGHTTP2_FLAG_NONE, 0, 86400, altsvc.port, - reinterpret_cast(altsvc.protocol_id), - altsvc.protocol_id_len, - reinterpret_cast(altsvc.host), altsvc.host_len, - reinterpret_cast(altsvc.origin), altsvc.origin_len); - - if (rv != 0) { - ULOG(ERROR, this) << "nghttp2_submit_altsvc() returned error: " - << nghttp2_strerror(rv); - } - } - } - // We wait for SETTINGS ACK at least 10 seconds. ev_timer_init(&settings_timer_, settings_timeout_cb, 10., 0.);