Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statichit: misc. fixes #7634

Merged
merged 1 commit into from
Mar 27, 2021
Merged
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
13 changes: 13 additions & 0 deletions plugins/experimental/statichit/statichit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,15 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
return TSREMAP_NO_REMAP;
}

// Anchor to URL specified in remap
int pathsz;
TSUrlPathGet(rri->requestBufp, rri->requestUrl, &pathsz);
if (pathsz > 0) {
VERROR("Path is not an exact match. Rejecting!");
TSHttpTxnStatusSet(rh, TS_HTTP_STATUS_NOT_FOUND);
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add an error message - VERROR("...");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @shukitchan ! Added a VERROR

return TSREMAP_NO_REMAP;
}

if (!cfg->maxAge) {
TSHttpTxnConfigIntSet(rh, TS_CONFIG_HTTP_CACHE_HTTP, 0);
StaticHitSetupIntercept(static_cast<StaticHitConfig *>(ih), rh);
Expand Down Expand Up @@ -631,6 +640,10 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
return TS_ERROR;
}

if (filePath.find("/") != 0) {
filePath = std::string(TSConfigDirGet()) + '/' + filePath;
}

StaticHitConfig *tc = new StaticHitConfig(filePath, mimeType);
if (maxAge > 0) {
tc->maxAge = maxAge;
Expand Down