#include <ts/ts.h>

TSReturnCode TSHttpTxnServerRespGet(TSHttpTxn txnp, TSMBuffer * bufp, TSMLoc * offset)


Get the response header sent by the upstream server. This will only be useful in a callback on a hook that is called after the upstream responds, and if there was an upstream response. For instance, if the inbound request has no remap rule and remap is required then there will be no server response because no outbound connection was made. In this case the function will return TS_ERROR.

The response header is returned in bufp and offset. bufp is the heap in which the header resides, and offset is the location in that heap. These will be used in subsequent calls to retrieve information from the header.

int get_response_status(TSHttpTxn txn) {
   TSMBuffer resp_heap = nullptr;
   TSMLoc resp_hdr = nullptr;
   if (TS_SUCCESS == TSHttpTxnServerRespGet(tnx, &resp_heap, &resp_hdr)) {
      return TSHttpHdrStatusGet(resp_headp, resp_hdr);