(url2)
| 78863 | function getClientHeaders(requestOptions) { |
| 78864 | const clientHeaders = []; |
| 78865 | if (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.apiClient) { |
| 78866 | clientHeaders.push(requestOptions.apiClient); |
| 78867 | } |
| 78868 | clientHeaders.push(`${PACKAGE_LOG_HEADER}/${PACKAGE_VERSION}`); |
| 78869 | return clientHeaders.join(" "); |
| 78870 | } |
| 78871 | async function getHeaders(url2) { |
| 78872 | var _a5; |
| 78873 | const headers = new Headers(); |
| 78874 | headers.append("Content-Type", "application/json"); |
| 78875 | headers.append("x-goog-api-client", getClientHeaders(url2.requestOptions)); |
| 78876 | headers.append("x-goog-api-key", url2.apiKey); |
| 78877 | let customHeaders = (_a5 = url2.requestOptions) === null || _a5 === void 0 ? void 0 : _a5.customHeaders; |
| 78878 | if (customHeaders) { |
| 78879 | if (!(customHeaders instanceof Headers)) { |
| 78880 | try { |
| 78881 | customHeaders = new Headers(customHeaders); |
| 78882 | } catch (e3) { |
| 78883 | throw new GoogleGenerativeAIRequestInputError(`unable to convert customHeaders value ${JSON.stringify(customHeaders)} to Headers: ${e3.message}`); |
| 78884 | } |
| 78885 | } |
| 78886 | for (const [headerName, headerValue] of customHeaders.entries()) { |
| 78887 | if (headerName === "x-goog-api-key") { |
| 78888 | throw new GoogleGenerativeAIRequestInputError(`Cannot set reserved header name ${headerName}`); |
| 78889 | } else if (headerName === "x-goog-api-client") { |
| 78890 | throw new GoogleGenerativeAIRequestInputError(`Header name ${headerName} can only be set using the apiClient field`); |
| 78891 | } |
| 78892 | headers.append(headerName, headerValue); |
| 78893 | } |
no test coverage detected