////////////////////////////////////////////////////////////////////////// This is the main continuation.
| 1078 | /////////////////////////////////////////////////////////////////////////////// |
| 1079 | // This is the main continuation. |
| 1080 | int |
| 1081 | event_handler(TSCont cont, TSEvent event, void *edata) |
| 1082 | { |
| 1083 | TSHttpTxn txnp = static_cast<TSHttpTxn>(edata); |
| 1084 | S3Config *s3 = static_cast<S3Config *>(TSContDataGet(cont)); |
| 1085 | TSEvent enable_event = TS_EVENT_HTTP_CONTINUE; |
| 1086 | |
| 1087 | { |
| 1088 | S3Request request(txnp); |
| 1089 | TSHttpStatus status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR; |
| 1090 | |
| 1091 | switch (event) { |
| 1092 | case TS_EVENT_HTTP_SEND_REQUEST_HDR: |
| 1093 | if (request.initialize()) { |
| 1094 | std::shared_lock lock(s3->reload_mutex); |
| 1095 | status = request.authorize(s3); |
| 1096 | } |
| 1097 | |
| 1098 | if (TS_HTTP_STATUS_OK == status) { |
| 1099 | Dbg(dbg_ctl, "Successfully signed the URL"); |
| 1100 | } else { |
| 1101 | Dbg(dbg_ctl, "Failed to sign the URL, status = %d", status); |
| 1102 | TSHttpTxnStatusSet(txnp, status); |
| 1103 | enable_event = TS_EVENT_HTTP_ERROR; |
| 1104 | } |
| 1105 | break; |
| 1106 | default: |
| 1107 | TSError("[%s] Unknown event for this plugin", PLUGIN_NAME); |
| 1108 | Dbg(dbg_ctl, "unknown event for this plugin"); |
| 1109 | break; |
| 1110 | } |
| 1111 | // Most get S3Request out of scope in case the later plugins invalidate the TSAPI |
| 1112 | // objects it references. Some cases were causing asserts from the destructor |
| 1113 | } |
| 1114 | |
| 1115 | TSHttpTxnReenable(txnp, enable_event); |
| 1116 | return 0; |
| 1117 | } |
| 1118 | |
| 1119 | // If the token has more than one hour to expire, reload is scheduled one hour before expiration. |
| 1120 | // If the token has less than one hour to expire, reload is scheduled 15 minutes before expiration. |
nothing calls this directly
no test coverage detected