Collect all resources
| 30 | |
| 31 | // Collect all resources |
| 32 | void |
| 33 | Resources::gather(const ResourceIDs ids, TSHttpHookID hook) |
| 34 | { |
| 35 | Dbg(pi_dbg_ctl, "Building resources, hook=%s", TSHttpHookNameLookup(hook)); |
| 36 | |
| 37 | Dbg(pi_dbg_ctl, "Gathering resources for hook %s with IDs %d", TSHttpHookNameLookup(hook), ids); |
| 38 | |
| 39 | // If we need the client request headers, make sure it's also available in the client vars. |
| 40 | if (ids & RSRC_CLIENT_REQUEST_HEADERS) { |
| 41 | Dbg(pi_dbg_ctl, "\tAdding TXN client request header buffers"); |
| 42 | if (TSHttpTxnClientReqGet(state.txnp, &client_bufp, &client_hdr_loc) != TS_SUCCESS) { |
| 43 | Dbg(pi_dbg_ctl, "could not gather bufp/hdr_loc for request"); |
| 44 | return; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | switch (hook) { |
| 49 | case TS_HTTP_READ_RESPONSE_HDR_HOOK: |
| 50 | // Read response headers from server |
| 51 | if ((ids & RSRC_SERVER_RESPONSE_HEADERS) || (ids & RSRC_RESPONSE_STATUS)) { |
| 52 | Dbg(pi_dbg_ctl, "\tAdding TXN server response header buffers"); |
| 53 | if (TSHttpTxnServerRespGet(state.txnp, &bufp, &hdr_loc) != TS_SUCCESS) { |
| 54 | Dbg(pi_dbg_ctl, "could not gather bufp/hdr_loc for response"); |
| 55 | return; |
| 56 | } |
| 57 | if (ids & RSRC_RESPONSE_STATUS) { |
| 58 | Dbg(pi_dbg_ctl, "\tAdding TXN server response status resource"); |
| 59 | resp_status = TSHttpHdrStatusGet(bufp, hdr_loc); |
| 60 | } |
| 61 | } |
| 62 | break; |
| 63 | |
| 64 | case TS_HTTP_SEND_REQUEST_HDR_HOOK: |
| 65 | Dbg(pi_dbg_ctl, "Processing TS_HTTP_SEND_REQUEST_HDR_HOOK"); |
| 66 | // Read request headers to server |
| 67 | if (ids & RSRC_SERVER_REQUEST_HEADERS) { |
| 68 | Dbg(pi_dbg_ctl, "\tAdding TXN server request header buffers"); |
| 69 | if (TSHttpTxnServerReqGet(state.txnp, &bufp, &hdr_loc) != TS_SUCCESS) { |
| 70 | Dbg(pi_dbg_ctl, "could not gather bufp/hdr_loc for request"); |
| 71 | return; |
| 72 | } |
| 73 | } |
| 74 | break; |
| 75 | |
| 76 | case TS_HTTP_READ_REQUEST_HDR_HOOK: |
| 77 | case TS_HTTP_PRE_REMAP_HOOK: |
| 78 | // Read request from client |
| 79 | if (ids & RSRC_CLIENT_REQUEST_HEADERS) { |
| 80 | bufp = client_bufp; |
| 81 | hdr_loc = client_hdr_loc; |
| 82 | } |
| 83 | break; |
| 84 | |
| 85 | case TS_HTTP_SEND_RESPONSE_HDR_HOOK: |
| 86 | // Send response headers to client |
| 87 | if (ids & RSRC_CLIENT_RESPONSE_HEADERS) { |
| 88 | Dbg(pi_dbg_ctl, "\tAdding TXN client response header buffers"); |
| 89 | if (TSHttpTxnClientRespGet(state.txnp, &bufp, &hdr_loc) != TS_SUCCESS) { |
no test coverage detected