diff --git a/cpp/functions/core/http_request.cpp b/cpp/functions/core/http_request.cpp index bb196165..4f481a03 100644 --- a/cpp/functions/core/http_request.cpp +++ b/cpp/functions/core/http_request.cpp @@ -269,8 +269,21 @@ Response request(const Request& req) { } cmd << ' ' << sh_q(req.url) - << " -o " << sh_q(tmp_body_out) - << " 2>&1"; + << " -o " << sh_q(tmp_body_out); + + // On POSIX we go through /bin/sh -c via popen, so `2>&1` is a shell redirect. + // On Windows we use CreateProcessW (no shell): `2>&1` would be passed as an + // extra positional arg to curl, which treats it as a second URL → "Bad + // hostname" (exit 3). stderr is already merged via STARTUPINFOW.hStdError. +#ifndef _WIN32 + cmd << " 2>&1"; +#endif + + if (std::getenv("FN_HTTP_DEBUG")) { + fprintf(stderr, "[fn_http debug] cmdline: %s\n", cmd.str().c_str()); + fprintf(stderr, "[fn_http debug] req.url=[%s] len=%zu\n", + req.url.c_str(), req.url.size()); + } // Capture stderr (curl prints transport errors to stderr with -sS). std::string curl_stderr;