From 0bd86b28ac34a843e74801419600d5cd70572c62 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 18 Oct 2025 12:45:16 -0500 Subject: [PATCH] Fix `curl -s` --- src/lib/commands/curl.test.ts | 8 +++++--- src/lib/commands/curl.ts | 8 ++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/commands/curl.test.ts b/src/lib/commands/curl.test.ts index 2f1fade6..b6f29454 100644 --- a/src/lib/commands/curl.test.ts +++ b/src/lib/commands/curl.test.ts @@ -190,7 +190,7 @@ describe('CurlCommand', () => { expect(result.stdout).toContain('100 12 100 12'); }); - it('should be silent when -s flag is used', async () => { + it('should still output response body when -s flag is used', async () => { const mockResponse = { ok: true, status: 200, @@ -205,7 +205,7 @@ describe('CurlCommand', () => { const result = await curlCommand.execute(['-s', 'https://example.com'], '/test'); expect(result.exitCode).toBe(0); - expect(result.stdout).toBe(''); + expect(result.stdout).toBe('Hello World'); }); it('should handle HTTP error responses', async () => { @@ -272,7 +272,9 @@ describe('CurlCommand', () => { const result = await curlCommand.execute(['-si', 'https://example.com'], '/test'); expect(result.exitCode).toBe(0); - expect(result.stdout).toBe(''); // Silent mode + // Silent mode still shows response body and headers (when -i is used) + expect(result.stdout).toContain('HTTP/1.1 200 OK'); + expect(result.stdout).toContain('Hello World'); }); it('should handle write-out format', async () => { diff --git a/src/lib/commands/curl.ts b/src/lib/commands/curl.ts index 6333b2e4..8a806f29 100644 --- a/src/lib/commands/curl.ts +++ b/src/lib/commands/curl.ts @@ -171,14 +171,10 @@ export class CurlCommand implements ShellCommand { // Handle write-out format if (options.writeOut) { const writeOutResult = this.formatWriteOut(options.writeOut, response, responseText); - if (options.silent) { - return createSuccessResult(writeOutResult); - } else { - output += '\n' + writeOutResult; - } + output += '\n' + writeOutResult; } - return createSuccessResult(options.silent ? '' : output); + return createSuccessResult(output); } catch (error) { if (timeoutId) {