You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2014/03/29 00:31:34 UTC
[12/13] git commit: TS-2675: metalink: Reformat comments
TS-2675: metalink: Reformat comments
metalink: Clarify that we *must* check TSVConnClosedGet(), if only to clean up allocated data
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a9a0b7cc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a9a0b7cc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a9a0b7cc
Branch: refs/heads/master
Commit: a9a0b7ccbbff448fd14ea2b22930ce6fc8b2c95f
Parents: f9d74b9
Author: Jack Bates <ja...@nottheoilrig.com>
Authored: Fri Mar 21 12:21:32 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 28 16:23:54 2014 -0700
----------------------------------------------------------------------
doc/reference/plugins/metalink.en.rst | 16 +-
plugins/experimental/metalink/metalink.cc | 298 +++++++++++--------
.../experimental/metalink/test/chunkedEncoding | 18 +-
.../metalink/test/chunkedEncodingDisconnect | 18 +-
.../experimental/metalink/test/contentLength | 11 +-
.../metalink/test/contentLengthDisconnect | 16 +-
.../test/finalChunkedEncodingDisconnect | 22 +-
plugins/experimental/metalink/test/http09 | 13 +-
plugins/experimental/metalink/test/location | 8 +-
plugins/experimental/metalink/test/longer | 18 +-
.../metalink/test/pipeliningDisconnect | 8 +-
.../test/shortChunkedEncodingDisconnect | 14 +-
.../metalink/test/shortClientDisconnect | 4 +-
.../metalink/test/shortContentLengthDisconnect | 14 +-
14 files changed, 273 insertions(+), 205 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/doc/reference/plugins/metalink.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/metalink.en.rst b/doc/reference/plugins/metalink.en.rst
index 50e1b32..ea71a87 100644
--- a/doc/reference/plugins/metalink.en.rst
+++ b/doc/reference/plugins/metalink.en.rst
@@ -6,7 +6,7 @@
except in compliance with the License. You may obtain a copy of
the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -70,13 +70,13 @@ Implementation Status
---------------------
The plugin implements the ``TS_HTTP_SEND_RESPONSE_HDR_HOOK`` hook to
-check and potentially rewrite the :mailheader:`Location: ...` and
-:mailheader:`Digest: SHA-256=...` headers after responses are cached.
-It doesn't do it before they're cached because the contents of the
-cache can change after responses are cached. It uses
-:c:func:`TSCacheRead` to check if the URL in the
-:mailheader:`Location: ...` header is already cached. In future, the
-plugin should also check if the URL is fresh or not.
+check and potentially rewrite the :mailheader:`Location` and
+:mailheader:`Digest` headers after responses are cached. It doesn't
+do it before they're cached because the contents of the cache can
+change after responses are cached. It uses :c:func:`TSCacheRead` to
+check if the URL in the :mailheader:`Location` header is already
+cached. In future, the plugin should also check if the URL is fresh
+or not.
The plugin implements the ``TS_HTTP_READ_RESPONSE_HDR_HOOK`` hook and
`a null transformation`_ to compute the SHA-256 digest for content as
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/metalink.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/metalink.cc b/plugins/experimental/metalink/metalink.cc
index ae8771c..207fdf1 100644
--- a/plugins/experimental/metalink/metalink.cc
+++ b/plugins/experimental/metalink/metalink.cc
@@ -27,21 +27,22 @@
#include "ts/ts.h"
-/* Implement TS_HTTP_READ_RESPONSE_HDR_HOOK to implement a null transformation.
- * Compute the SHA-256 digest of the content, write it to the cache and store
- * the request URL at that key.
+/* Implement TS_HTTP_READ_RESPONSE_HDR_HOOK to implement a null
+ * transformation. Compute the SHA-256 digest of the content, write
+ * it to the cache and store the request URL at that key.
*
- * Implement TS_HTTP_SEND_RESPONSE_HDR_HOOK to check the "Location: ..." and
- * "Digest: SHA-256=..." headers. Use TSCacheRead() to check if the URL in the
- * "Location: ..." header is already cached. If not, potentially rewrite that
- * header. Do this after responses are cached because the cache will change.
+ * Implement TS_HTTP_SEND_RESPONSE_HDR_HOOK to check the Location and
+ * Digest headers. Use TSCacheRead() to check if the URL in the
+ * Location header is already cached. If not, potentially rewrite
+ * that header. Do this after responses are cached because the cache
+ * will change.
*
* More details are on the [wiki page] in the Traffic Server wiki.
*
* [wiki page] https://cwiki.apache.org/confluence/display/TS/Metalink */
-/* TSCacheWrite() and TSVConnWrite() data: Write the digest to the cache and
- * store the request URL at that key */
+/* TSCacheWrite() and TSVConnWrite() data: Write the digest to the
+ * cache and store the request URL at that key */
typedef struct {
TSHttpTxn txnp;
@@ -67,8 +68,8 @@ typedef struct {
} TransformData;
-/* TSCacheRead() and TSVConnRead() data: Check the "Location: ..." and
- * "Digest: SHA-256=..." headers */
+/* TSCacheRead() and TSVConnRead() data: Check the Location and Digest
+ * headers */
typedef struct {
TSHttpTxn txnp;
@@ -76,14 +77,14 @@ typedef struct {
TSMBuffer resp_bufp;
TSMLoc hdr_loc;
- /* "Location: ..." header */
+ /* Location header */
TSMLoc location_loc;
/* Cache key */
TSMLoc url_loc;
TSCacheKey key;
- /* "Digest: SHA-256=..." header */
+ /* Digest header */
TSMLoc digest_loc;
/* Digest header field value index */
@@ -96,7 +97,8 @@ typedef struct {
} SendData;
-/* Implement TS_HTTP_READ_RESPONSE_HDR_HOOK to implement a null transformation */
+/* Implement TS_HTTP_READ_RESPONSE_HDR_HOOK to implement a null
+ * transformation */
/* Write the digest to the cache and store the request URL at that key */
@@ -187,9 +189,9 @@ write_vconn_write_complete(TSCont contp, void */* edata ATS_UNUSED */)
WriteData *data = (WriteData *) TSContDataGet(contp);
TSContDestroy(contp);
- /* The object is not committed to the cache until the vconnection is closed.
- * When all the data has been transferred, the user (contp) must do a
- * TSVConnClose() */
+ /* The object is not committed to the cache until the VConnection is
+ * closed. When all the data has been transferred, the user (contp)
+ * must do a TSVConnClose() */
TSVConnClose(data->connp);
TSIOBufferDestroy(data->cache_bufp);
@@ -198,8 +200,8 @@ write_vconn_write_complete(TSCont contp, void */* edata ATS_UNUSED */)
return 0;
}
-/* TSCacheWrite() and TSVConnWrite() handler: Write the digest to the cache and
- * store the request URL at that key */
+/* TSCacheWrite() and TSVConnWrite() handler: Write the digest to the
+ * cache and store the request URL at that key */
static int
write_handler(TSCont contp, TSEvent event, void *edata)
@@ -221,64 +223,113 @@ write_handler(TSCont contp, TSEvent event, void *edata)
return 0;
}
-/* Copy content from the input buffer to the output buffer without modification
- * and feed it through the message digest at the same time.
+/* Copy content from the input buffer to the output buffer without
+ * modification and feed it through the message digest at the same
+ * time.
*
- * 1. Check if we are "closed" before doing anything else to avoid errors.
+ * 1. Check if we are "closed" before doing anything else to avoid
+ * errors.
* 2. Then deal with any input that's available now.
- * 3. Check if the input is complete after dealing with any available input
- * in case it was the last of it. If it is complete, tell downstream,
- * thank upstream, and finish computing the digest. Otherwise either
- * wait for more input or abort if upstream is "closed".
+ * 3. Check if the input is complete after dealing with any
+ * available input in case it was the last of it. If it is
+ * complete, tell downstream, thank upstream, and finish
+ * computing the digest. Otherwise either wait for more input
+ * or abort if upstream is "closed".
*
- * The handler is guaranteed to get called at least once, even if the response
- * is 304 Not Modified, so we are guaranteed an opportunity to clean up e.g.
- * data that we allocated when we called TSTransformCreate().
+ * The handler is guaranteed to get called at least once, even if the
+ * response is 304 Not Modified, so we are guaranteed an opportunity
+ * to clean up e.g. data that we allocated when we called
+ * TSTransformCreate().
*
- * TS_EVENT_VCONN_WRITE_READY and TS_EVENT_VCONN_WRITE_COMPLETE events are sent
- * from downstream, e.g. by TransformTerminus::handle_event().
- * TS_EVENT_IMMEDIATE events are sent by INKVConnInternal::do_io_write(),
- * INKVConnInternal::do_io_close(), and INKVConnInternal::reenable() which are
- * called from upstream, e.g. by TransformVConnection::do_io_write(),
- * TransformVConnection::do_io_close(), and HttpTunnel::producer_handler().
+ * TS_EVENT_VCONN_WRITE_READY and TS_EVENT_VCONN_WRITE_COMPLETE events
+ * are sent from downstream, e.g. by
+ * TransformTerminus::handle_event(). TS_EVENT_IMMEDIATE events are
+ * sent by INKVConnInternal::do_io_write(),
+ * INKVConnInternal::do_io_close(), and INKVConnInternal::reenable()
+ * which are called from upstream, e.g. by
+ * TransformVConnection::do_io_write(),
+ * TransformVConnection::do_io_close(), and
+ * HttpTunnel::producer_handler().
*
- * Clean up the output buffer on TS_EVENT_VCONN_WRITE_COMPLETE and not before.
- * We are guaranteed a TS_EVENT_VCONN_WRITE_COMPLETE event *unless* we are
- * "closed". In that case we instead get a TS_EVENT_IMMEDIATE event where
- * TSVConnClosedGet() is one, so clean up the output buffer in that case as
- * well. We'll only ever get one event where TSVConnClosedGet() is one and it
- * will be our last, so there's no risk of a double free.
+ * Clean up the output buffer on TS_EVENT_VCONN_WRITE_COMPLETE and not
+ * before. We are guaranteed a TS_EVENT_VCONN_WRITE_COMPLETE event
+ * *unless* we are "closed". In that case we instead get a
+ * TS_EVENT_IMMEDIATE event where TSVConnClosedGet() is one. We'll
+ * only ever get one event where TSVConnClosedGet() is one and it will
+ * be our last, so we *must* check for this case and clean up then
+ * too. Because we'll only ever get one such event and it will be our
+ * last, there's no risk of double freeing.
*
- * The response headers get sent when TSVConnWrite() gets called and not
- * before. (We could potentially edit them until then.)
+ * The response headers get sent when TSVConnWrite() gets called and
+ * not before. (We could potentially edit them until then.)
*
- * The events say nothing about the state of the input. Gather this instead
- * from TSVConnClosedGet(), TSVIOReaderGet(), and TSVIONTodoGet() and handle
- * the end of the input independently from the TS_EVENT_VCONN_WRITE_COMPLETE
- * event from downstream.
+ * The events say nothing about the state of the input. Gather this
+ * instead from TSVConnClosedGet(), TSVIOReaderGet(), and
+ * TSVIONTodoGet() and handle the end of the input independently from
+ * the TS_EVENT_VCONN_WRITE_COMPLETE event from downstream.
*
- * When TSVConnClosedGet() is one, *we* are "closed". Some state is already
- * inconsistent and there's nothing to do except clean up. (This happens when
- * the response is 304 Not Modified or when the client or origin disconnect
- * before the message is complete.)
+ * When TSVConnClosedGet() is one, *we* are "closed". We *must* check
+ * for this case, if only to clean up allocated data. Some state is
+ * already inconsistent. (This happens when the response is 304 Not
+ * Modified or when the client or origin disconnect before the message
+ * is complete.)
*
- * When TSVIOReaderGet() is NULL, upstream is "closed". In that case it's
- * clearly an error to call TSIOBufferReaderAvail(), it's also an error at that
- * point to send any events upstream with TSContCall(). (This happens when the
- * content length is zero or when we get the final chunk of a
- * "Transfer-Encoding: chunked" response.)
+ * When TSVIOReaderGet() is NULL, upstream is "closed". In that case
+ * it's clearly an error to call TSIOBufferReaderAvail(), it's also an
+ * error at that point to send any events upstream with TSContCall().
+ * (This happens when the content length is zero or when we get the
+ * final chunk of a chunked response.)
*
- * The input is complete only when TSVIONTodoGet() is zero. (Don't update the
- * downstream nbytes otherwise!) Update the downstream nbytes when the input
- * is complete in case the response is "Transfer-Encoding: chunked" (in which
- * case nbytes is unknown until then). Downstream will (normally) send the
- * TS_EVENT_VCONN_WRITE_COMPLETE event (and the final chunk if the response is
- * "Transfer-Encoding: chunked") when ndone equals nbytes and not before.
+ * The input is complete only when TSVIONTodoGet() is zero. (Don't
+ * update the downstream nbytes otherwise!) Update the downstream
+ * nbytes when the input is complete in case the response is chunked
+ * (in which case nbytes is unknown until then). Downstream will
+ * (normally) send the TS_EVENT_VCONN_WRITE_COMPLETE event (and the
+ * final chunk if the response is chunked) when ndone equals nbytes
+ * and not before.
*
- * Send our own TS_EVENT_VCONN_WRITE_COMPLETE event upstream when the input is
- * complete otherwise HttpSM::update_stats() won't get called and the
- * transaction won't get logged. (If there are upstream transformations they
- * won't get a chance to clean up otherwise!) */
+ * Send our own TS_EVENT_VCONN_WRITE_COMPLETE event upstream when the
+ * input is complete otherwise HttpSM::update_stats() won't get called
+ * and the transaction won't get logged. (If there are upstream
+ * transformations they won't get a chance to clean up otherwise!)
+ *
+ * Summary of the cases into which each event can fall:
+ *
+ * Closed *We* are "closed". Clean up allocated data.
+ *
+ * Start First (and last) time the handler was called.
+ * (This happens when the response is 304 Not Modified.)
+ *
+ * Not start (This happens when the client or origin disconnect
+ * before the message is complete.)
+ *
+ * Start First time the handler was called. Initialize
+ * data here because we can't call TSVConnWrite()
+ * before TS_HTTP_RESPONSE_TRANSFORM_HOOK.
+ *
+ * Content length
+ *
+ * Chunked response
+ *
+ * Upstream closed
+ * (This happens when the content length is zero or
+ * when we get the final chunk of a chunked
+ * response.)
+ *
+ * Available input
+ *
+ * Input complete
+ *
+ * Deja vu There might be multiple TS_EVENT_IMMEDIATE events
+ * between the end of the input and the
+ * TS_EVENT_VCONN_WRITE_COMPLETE event from
+ * downstream.
+ *
+ * Not deja vu
+ * Tell downstream and thank upstream.
+ *
+ * Downstream complete
+ * Clean up the output buffer. */
static int
vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
@@ -290,16 +341,18 @@ vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
TransformData *transform_data = (TransformData *) TSContDataGet(contp);
- /* Check if we are "closed" before doing anything else to avoid errors. Some
- * state is already inconsistent and there's nothing to do except clean up.
- * (This happens if the response is 304 Not Modified or if the client or
+ /* Check if we are "closed" before doing anything else to avoid
+ * errors. We *must* check for this case, if only to clean up
+ * allocated data. Some state is already inconsistent. (This
+ * happens if the response is 304 Not Modified or if the client or
* origin disconnect before the message is complete.) */
int closed = TSVConnClosedGet(contp);
if (closed) {
TSContDestroy(contp);
/* Avoid failed assert "sdk_sanity_check_iocore_structure(bufp) ==
- * TS_SUCCESS" in TSIOBufferDestroy() if the response is 304 Not Modified */
+ * TS_SUCCESS" in TSIOBufferDestroy() if the response is 304 Not
+ * Modified */
if (transform_data->output_bufp) {
TSIOBufferDestroy(transform_data->output_bufp);
}
@@ -319,20 +372,19 @@ vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
transform_data->output_bufp = TSIOBufferCreate();
TSIOBufferReader readerp = TSIOBufferReaderAlloc(transform_data->output_bufp);
- /* Determines the "Content-Length: ..." header
- * (or "Transfer-Encoding: chunked") */
+ /* Determines the Content-Length header (or a chunked response) */
- /* Avoid failed assert "nbytes >= 0" if "Transfer-Encoding: chunked" */
+ /* Avoid failed assert "nbytes >= 0" if the response is chunked */
int nbytes = TSVIONBytesGet(input_viop);
transform_data->output_viop = TSVConnWrite(output_connp, contp, readerp, nbytes < 0 ? INT64_MAX : nbytes);
SHA256_Init(&transform_data->c);
}
- /* Then deal with any input that's available now. Avoid failed assert
- * "sdk_sanity_check_iocore_structure(readerp) == TS_SUCCESS" in
- * TSIOBufferReaderAvail() if the content length is zero or when we get the
- * final chunk of a "Transfer-Encoding: chunked" response. */
+ /* Then deal with any input that's available now. Avoid failed
+ * assert "sdk_sanity_check_iocore_structure(readerp) == TS_SUCCESS"
+ * in TSIOBufferReaderAvail() if the content length is zero or when
+ * we get the final chunk of a chunked response. */
TSIOBufferReader readerp = TSVIOReaderGet(input_viop);
if (readerp) {
@@ -359,18 +411,19 @@ vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
}
}
- /* Check if the input is complete after dealing with any available input in
- * case it was the last of it */
+ /* Check if the input is complete after dealing with any available
+ * input in case it was the last of it */
int ntodo = TSVIONTodoGet(input_viop);
if (ntodo) {
TSVIOReenable(transform_data->output_viop);
TSContCall(TSVIOContGet(input_viop), TS_EVENT_VCONN_WRITE_READY, input_viop);
- /* Don't finish computing the digest (and tell downstream and thank upstream)
- * more than once! There might be multiple TS_EVENT_IMMEDIATE events between
- * the end of the input and the TS_EVENT_VCONN_WRITE_COMPLETE event from
- * downstream, e.g. INKVConnInternal::reenable() is called by
+ /* Don't finish computing the digest (and tell downstream and thank
+ * upstream) more than once! There might be multiple
+ * TS_EVENT_IMMEDIATE events between the end of the input and the
+ * TS_EVENT_VCONN_WRITE_COMPLETE event from downstream, e.g.
+ * INKVConnInternal::reenable() is called by
* HttpTunnel::producer_handler() when more input is available and
* TransformVConnection::do_io_shutdown() is called by
* HttpSM::tunnel_handler_transform_write() when we send our own
@@ -382,9 +435,9 @@ vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
TSVIOReenable(transform_data->output_viop);
- /* Avoid failed assert "c->alive == true" in TSContCall() if the content
- * length is zero or when we get the final chunk of a
- * "Transfer-Encoding: chunked" response */
+ /* Avoid failed assert "c->alive == true" in TSContCall() if the
+ * content length is zero or when we get the final chunk of a
+ * chunked response */
if (readerp) {
TSContCall(TSVIOContGet(input_viop), TS_EVENT_VCONN_WRITE_COMPLETE, input_viop);
}
@@ -408,8 +461,9 @@ vconn_write_ready(TSCont contp, void */* edata ATS_UNUSED */)
return 0;
}
- /* Can't reuse the TSTransformCreate() continuation because we don't know
- * whether to destroy it in cache_open_write()/cache_open_write_failed() or
+ /* Can't reuse the TSTransformCreate() continuation because we
+ * don't know whether to destroy it in
+ * cache_open_write()/cache_open_write_failed() or
* transform_vconn_write_complete() */
contp = TSContCreate(write_handler, NULL);
TSContDataSet(contp, write_data);
@@ -432,7 +486,8 @@ transform_vconn_write_complete(TSCont contp, void */* edata ATS_UNUSED */)
return 0;
}
-/* TSTransformCreate() handler: Compute the SHA-256 digest of the content */
+/* TSTransformCreate() handler: Compute the SHA-256 digest of the
+ * content */
static int
transform_handler(TSCont contp, TSEvent event, void *edata)
@@ -452,8 +507,8 @@ transform_handler(TSCont contp, TSEvent event, void *edata)
return 0;
}
-/* Compute the SHA-256 digest of the content, write it to the cache and store
- * the request URL at that key */
+/* Compute the SHA-256 digest of the content, write it to the cache
+ * and store the request URL at that key */
static int
http_read_response_hdr(TSCont /* contp ATS_UNUSED */, void *edata)
@@ -461,8 +516,8 @@ http_read_response_hdr(TSCont /* contp ATS_UNUSED */, void *edata)
TransformData *data = (TransformData *) TSmalloc(sizeof(TransformData));
data->txnp = (TSHttpTxn) edata;
- /* Can't initialize data here because we can't call TSVConnWrite() before
- * TS_HTTP_RESPONSE_TRANSFORM_HOOK */
+ /* Can't initialize data here because we can't call TSVConnWrite()
+ * before TS_HTTP_RESPONSE_TRANSFORM_HOOK */
data->output_bufp = NULL;
TSVConn connp = TSTransformCreate(transform_handler, data->txnp);
@@ -475,8 +530,8 @@ http_read_response_hdr(TSCont /* contp ATS_UNUSED */, void *edata)
return 0;
}
-/* Implement TS_HTTP_SEND_RESPONSE_HDR_HOOK to check the "Location: ..." and
- * "Digest: SHA-256=..." headers */
+/* Implement TS_HTTP_SEND_RESPONSE_HDR_HOOK to check the Location and
+ * Digest headers */
/* Read the URL stored at the digest */
@@ -515,7 +570,8 @@ cache_open_read_failed(TSCont contp, void */* edata ATS_UNUSED */)
return 0;
}
-/* TSCacheRead() handler: Check if the URL stored at the digest is cached */
+/* TSCacheRead() handler: Check if the URL stored at the digest is
+ * cached */
static int
rewrite_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
@@ -525,7 +581,7 @@ rewrite_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
switch (event) {
- /* Yes: Rewrite the "Location: ..." header and reenable the response */
+ /* Yes: Rewrite the Location header and reenable the response */
case TS_EVENT_CACHE_OPEN_READ:
TSMimeHdrFieldValuesClear(data->resp_bufp, data->hdr_loc, data->location_loc);
@@ -569,8 +625,9 @@ vconn_read_ready(TSCont contp, void */* edata ATS_UNUSED */)
/* No allocation, freed with data->cache_bufp? */
const char *value = data->value = TSIOBufferBlockReadStart(blockp, readerp, &data->length);
- /* The start pointer is both an input and an output parameter. After a
- * successful parse the start pointer equals the end pointer. */
+ /* The start pointer is both an input and an output parameter.
+ * After a successful parse the start pointer equals the end
+ * pointer. */
if (TSUrlParse(data->resp_bufp, data->url_loc, &value, value + data->length) != TS_PARSE_DONE) {
TSIOBufferDestroy(data->cache_bufp);
@@ -613,8 +670,8 @@ vconn_read_ready(TSCont contp, void */* edata ATS_UNUSED */)
return 0;
}
-/* TSCacheRead() and TSVConnRead() handler: Check if the "Digest: SHA-256=..."
- * digest already exists in the cache */
+/* TSCacheRead() and TSVConnRead() handler: Check if the digest
+ * already exists in the cache */
static int
digest_handler(TSCont contp, TSEvent event, void *edata)
@@ -639,7 +696,7 @@ digest_handler(TSCont contp, TSEvent event, void *edata)
return 0;
}
-/* TSCacheRead() handler: Check if the "Location: ..." URL is already cached */
+/* TSCacheRead() handler: Check if the Location URL is already cached */
static int
location_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
@@ -658,7 +715,7 @@ location_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
case TS_EVENT_CACHE_OPEN_READ:
break;
- /* No: Check if the "Digest: SHA-256=..." digest already exists in the cache */
+ /* No: Check if the digest already exists in the cache */
case TS_EVENT_CACHE_OPEN_READ_FAILED:
/* No allocation, freed with data->resp_bufp? */
@@ -670,7 +727,7 @@ location_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
TSHandleMLocRelease(data->resp_bufp, data->hdr_loc, data->digest_loc);
- /* Check if the "Digest: SHA-256=..." digest already exists in the cache */
+ /* Check if the digest already exists in the cache */
contp = TSContCreate(digest_handler, NULL);
TSContDataSet(contp, data);
@@ -697,9 +754,9 @@ location_handler(TSCont contp, TSEvent event, void */* edata ATS_UNUSED */)
return 0;
}
-/* Use TSCacheRead() to check if the URL in the "Location: ..." header is
- * already cached. If not, potentially rewrite that header. Do this after
- * responses are cached because the cache will change. */
+/* Use TSCacheRead() to check if the URL in the Location header is
+ * already cached. If not, potentially rewrite that header. Do this
+ * after responses are cached because the cache will change. */
static int
http_send_response_hdr(TSCont contp, void *edata)
@@ -719,20 +776,21 @@ http_send_response_hdr(TSCont contp, void *edata)
return 0;
}
- /* If Instance Digests are not provided by the Metalink servers, the Link
- * header fields pertaining to this specification MUST be ignored */
+ /* If Instance Digests are not provided by the Metalink servers, the
+ * Link header fields pertaining to this specification MUST be
+ * ignored */
- /* Metalinks contain whole file hashes as described in Section 6, and MUST
- * include SHA-256, as specified in [FIPS-180-3] */
+ /* Metalinks contain whole file hashes as described in Section 6,
+ * and MUST include SHA-256, as specified in [FIPS-180-3] */
/* Assumption: We want to minimize cache reads, so check first that
*
- * 1. the response has a "Location: ..." header and
- * 2. the response has a "Digest: SHA-256=..." header.
+ * 1. the response has a Location header and
+ * 2. the response has a Digest header.
*
* Then scan if the URL or digest already exist in the cache. */
- /* If the response has a "Location: ..." header */
+ /* If the response has a Location header */
data->location_loc = TSMimeHdrFieldFind(data->resp_bufp, data->hdr_loc, TS_MIME_FIELD_LOCATION, TS_MIME_LEN_LOCATION);
if (!data->location_loc) {
TSHandleMLocRelease(data->resp_bufp, TS_NULL_MLOC, data->hdr_loc);
@@ -745,9 +803,9 @@ http_send_response_hdr(TSCont contp, void *edata)
TSUrlCreate(data->resp_bufp, &data->url_loc);
- /* If we can't parse or lookup the "Location: ..." URL, should we still check
- * if the response has a "Digest: SHA-256=..." header? No: Can't parse or
- * lookup the URL in the "Location: ..." header is an error. */
+ /* If we can't parse or lookup the Location URL, should we still
+ * check if the response has a Digest header? No: Can't parse or
+ * lookup the URL in the Location header is an error. */
/* No allocation, freed with data->resp_bufp? */
value = TSMimeHdrFieldValueStringGet(data->resp_bufp, data->hdr_loc, data->location_loc, -1, &length);
@@ -777,7 +835,7 @@ http_send_response_hdr(TSCont contp, void *edata)
return 0;
}
- /* ... and a "Digest: SHA-256=..." header */
+ /* ... and a Digest header */
data->digest_loc = TSMimeHdrFieldFind(data->resp_bufp, data->hdr_loc, "Digest", 6);
while (data->digest_loc) {
@@ -790,7 +848,7 @@ http_send_response_hdr(TSCont contp, void *edata)
continue;
}
- /* Check if the "Location: ..." URL is already cached */
+ /* Check if the Location URL is already cached */
contp = TSContCreate(location_handler, NULL);
TSContDataSet(contp, data);
@@ -807,7 +865,7 @@ http_send_response_hdr(TSCont contp, void *edata)
data->digest_loc = next_loc;
}
- /* Didn't find a "Digest: SHA-256=..." header, just reenable the response */
+ /* Didn't find a Digest header, just reenable the response */
TSCacheKeyDestroy(data->key);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/chunkedEncoding
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/chunkedEncoding b/plugins/experimental/metalink/test/chunkedEncoding
index 7a2ed37..66c8d9b 100755
--- a/plugins/experimental/metalink/test/chunkedEncoding
+++ b/plugins/experimental/metalink/test/chunkedEncoding
@@ -39,8 +39,9 @@ class factory(http.HTTPFactory):
ctx.write('chunkedEncoding')
- # If the proxy reads the final chunk before it sends the response
- # headers, it may send a Content-Length header vs. a chunked response
+ # If the proxy reads the final chunk before it sends the
+ # response headers, it may send a Content-Length header vs. a
+ # chunked response
reactor.callLater(1, ctx.finish)
origin = tcp.Port(0, factory())
@@ -76,13 +77,14 @@ class factory(protocol.ClientFactory):
# No hope of a final chunk now
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent a Content-Length header vs. a chunked response).
- # (Override connectionLost() when the proxy crashes or stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent a Content-Length header vs. a chunked
+ # response). (Override connectionLost() when the proxy crashes or
+ # we stop the reactor.)
#
- # Data that was already received will be processed (the end of the
- # headers), then shutdown events will fire (connections will be closed),
- # and then finally the reactor will grind to a halt.
+ # Data that was already received will get processed (the end of
+ # the headers), then shutdown events will fire (connections will
+ # get closed), and then finally the reactor will grind to a halt.
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/chunkedEncodingDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/chunkedEncodingDisconnect b/plugins/experimental/metalink/test/chunkedEncodingDisconnect
index 91593d0..e39549f 100755
--- a/plugins/experimental/metalink/test/chunkedEncodingDisconnect
+++ b/plugins/experimental/metalink/test/chunkedEncodingDisconnect
@@ -17,8 +17,8 @@
# permissions and limitations under the License.
print '''1..1 chunkedEncodingDisconnect
-# The proxy closes the client connection and doesn't send a final chunk if the
-# origin disconnects without sending one'''
+# The proxy closes the client connection and doesn't send a final
+# chunk if the origin disconnects without sending one'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -40,9 +40,9 @@ class factory(http.HTTPFactory):
ctx.write('chunkedEncodingDisconnect')
- # If the origin disconnects before the proxy sends the response
- # headers, the proxy may send a Content-Length header vs. a chunked
- # response
+ # If the origin disconnects before the proxy sends the
+ # response headers, the proxy may send a Content-Length header
+ # vs. a chunked response
reactor.callLater(1, ctx.transport.loseConnection)
origin = tcp.Port(0, factory())
@@ -78,10 +78,10 @@ class factory(protocol.ClientFactory):
# Who cares what happens now?
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent a Content-Length header vs. a chunked response).
- # (Override connectionLost() when the proxy closes the client connection or
- # stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent a Content-Length header vs. a chunked
+ # response). (Override connectionLost() when the proxy closes the
+ # client connection or we stop the reactor.)
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/contentLength
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/contentLength b/plugins/experimental/metalink/test/contentLength
index 92708e7..f53efe7 100755
--- a/plugins/experimental/metalink/test/contentLength
+++ b/plugins/experimental/metalink/test/contentLength
@@ -85,12 +85,13 @@ class factory(protocol.ClientFactory):
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message.
- # (Override connectionLost() when the proxy crashes or stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message. (Override connectionLost() when the proxy crashes or
+ # we stop the reactor.)
#
- # Data that was already received will be processed (the end of the
- # headers), then shutdown events will fire (connections will be closed),
- # and then finally the reactor will grind to a halt.
+ # Data that was already received will get processed (the end of
+ # the headers), then shutdown events will fire (connections will
+ # get closed), and then finally the reactor will grind to a halt.
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/contentLengthDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/contentLengthDisconnect b/plugins/experimental/metalink/test/contentLengthDisconnect
index 1627d0e..17d927f 100755
--- a/plugins/experimental/metalink/test/contentLengthDisconnect
+++ b/plugins/experimental/metalink/test/contentLengthDisconnect
@@ -17,7 +17,8 @@
# permissions and limitations under the License.
print '''1..2 contentLengthDisconnect
-# The proxy closes the client connection if the origin disconnects prematurely'''
+# The proxy closes the client connection if the origin disconnects
+# prematurely'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -40,8 +41,9 @@ class factory(http.HTTPFactory):
ctx.setHeader('Content-Length', 24)
ctx.write('contentLengthDisconnect')
- # If the origin disconnects before the proxy sends the response
- # headers, the proxy may send the wrong Content-Length header
+ # If the origin disconnects before the proxy sends the
+ # response headers, the proxy may send the wrong
+ # Content-Length header
reactor.callLater(1, ctx.transport.loseConnection)
origin = tcp.Port(0, factory())
@@ -80,10 +82,10 @@ class factory(protocol.ClientFactory):
print 'ok 1 - Content-Length header'
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent the wrong Content-Length header). (Override
- # connectionLost() when the proxy closes the client connection or stop the
- # reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent the wrong Content-Length header).
+ # (Override connectionLost() when the proxy closes the client
+ # connection or we stop the reactor.)
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect b/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect
index 32011bc..6185e9a 100755
--- a/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect
+++ b/plugins/experimental/metalink/test/finalChunkedEncodingDisconnect
@@ -17,8 +17,8 @@
# permissions and limitations under the License.
print '''1..1 finalChunkEncodingDisconnect
-# The proxy forwards the final chunk even if the origin disconnects immediately
-# afterward'''
+# The proxy forwards the final chunk even if the origin disconnects
+# immediately afterward'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -40,8 +40,9 @@ class factory(http.HTTPFactory):
ctx.write('finalChunkedEncodingDisconnect')
- # If the proxy reads the final chunk before it sends the response
- # headers, it may send a Content-Length header vs. a chunked response
+ # If the proxy reads the final chunk before it sends the
+ # response headers, it may send a Content-Length header vs. a
+ # chunked response
def callback():
try:
ctx.finish()
@@ -89,13 +90,14 @@ class factory(protocol.ClientFactory):
# No hope of a final chunk now
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent a Content-Length header vs. a chunked response).
- # (Override connectionLost() when the proxy crashes or stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent a Content-Length header vs. a chunked
+ # response). (Override connectionLost() when the proxy crashes or
+ # we stop the reactor.)
#
- # Data that was already received will be processed (the end of the
- # headers), then shutdown events will fire (connections will be closed),
- # and then finally the reactor will grind to a halt.
+ # Data that was already received will get processed (the end of
+ # the headers), then shutdown events will fire (connections will
+ # get closed), and then finally the reactor will grind to a halt.
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/http09
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/http09 b/plugins/experimental/metalink/test/http09
index e9f7c77..b53d200 100755
--- a/plugins/experimental/metalink/test/http09
+++ b/plugins/experimental/metalink/test/http09
@@ -21,12 +21,13 @@ print '''1..1 http09
# http://www.w3.org/Protocols/HTTP/AsImplemented
#
-# The proxy crashes only after the response is complete. It closes the client
-# connection whether it crashes or not because an HTTP/0.9 response is complete
-# only after the origin closes its connection, and then the proxy normally does
-# the same thing to the client connection (although it upgrades the response to
-# HTTP/1.1). So the only way to check that the proxy didn't crash is to open
-# another connection.
+# The proxy crashes only after the response is complete. It closes
+# the client connection whether it crashes or not because an HTTP/0.9
+# response is complete only after the origin closes its connection,
+# and then the proxy normally does the same thing to the client
+# connection (although it upgrades the response to HTTP/1.1). So the
+# only way to check that the proxy didn't crash is to open another
+# connection.
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/location
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/location b/plugins/experimental/metalink/test/location
index 77b601e..97eb32a 100755
--- a/plugins/experimental/metalink/test/location
+++ b/plugins/experimental/metalink/test/location
@@ -72,10 +72,10 @@ class factory(protocol.ClientFactory):
else:
print 'not ok 1 - Did the proxy crash? (The client connection closed.)'
- # Get a response with a Location and a Digest header and check that the
- # Location header is not rewritten. Then get the same response after
- # caching a matching file from a different URL and check that this time the
- # header is rewritten.
+ # Get a response with a Location and a Digest header and check
+ # that the Location header is not rewritten. Then get the same
+ # response after caching a matching file from a different URL and
+ # check that this time the header is rewritten.
connectionMade = lambda ctx: ctx.transport.write('GET {0}:{1} HTTP/1.1\r\n\r\nGET {0}:{1}/location HTTP/1.1\r\n\r\nGET {0}:{1} HTTP/1.1\r\n\r\n'.format(*origin.socket.getsockname()))
def handleResponsePart(ctx, data):
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/longer
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/longer b/plugins/experimental/metalink/test/longer
index 259ad7d..d298451 100755
--- a/plugins/experimental/metalink/test/longer
+++ b/plugins/experimental/metalink/test/longer
@@ -17,10 +17,11 @@
# permissions and limitations under the License.
print '''1..1 longer
-# The proxy doesn't choke if the origin sends more content than it advertised'''
+# The proxy doesn't choke if the origin sends more content than it
+# advertised'''
-# Unlike the contentLength test, don't stop the reactor at the end of the
-# headers. Give the proxy time to choke.
+# Unlike the contentLength test, don't stop the reactor at the end of
+# the headers. Give the proxy time to choke.
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -78,12 +79,13 @@ class factory(protocol.ClientFactory):
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message.
- # (Override connectionLost() when the proxy crashes or stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message. (Override connectionLost() when the proxy crashes or
+ # we stop the reactor.)
#
- # Data that was already received will be processed (the end of the
- # headers), then shutdown events will fire (connections will be closed),
- # and then finally the reactor will grind to a halt.
+ # Data that was already received will get processed (the end of
+ # the headers), then shutdown events will fire (connections will
+ # get closed), and then finally the reactor will grind to a halt.
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/pipeliningDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/pipeliningDisconnect b/plugins/experimental/metalink/test/pipeliningDisconnect
index 152e2cf..2d97dc1 100755
--- a/plugins/experimental/metalink/test/pipeliningDisconnect
+++ b/plugins/experimental/metalink/test/pipeliningDisconnect
@@ -17,8 +17,8 @@
# permissions and limitations under the License.
print '''1..1 pipeliningDisconnect
-# The proxy doesn't crash if INKVConnInternal::do_io_close() gets called after
-# a message is already complete'''
+# The proxy doesn't crash if INKVConnInternal::do_io_close() gets
+# called after a message is already complete'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -83,8 +83,8 @@ class factory(protocol.ClientFactory):
def connectionMade(ctx):
# Somehow these magic words frequently cause
- # INKVConnInternal::do_io_close() to get called after a message is
- # already complete
+ # INKVConnInternal::do_io_close() to get called after a message
+ # is already complete
ctx.transport.write('GET {0}:{1}/pipeliningDisconnect0 HTTP/1.1\r\n\r\nGET {0}:{1}/pipeliningDisconnect1 HTTP/1.1\r\n\r\n'.format(*origin.socket.getsockname()))
ctx.transport.loseConnection()
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect b/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect
index 3c52858..14e5a6f 100755
--- a/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect
+++ b/plugins/experimental/metalink/test/shortChunkedEncodingDisconnect
@@ -17,9 +17,9 @@
# permissions and limitations under the License.
print '''1..1 shortChunkedEncodingDisconnect
-# The proxy closes the client connection and doesn't send a final chunk if the
-# origin disconnects without sending one, before the proxy sends the response
-# headers'''
+# The proxy closes the client connection and doesn't send a final
+# chunk if the origin disconnects without sending one, before the
+# proxy sends the response headers'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -77,10 +77,10 @@ class factory(protocol.ClientFactory):
# Who cares what happens now?
reactor.stop()
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent a Content-Length header vs. a chunked response).
- # (Override connectionLost() when the proxy closes the client connection or
- # stop the reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent a Content-Length header vs. a chunked
+ # response). (Override connectionLost() when the proxy closes the
+ # client connection or we stop the reactor.)
def handleResponseEnd(ctx):
pass
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/shortClientDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/shortClientDisconnect b/plugins/experimental/metalink/test/shortClientDisconnect
index 6956c78..a36169e 100755
--- a/plugins/experimental/metalink/test/shortClientDisconnect
+++ b/plugins/experimental/metalink/test/shortClientDisconnect
@@ -17,8 +17,8 @@
# permissions and limitations under the License.
print '''1..1 shortClientDisconnect
-# The proxy doesn't crash if the client disconnects before the proxy sends the
-# response headers'''
+# The proxy doesn't crash if the client disconnects before the proxy
+# sends the response headers'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9a0b7cc/plugins/experimental/metalink/test/shortContentLengthDisconnect
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/test/shortContentLengthDisconnect b/plugins/experimental/metalink/test/shortContentLengthDisconnect
index 5662650..b2a74fa 100755
--- a/plugins/experimental/metalink/test/shortContentLengthDisconnect
+++ b/plugins/experimental/metalink/test/shortContentLengthDisconnect
@@ -17,9 +17,9 @@
# permissions and limitations under the License.
print '''1..2 shortContentLengthDisconnect
-# The proxy sends the right Content-Length header and closes the client
-# connection if the origin disconnects before the proxy sends the response
-# headers'''
+# The proxy sends the right Content-Length header and closes the
+# client connection if the origin disconnects before the proxy sends
+# the response headers'''
from twisted.internet import error, protocol, reactor, tcp
from twisted.web import http
@@ -81,10 +81,10 @@ class factory(protocol.ClientFactory):
print 'ok 1 - Content-Length header'
- # Avoid calling undefined handleResponse() at the end of the message (if
- # the proxy sent the wrong Content-Length header). (Override
- # connectionLost() when the proxy closes the client connection or stop the
- # reactor.)
+ # Avoid calling undefined handleResponse() at the end of the
+ # message (if the proxy sent the wrong Content-Length header).
+ # (Override connectionLost() when the proxy closes the client
+ # connection or we stop the reactor.)
def handleResponseEnd(ctx):
pass