MCPcopy Create free account
hub / github.com/continuedev/continue / executeHttpHook

Function executeHttpHook

extensions/cli/src/hooks/hookRunner.ts:136–208  ·  view source on GitHub ↗
(
  handler: HttpHookHandler,
  input: HookInput,
)

Source from the content-addressed store, hash-verified

134}
135
136async function executeHttpHook(
137 handler: HttpHookHandler,
138 input: HookInput,
139): Promise<HookExecutionResult> {
140 const timeoutMs = (handler.timeout ?? DEFAULT_HTTP_TIMEOUT_SECONDS) * 1000;
141
142 try {
143 const headers: Record<string, string> = {
144 "Content-Type": "application/json",
145 };
146
147 if (handler.headers) {
148 const allowedVars = handler.allowedEnvVars ?? [];
149 for (const [key, value] of Object.entries(handler.headers)) {
150 headers[key] = interpolateEnvVars(value, allowedVars);
151 }
152 }
153
154 const controller = new AbortController();
155 const timeout = setTimeout(() => controller.abort(), timeoutMs);
156
157 const response = await fetch(handler.url, {
158 method: "POST",
159 headers,
160 body: JSON.stringify(input),
161 signal: controller.signal,
162 });
163
164 clearTimeout(timeout);
165
166 if (!response.ok) {
167 // Non-2xx = non-blocking error (matches Claude Code behavior)
168 logger.warn(`HTTP hook returned ${response.status}: ${handler.url}`);
169 return {
170 output: null,
171 stdout: "",
172 stderr: `HTTP ${response.status}`,
173 exitCode: 1,
174 blocked: false,
175 };
176 }
177
178 const bodyText = await response.text();
179 const output = tryParseJson(bodyText);
180
181 let blocked = false;
182 let blockReason: string | undefined;
183
184 if (output?.decision === "block") {
185 blocked = true;
186 blockReason = output.reason || "Blocked by hook";
187 }
188
189 return {
190 output,
191 stdout: bodyText.trim(),
192 stderr: "",
193 exitCode: 0,

Callers 1

executeHandlerFunction · 0.85

Calls 6

interpolateEnvVarsFunction · 0.85
warnMethod · 0.80
textMethod · 0.80
tryParseJsonFunction · 0.70
fetchFunction · 0.50
abortMethod · 0.45

Tested by

no test coverage detected