MCPcopy Create free account
hub / github.com/apache/trafficserver / EditRedirectResponse

Function EditRedirectResponse

plugins/header_rewrite/operators.cc:505–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505void
506EditRedirectResponse(TSHttpTxn txnp, const std::string &location, TSHttpStatus status, TSMBuffer bufp, TSMLoc hdr_loc)
507{
508 // Set new location.
509 TSMLoc field_loc;
510 static std::string header("Location");
511 if (TS_SUCCESS == TSMimeHdrFieldCreateNamed(bufp, hdr_loc, header.c_str(), header.size(), &field_loc)) {
512 if (TS_SUCCESS == TSMimeHdrFieldValueStringSet(bufp, hdr_loc, field_loc, -1, location.c_str(), location.size())) {
513 Dbg(pi_dbg_ctl, " Adding header %s", header.c_str());
514 TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
515 }
516 const char *reason = TSHttpHdrReasonLookup(status);
517 size_t len = strlen(reason);
518 TSHttpHdrReasonSet(bufp, hdr_loc, reason, len);
519 TSHandleMLocRelease(bufp, hdr_loc, field_loc);
520 }
521
522 // Set the body.
523 static std::string msg = "<HTML>\n<HEAD>\n<TITLE>Document Has Moved</TITLE>\n</HEAD>\n"
524 "<BODY BGCOLOR=\"white\" FGCOLOR=\"black\">\n"
525 "<H1>Document Has Moved</H1>\n<HR>\n<FONT FACE=\"Helvetica,Arial\"><B>\n"
526 "Description: The document you requested has moved to a new location."
527 " The new location is \"" +
528 location + "\".\n</B></FONT>\n<HR>\n</BODY>\n";
529 TSHttpTxnErrorBodySet(txnp, TSstrdup(msg.c_str()), msg.length(), TSstrdup("text/html"));
530}
531
532bool
533OperatorSetRedirect::exec(const Resources &res) const

Callers 1

execMethod · 0.85

Calls 11

TSMimeHdrFieldAppendFunction · 0.85
TSHttpHdrReasonLookupFunction · 0.85
TSHttpHdrReasonSetFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSHttpTxnErrorBodySetFunction · 0.85
TSstrdupFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected