Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions plugins/header_rewrite/operators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1242,20 +1242,6 @@ OperatorSetPluginCntl::initialize(Parser &p)
}
}

// This operator should be allowed everywhere
void
OperatorSetPluginCntl::initialize_hooks()
{
add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_READ_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_REMAP_PSEUDO_HOOK);
add_allowed_hook(TS_HTTP_PRE_REMAP_HOOK);
add_allowed_hook(TS_HTTP_SEND_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_TXN_CLOSE_HOOK);
add_allowed_hook(TS_HTTP_TXN_START_HOOK);
}

bool
OperatorSetPluginCntl::exec(const Resources &res) const
{
Expand Down Expand Up @@ -1431,20 +1417,6 @@ OperatorSetStateFlag::initialize(Parser &p)
}
}

// This operator should be allowed everywhere
void
OperatorSetStateFlag::initialize_hooks()
{
add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_READ_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_REMAP_PSEUDO_HOOK);
add_allowed_hook(TS_HTTP_PRE_REMAP_HOOK);
add_allowed_hook(TS_HTTP_SEND_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_TXN_CLOSE_HOOK);
add_allowed_hook(TS_HTTP_TXN_START_HOOK);
}

bool
OperatorSetStateFlag::exec(const Resources &res) const
{
Expand Down Expand Up @@ -1485,20 +1457,6 @@ OperatorSetStateInt8::initialize(Parser &p)
}
}

// This operator should be allowed everywhere
void
OperatorSetStateInt8::initialize_hooks()
{
add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_READ_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_REMAP_PSEUDO_HOOK);
add_allowed_hook(TS_HTTP_PRE_REMAP_HOOK);
add_allowed_hook(TS_HTTP_SEND_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_TXN_CLOSE_HOOK);
add_allowed_hook(TS_HTTP_TXN_START_HOOK);
}

bool
OperatorSetStateInt8::exec(const Resources &res) const
{
Expand Down Expand Up @@ -1555,20 +1513,6 @@ OperatorSetStateInt16::initialize(Parser &p)
}
}

// This operator should be allowed everywhere
void
OperatorSetStateInt16::initialize_hooks()
{
add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_READ_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
add_allowed_hook(TS_REMAP_PSEUDO_HOOK);
add_allowed_hook(TS_HTTP_PRE_REMAP_HOOK);
add_allowed_hook(TS_HTTP_SEND_REQUEST_HDR_HOOK);
add_allowed_hook(TS_HTTP_TXN_CLOSE_HOOK);
add_allowed_hook(TS_HTTP_TXN_START_HOOK);
}

bool
OperatorSetStateInt16::exec(const Resources &res) const
{
Expand Down
4 changes: 0 additions & 4 deletions plugins/header_rewrite/operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ class OperatorSetPluginCntl : public Operator
};

protected:
void initialize_hooks() override;
bool exec(const Resources &res) const override;

bool
Expand Down Expand Up @@ -560,7 +559,6 @@ class OperatorSetStateFlag : public Operator
void initialize(Parser &p) override;

protected:
void initialize_hooks() override;
bool exec(const Resources &res) const override;

bool
Expand Down Expand Up @@ -598,7 +596,6 @@ class OperatorSetStateInt8 : public Operator
void initialize(Parser &p) override;

protected:
void initialize_hooks() override;
bool exec(const Resources &res) const override;

bool
Expand Down Expand Up @@ -635,7 +632,6 @@ class OperatorSetStateInt16 : public Operator
void initialize(Parser &p) override;

protected:
void initialize_hooks() override;
bool exec(const Resources &res) const override;

bool
Expand Down
9 changes: 7 additions & 2 deletions tests/gold_tests/pluginTest/header_rewrite/post_remap.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

# Global header_rewrite ruleset that fires after remapping, on the remapped
# request, before the cache lookup. The value is the remapped host, so an
# earlier hook would record the pristine host instead.
# earlier hook would record the pristine host instead. Setting a state flag
# also verifies that operators which inherit the default hook list are valid
# at POST_REMAP_HOOK.
cond %{POST_REMAP_HOOK}
set-state-flag 0 true
set-header X-Post-Remap-Host "%{URL:HOST}"

# Echo the post-remap header into the client response so the rule above can be
# observed on a cache hit, where no request is forwarded to the origin.
# observed on a cache hit, where no request is forwarded to the origin. The
# state condition proves that the state operator also ran at POST_REMAP_HOOK.
cond %{SEND_RESPONSE_HDR_HOOK}
cond %{STATE-FLAG:0} =TRUE
set-header X-Post-Remap-Echo "%{CLIENT-HEADER:X-Post-Remap-Host}"
Comment thread
bneradt marked this conversation as resolved.