Skip to content

Conversation

@zwoop
Copy link
Contributor

@zwoop zwoop commented Jan 23, 2019

These changes include:

  1. Adds a new option, --allow-304 / -a, which allows 304 responses
    to still kick off a background fetch. This is important for request
    that comes in with e.g.

    Range: bytes=0-12
    If-Modified-Since: Tue, 22 Jan 2019 19:36:03 GMT

  2. Similar, to make the conditional request succeed properly with
    conditional requests, we have to filter out more headers. In addition
    to the Range: header, we now also filter out any values of

    If-Match
    If-Modified-Since
    If-None-Match
    If-Range
    If-Unmodified-Since

  3. To make all of this work with both global and per-remap setups,
    we generalize the option parsing to work equally for both types. To
    be backward compatible, a single option without a leading '-' is
    assumed to be the name of the configuration file, but the correct
    way to use this in a remap plugin is

    @pparam=--config=/some/config/file.conf

  4. In addition, while reading up on this, we should allow the
    background fetch to be kicked off with an If-Range header.

@zwoop zwoop added this to the 9.0.0 milestone Jan 23, 2019
@zwoop zwoop self-assigned this Jan 23, 2019
@zwoop
Copy link
Contributor Author

zwoop commented Jan 23, 2019

This still needs some more testing, so don't land yet. I wanted to see that it compiles on all compilers / platforms, and also get some initial input.

@zwoop
Copy link
Contributor Author

zwoop commented Jan 24, 2019

I made a few changes / fixes, and I think this is ready for review now. I've tested it with both global and remap plugins, and various configurations etc.

@SolidWallOfCode
Copy link
Member

Should you remove the WIP label then?

Copy link
Member

@SolidWallOfCode SolidWallOfCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for one major blemish.

#include <string>
#include <unordered_map>
#include <cinttypes>
#include <string_view>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that on purpose? By Turing's right patella, you've changed.

gConfig->readConfig(optarg);
break;
}
if (!gConfig) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this checked because of potential remap use? Would it be reasonable to assume that if TSPluginInit is called at all, it's called before any remap rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a remnant from something stupid, I’ll remove it.

TSDebug(PLUGIN_NAME, "Initialized");
TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, cont);
} else {
// ToDo: Hmmm, no way to fail a global plugin here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTSOTPR, but this has come up before. We need to do something for that.


*ih = (void *)config;
if (success) {
*ih = (void *)config;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO C STYLE CASTS!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually surprised a cast is needed, as a pointer of any type should auto convert to a void*.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t remember, the code was like that before :)

@zwoop
Copy link
Contributor Author

zwoop commented Jan 26, 2019

What’s the major blemish?

@SolidWallOfCode
Copy link
Member

Using a C style cast.

@zwoop
Copy link
Contributor Author

zwoop commented Jan 26, 2019

Gah, that’s the way it was ... I didn’t add it! But, I’ll go through the entire plugin and fix it up.

@SolidWallOfCode
Copy link
Member

You just need to do it on code you touched.

@zwoop zwoop removed the WIP label Jan 28, 2019
@zwoop
Copy link
Contributor Author

zwoop commented Jan 28, 2019

Updated with the review comments, thanks!

These changes include:

1) Adds a new option, --allow-304 / -a, which allows 304 responses
to still kick off a background fetch. This is important for request
that comes in with e.g.

     Range: bytes=0-12
     If-Modified-Since: Tue, 22 Jan 2019 19:36:03 GMT

2) Similar, to make the conditional request succeed properly with
conditional requests, we have to filter out more headers. In addition
to the Range: header, we now also filter out any values of

   If-Match
   If-Modified-Since
   If-None-Match
   If-Range
   If-Unmodified-Since

3) To make all of this work with both global and per-remap setups,
we generalize the option parsing to work equally for both types. To
be backward compatible, a single option without a leading '-' is
assumed to be the name of the configuration file, but the correct
way to use this in a remap plugin is

    @pparam=--config=/some/config/file.conf

4) In addition, while reading up on this, we should allow the
background fetch to be kicked off with an If-Range header.
@zwoop zwoop merged commit 140e3a3 into apache:master Jan 28, 2019
@zwoop zwoop deleted the FixesToBGFetch branch January 28, 2019 15:28
@zwoop
Copy link
Contributor Author

zwoop commented Feb 5, 2019

Cherry-picked to 8.0.x

@zwoop zwoop modified the milestones: 9.0.0, 8.0.3 Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants