feat: support for binary body (#4466)

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Akash K
2024-11-26 19:48:01 +05:30
committed by GitHub
parent 37bf0567ea
commit 80d7dd046d
16 changed files with 261 additions and 22 deletions

View File

@@ -43,5 +43,5 @@ export interface EffectiveHoppRESTRequest extends HoppRESTRequest {
active: boolean;
description: string;
}[];
effectiveFinalBody: FormData | string | null;
effectiveFinalBody: FormData | string | File | null;
}

View File

@@ -360,7 +360,7 @@ export async function getEffectiveRESTRequest(
function getFinalBodyFromRequest(
request: HoppRESTRequest,
resolvedVariables: EnvironmentVariable[]
): E.Either<HoppCLIError, string | null | FormData> {
): E.Either<HoppCLIError, string | null | FormData | File> {
if (request.body.contentType === null) {
return E.right(null);
}
@@ -437,6 +437,20 @@ function getFinalBodyFromRequest(
);
}
if (request.body.contentType === "application/octet-stream") {
const body = request.body.body;
if (!body) {
return E.right(null);
}
if (!(body instanceof File)) {
return E.right(null);
}
return E.right(body);
}
return pipe(
parseBodyEnvVariablesE(request.body.body, resolvedVariables),
E.mapLeft((e) =>