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

Method sendLocalResponse

plugins/experimental/wasm/ats_context.cc:1482–1502  ·  view source on GitHub ↗

send pre-made response

Source from the content-addressed store, hash-verified

1480
1481// send pre-made response
1482WasmResult
1483Context::sendLocalResponse(uint32_t response_code, std::string_view body_text, Pairs additional_headers,
1484 GrpcStatusCode /* grpc_status */, std::string_view details)
1485{
1486 if (txnp_ == nullptr) {
1487 TSError("[wasm][%s] Can't send local response without a transaction", __FUNCTION__);
1488 return WasmResult::InternalFailure;
1489 } else {
1490 TSHttpTxnStatusSet(txnp_, static_cast<TSHttpStatus>(response_code));
1491
1492 if (body_text.size() > 0) {
1493 TSHttpTxnErrorBodySet(txnp_, TSstrndup(body_text.data(), body_text.size()), body_text.size(),
1494 nullptr); // Defaults to text/html
1495 }
1496
1497 local_reply_headers_ = additional_headers;
1498 local_reply_details_ = details;
1499 local_reply_ = true;
1500 }
1501 return WasmResult::Ok;
1502}
1503
1504WasmResult
1505Context::getSharedData(std::string_view key, std::pair<std::string, uint32_t> *data)

Callers

nothing calls this directly

Calls 6

TSHttpTxnStatusSetFunction · 0.85
TSHttpTxnErrorBodySetFunction · 0.85
TSstrndupFunction · 0.85
TSErrorFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected