You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/11/16 01:23:32 UTC
[trafficserver] branch 7.1.x updated: Preserve Accept-Encoding
header for H2 Server Push promise.
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new 3daaac9 Preserve Accept-Encoding header for H2 Server Push promise.
3daaac9 is described below
commit 3daaac9273fe0ba8af3ae3e90cfa2d6408dab053
Author: David Calavera <da...@gmail.com>
AuthorDate: Fri Aug 18 17:38:15 2017 -0700
Preserve Accept-Encoding header for H2 Server Push promise.
This change maintains API compatibility.
Preserve the Accept-Encoding header from the original client request to
send H2 Server Push promises. With this change, responses initiated by a
Server Push promise can be compressed based on the accepted encoding.
Otherwise, the response body can never be compressed.
Signed-off-by: David Calavera <da...@gmail.com>
(cherry picked from commit 9fad29f04cf20f4185b39b538a55e9d04a41cf14)
---
proxy/InkAPI.cc | 9 ++++++++-
proxy/http2/Http2ConnectionState.cc | 17 ++++++++++++++++-
proxy/http2/Http2ConnectionState.h | 2 +-
proxy/http2/Http2Stream.cc | 4 ++--
proxy/http2/Http2Stream.h | 2 +-
5 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 2f4626f..f2a94f8 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7681,12 +7681,19 @@ TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len)
url_obj.destroy();
return;
}
+
HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
Http2Stream *stream = dynamic_cast<Http2Stream *>(sm->ua_session);
if (stream) {
Http2ClientSession *parent = static_cast<Http2ClientSession *>(stream->get_parent());
if (!parent->is_url_pushed(url, url_len)) {
- stream->push_promise(url_obj);
+ HTTPHdr *hptr = &(sm->t_state.hdr_info.client_request);
+ TSMLoc obj = reinterpret_cast<TSMLoc>(hptr->m_http);
+
+ MIMEHdrImpl *mh = _hdr_mloc_to_mime_hdr_impl(obj);
+ MIMEField *f = mime_hdr_field_find(mh, MIME_FIELD_ACCEPT_ENCODING, MIME_LEN_ACCEPT_ENCODING);
+ stream->push_promise(url_obj, f);
+
parent->add_url_to_pushed_table(url, url_len);
}
}
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index c38c919..fa1fb29 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1427,7 +1427,7 @@ Http2ConnectionState::send_headers_frame(Http2Stream *stream)
}
void
-Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
+Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, const MIMEField *accept_encoding)
{
HTTPHdr h1_hdr, h2_hdr;
uint8_t *buf = nullptr;
@@ -1446,6 +1446,21 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
h1_hdr.create(HTTP_TYPE_REQUEST);
h1_hdr.url_set(&url);
h1_hdr.method_set("GET", 3);
+ if (accept_encoding != nullptr) {
+ MIMEField *f;
+ const char *name;
+ int name_len;
+ const char *value;
+ int value_len;
+
+ name = accept_encoding->name_get(&name_len);
+ f = h1_hdr.field_create(name, name_len);
+ value = accept_encoding->value_get(&value_len);
+ f->value_set(h1_hdr.m_heap, h1_hdr.m_mime, value, value_len);
+
+ h1_hdr.field_attach(f);
+ }
+
http2_generate_h2_header_from_1_1(&h1_hdr, &h2_hdr);
buf_len = h1_hdr.length_get() * 2; // Make it double just in case
diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h
index 2bd63a7..911a8de 100644
--- a/proxy/http2/Http2ConnectionState.h
+++ b/proxy/http2/Http2ConnectionState.h
@@ -237,7 +237,7 @@ public:
Http2SendDataFrameResult send_data_frames(Http2Stream *stream);
Http2SendDataFrameResult send_a_data_frame(Http2Stream *stream, size_t &payload_length);
void send_headers_frame(Http2Stream *stream);
- void send_push_promise_frame(Http2Stream *stream, URL &url);
+ void send_push_promise_frame(Http2Stream *stream, URL &url, const MIMEField *accept_encoding);
void send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec);
void send_settings_frame(const Http2ConnectionSettings &new_settings);
void send_ping_frame(Http2StreamId id, uint8_t flag, const uint8_t *opaque_data);
diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
index 7b5ed4a..c9da909 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -630,10 +630,10 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len,
}
void
-Http2Stream::push_promise(URL &url)
+Http2Stream::push_promise(URL &url, const MIMEField *accept_encoding)
{
Http2ClientSession *parent = static_cast<Http2ClientSession *>(this->get_parent());
- parent->connection_state.send_push_promise_frame(this, url);
+ parent->connection_state.send_push_promise_frame(this, url, accept_encoding);
}
void
diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
index 2261377..4c83158 100644
--- a/proxy/http2/Http2Stream.h
+++ b/proxy/http2/Http2Stream.h
@@ -175,7 +175,7 @@ public:
void reenable(VIO *vio);
virtual void transaction_done();
void send_response_body();
- void push_promise(URL &url);
+ void push_promise(URL &url, const MIMEField *accept_encoding);
// Stream level window size
ssize_t client_rwnd, server_rwnd;
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].