Fix ephemeral response body reading

This commit is contained in:
Gregory Schier
2025-09-22 14:07:25 -07:00
parent 8fe50959b9
commit b3414ee60f
7 changed files with 11 additions and 13 deletions

View File

@@ -720,13 +720,10 @@ async fn cmd_format_json(text: &str) -> YaakResult<String> {
#[tauri::command]
async fn cmd_http_response_body<R: Runtime>(
window: WebviewWindow<R>,
app_handle: AppHandle<R>,
plugin_manager: State<'_, PluginManager>,
response_id: &str,
response: HttpResponse,
filter: Option<&str>,
) -> YaakResult<FilterResponse> {
let response = app_handle.db().get_http_response(response_id)?;
let body_path = match response.body_path {
None => {
return Err(GenericError("Response body path not set".to_string()));
@@ -836,7 +833,7 @@ async fn cmd_get_http_authentication_config<R: Runtime>(
AnyModel::Workspace(m) => (m.id, None),
m => {
return Err(GenericError(format!("Unsupported model to call auth config {m:?}")));
},
}
};
let environment_chain =

View File

@@ -51,7 +51,7 @@ export function ConfirmLargeResponse({ children, response }: Props) {
color="secondary"
variant="border"
size="xs"
text={() => getResponseBodyText({ responseId: response.id, filter: null })}
text={() => getResponseBodyText({ response, filter: null })}
/>
)}
</HStack>

View File

@@ -44,8 +44,8 @@ const icons = {
copy_check: lucide.CopyCheck,
download: lucide.DownloadIcon,
ellipsis: lucide.EllipsisIcon,
external_link: lucide.ExternalLinkIcon,
expand: lucide.ExpandIcon,
external_link: lucide.ExternalLinkIcon,
eye: lucide.EyeIcon,
eye_closed: lucide.EyeOffIcon,
file_code: lucide.FileCodeIcon,
@@ -95,6 +95,7 @@ const icons = {
puzzle: lucide.PuzzleIcon,
refresh: lucide.RefreshCwIcon,
rocket: lucide.RocketIcon,
rows_2: lucide.Rows2Icon,
save: lucide.SaveIcon,
search: lucide.SearchIcon,
send_horizontal: lucide.SendHorizonalIcon,

View File

@@ -7,7 +7,7 @@ export function useCopyHttpResponse(response: HttpResponse) {
return useFastMutation({
mutationKey: ['copy_http_response', response.id],
async mutationFn() {
const body = await getResponseBodyText({ responseId: response.id, filter: null });
const body = await getResponseBodyText({ response, filter: null });
copyToClipboard(body);
},
});

View File

@@ -66,7 +66,7 @@ export function useIntrospectGraphQL(
return setError(response.error);
}
const bodyText = await getResponseBodyText({ responseId: response.id, filter: null });
const bodyText = await getResponseBodyText({ response, filter: null });
if (response.status < 200 || response.status >= 300) {
return setError(
`Request failed with status ${response.status}.\nThe response text is:\n\n${bodyText}`,

View File

@@ -17,6 +17,6 @@ export function useResponseBodyText({
response.contentLength,
filter ?? '',
],
queryFn: () => getResponseBodyText({ responseId: response.id, filter }),
queryFn: () => getResponseBodyText({ response, filter }),
});
}

View File

@@ -4,14 +4,14 @@ import type { ServerSentEvent } from '@yaakapp-internal/sse';
import { invokeCmd } from './tauri';
export async function getResponseBodyText({
responseId,
response,
filter,
}: {
responseId: string;
response: HttpResponse;
filter: string | null;
}): Promise<string | null> {
const result = await invokeCmd<FilterResponse>('cmd_http_response_body', {
responseId,
response,
filter,
});