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 2019/11/08 18:53:58 UTC
[trafficserver] branch 9.0.x updated: Revert "Change API to return
a TSReturnCode code."
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new ebc3ec1 Revert "Change API to return a TSReturnCode code."
ebc3ec1 is described below
commit ebc3ec1e5d73b3b1e383eea521eda91ec59ffe53
Author: Leif Hedstrom <le...@ogre.com>
AuthorDate: Fri Nov 8 11:48:25 2019 -0700
Revert "Change API to return a TSReturnCode code."
This reverts commit 469d4d8c05c28291d40e26af8cce2abc01fc03b7.
---
.../api/functions/TSHttpTxnServerPush.en.rst | 9 +++--
include/ts/ts.h | 9 -----
proxy/http2/Http2ConnectionState.cc | 11 +++---
proxy/http2/Http2ConnectionState.h | 2 +-
proxy/http2/Http2Stream.cc | 4 +--
proxy/http2/Http2Stream.h | 2 +-
src/traffic_server/InkAPI.cc | 41 ++++++++--------------
7 files changed, 30 insertions(+), 48 deletions(-)
diff --git a/doc/developer-guide/api/functions/TSHttpTxnServerPush.en.rst b/doc/developer-guide/api/functions/TSHttpTxnServerPush.en.rst
index 299172f..3e43cd2 100644
--- a/doc/developer-guide/api/functions/TSHttpTxnServerPush.en.rst
+++ b/doc/developer-guide/api/functions/TSHttpTxnServerPush.en.rst
@@ -28,7 +28,7 @@ Synopsis
#include <ts/experimental.h>
-.. function:: TSReturnCode TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len)
+.. function:: void TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len)
Description
===========
@@ -40,8 +40,11 @@ is not disabled by the client. You can call this API without checking whether
Server Push is available on the transaction and it does nothing if Server Push
is not available.
-This API returns an error if the URL to push is not valid, the client has Server Push disabled,
-or there is an error creating the H/2 PUSH_PROMISE frame.
+
+Notes
+=====
+
+This API may be changed in the future version since it is experimental.
See Also
========
diff --git a/include/ts/ts.h b/include/ts/ts.h
index 79ad523..60828f9 100644
--- a/include/ts/ts.h
+++ b/include/ts/ts.h
@@ -2535,15 +2535,6 @@ tsapi TSReturnCode TSRemapToUrlGet(TSHttpTxn txnp, TSMLoc *urlLocp);
*/
tsapi TSIOBufferReader TSHttpTxnPostBufferReaderGet(TSHttpTxn txnp);
-/**
- * Initiate an HTTP/2 Server Push preload request.
- * Use this api to register a URL that you want to preload with HTTP/2 Server Push.
- *
- * @param url the URL string to preload.
- * @param url_len the length of the URL string.
- */
-tsapi TSReturnCode TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index b23e0a5..7fb41ce 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1639,7 +1639,7 @@ Http2ConnectionState::send_headers_frame(Http2Stream *stream)
ats_free(buf);
}
-bool
+void
Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, const MIMEField *accept_encoding)
{
HTTPHdr h1_hdr, h2_hdr;
@@ -1651,7 +1651,7 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, con
uint8_t flags = 0x00;
if (client_settings.get(HTTP2_SETTINGS_ENABLE_PUSH) == 0) {
- return false;
+ return;
}
Http2StreamDebug(ua_session, stream->get_id(), "Send PUSH_PROMISE frame");
@@ -1681,14 +1681,14 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, con
buf = static_cast<uint8_t *>(ats_malloc(buf_len));
if (buf == nullptr) {
h2_hdr.destroy();
- return false;
+ return;
}
Http2ErrorCode result = http2_encode_header_blocks(&h2_hdr, buf, buf_len, &header_blocks_size, *(this->remote_hpack_handle),
client_settings.get(HTTP2_SETTINGS_HEADER_TABLE_SIZE));
if (result != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) {
h2_hdr.destroy();
ats_free(buf);
- return false;
+ return;
}
// Send a PUSH_PROMISE frame
@@ -1736,7 +1736,7 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, con
stream = this->create_stream(id, error);
if (!stream) {
h2_hdr.destroy();
- return false;
+ return;
}
SCOPED_MUTEX_LOCK(stream_lock, stream->mutex, this_ethread());
@@ -1759,7 +1759,6 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url, con
stream->send_request(*this);
h2_hdr.destroy();
- return true;
}
void
diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h
index afd4385..01c80cf 100644
--- a/proxy/http2/Http2ConnectionState.h
+++ b/proxy/http2/Http2ConnectionState.h
@@ -247,7 +247,7 @@ public:
void send_data_frames(Http2Stream *stream);
Http2SendDataFrameResult send_a_data_frame(Http2Stream *stream, size_t &payload_length);
void send_headers_frame(Http2Stream *stream);
- bool send_push_promise_frame(Http2Stream *stream, URL &url, const MIMEField *accept_encoding);
+ 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 eb98c4c..8d2d5c6 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -683,12 +683,12 @@ Http2Stream::signal_write_event(bool call_update)
}
}
-bool
+void
Http2Stream::push_promise(URL &url, const MIMEField *accept_encoding)
{
Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(this->_proxy_ssn);
SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread());
- return h2_proxy_ssn->connection_state.send_push_promise_frame(this, url, accept_encoding);
+ h2_proxy_ssn->connection_state.send_push_promise_frame(this, url, accept_encoding);
}
void
diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
index 6a522a8..58baee6 100644
--- a/proxy/http2/Http2Stream.h
+++ b/proxy/http2/Http2Stream.h
@@ -75,7 +75,7 @@ public:
void update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool send_update);
void signal_write_event(bool call_update);
void restart_sending();
- bool push_promise(URL &url, const MIMEField *accept_encoding);
+ void push_promise(URL &url, const MIMEField *accept_encoding);
// Stream level window size
ssize_t client_rwnd() const;
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index fb910e0..1d9dea3 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -8026,7 +8026,7 @@ TSHttpTxnIsInternal(TSHttpTxn txnp)
return TSHttpSsnIsInternal(TSHttpTxnSsnGet(txnp));
}
-TSReturnCode
+void
TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len)
{
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
@@ -8035,37 +8035,26 @@ TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len)
url_obj.create(nullptr);
if (url_obj.parse(url, url_len) == PARSE_RESULT_ERROR) {
url_obj.destroy();
- return TS_ERROR;
+ return;
}
HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
Http2Stream *stream = dynamic_cast<Http2Stream *>(sm->ua_txn);
- if (stream == nullptr) {
- url_obj.destroy();
- return TS_ERROR;
- }
-
- Http2ClientSession *ua_session = static_cast<Http2ClientSession *>(stream->get_proxy_ssn());
- SCOPED_MUTEX_LOCK(lock, ua_session->mutex, this_ethread());
- if (ua_session->connection_state.is_state_closed() || ua_session->is_url_pushed(url, url_len)) {
- url_obj.destroy();
- return TS_ERROR;
- }
-
- 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);
- if (!stream->push_promise(url_obj, f)) {
- url_obj.destroy();
- return TS_ERROR;
+ if (stream) {
+ Http2ClientSession *ua_session = static_cast<Http2ClientSession *>(stream->get_proxy_ssn());
+ SCOPED_MUTEX_LOCK(lock, ua_session->mutex, this_ethread());
+ if (!ua_session->connection_state.is_state_closed() && !ua_session->is_url_pushed(url, url_len)) {
+ 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);
+
+ ua_session->add_url_to_pushed_table(url, url_len);
+ }
}
-
- ua_session->add_url_to_pushed_table(url, url_len);
-
url_obj.destroy();
- return TS_SUCCESS;
}
TSReturnCode