postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Show compressed body size

Open Eomm opened this issue 6 years ago • 53 comments

Hi, the Size: field shows the amount of uncompressed payload:

image

And if I remove the response header (to avoid the uncompression of Postman) I get the size I'm interested:

image

Could we add a Before uncompression field?

image

Thanks

Related to https://github.com/postmanlabs/postman-app-support/issues/5885

Eomm avatar Nov 07 '19 08:11 Eomm

+1

I've spent some time trying to make my server do gzip compression automatically, and it would be nice if Postman could help me verify the actual transfer size.

MilosRandelovic avatar Mar 29 '20 04:03 MilosRandelovic

+1

thoughtworks200 avatar May 06 '20 16:05 thoughtworks200

+1

tafia avatar Jan 04 '21 10:01 tafia

+1

jonasfrid avatar Feb 15 '21 08:02 jonasfrid

+1

vaibhavpacharya avatar Feb 15 '21 15:02 vaibhavpacharya

@shamasis - any movement on this?

Samreay avatar Mar 04 '21 12:03 Samreay

+1

tamirs9876 avatar Mar 04 '21 15:03 tamirs9876

@shamasis +1

ElliotNB avatar Apr 30 '21 06:04 ElliotNB

+1

goriunov avatar May 29 '21 00:05 goriunov

+1

pedrotambo avatar Jun 07 '21 20:06 pedrotambo

+1

augustoicaro avatar Aug 22 '21 17:08 augustoicaro

+1

danielramireze avatar Sep 05 '21 13:09 danielramireze

+1

lada avatar Oct 06 '21 10:10 lada

+1

wilsonssss avatar Oct 12 '21 01:10 wilsonssss

+1

goforgold avatar Oct 16 '21 11:10 goforgold

+1

s00pa avatar Oct 27 '21 07:10 s00pa

+1

dranitski avatar Jan 19 '22 16:01 dranitski

+1

alexkev avatar Jan 27 '22 16:01 alexkev

+1

raymondKelly avatar Mar 15 '22 18:03 raymondKelly

+1

MonsterMetroid avatar Apr 06 '22 21:04 MonsterMetroid

2 1/2 years, any updates on this?

juber-nunes avatar Apr 12 '22 17:04 juber-nunes

Our team is considering switching to Insomnia for this exact reason. We need to know the uncompressed response size in order to test what's going on with API limitations from our providers. Would love to see a fix.

okcthulhu avatar Aug 03 '22 15:08 okcthulhu

Note This is not an official resolution.

A workaround I use is to either console.log the information I need or use the Postman visualizer.

Here's a script I drop in to the Tests tab to use the visualizer and inspect the body size:

const template = `
<b>Response body size (bytes):</b>
<ul>
<li>Body size: {{bodySize}}</li>
<li>Content size: {{contentSize}}</li>
<li>Compression: {{compression}}</li>
</ul>
`;

const bodySize = pm.response.text().length;
const contentSize = pm.response.size().body;
const compression = bodySize - contentSize; // bytes saved

pm.visualizer.set(template, { bodySize, contentSize, compression })

You have to select the Visualize tab in the Response pane, and it looks something like this:

image

kevinswiber avatar Aug 03 '22 18:08 kevinswiber

@kevinswiber

const template = `
<b>Response body size (bytes):</b>
<ul>
<li>Body size: {{bodySize}}</li>
<li>Content size: {{contentSize}}</li>
<li>Compression: {{compression}}</li>
</ul>
`;

const bodySize = pm.response.text().length;
const contentSize = pm.response.size().body;
const compression = bodySize - contentSize; // bytes saved

pm.visualizer.set(template, { bodySize, contentSize, compression })

This actually gives me a negative compression:

image

This must be the difference between the raw text and the expanded/pretty JSON displayed. Or maybe you inverted body and content size ?

const contentSize = pm.response.text().length;
const bodySize = pm.response.size().body;

Anyway, this is miles away of the real compressed size that I can read from Chrome: ~25KB instead of ~146KB

image

Albob avatar Aug 24 '22 14:08 Albob

And yeah +1 on this request 👍

Albob avatar Aug 24 '22 14:08 Albob

+1

zhao1532072926 avatar Sep 26 '22 03:09 zhao1532072926

@Albob There could be a number of reasons for this. My first guess would be that the Content-Length header isn't matching the actual length of the response body. This can happen when proxies, for example, modify the response body without modifying the value of the Content-Length header. The compression value should never be less than zero.

Why is Chrome showing different results? That's an interesting one. Check the Accept-Encoding request header in Postman and make sure it matches what you're seeing in Chrome. Then check the Content-Encoding response header in both Postman and Chrome to make sure they match.

kevinswiber avatar Sep 26 '22 19:09 kevinswiber

+1

yevhenii-username avatar Jan 16 '23 13:01 yevhenii-username

seriously? I have a chunked transfer encoded gzip stream with no content length at all, and not even via the dev tools is this available? Calls to the proxy, sure. And in the console, all of the response headers, but the actual like to the body? Body is more than 10 KB and can only be viewed in editor. Except the uncompressed version is 140 megs, and printing it "pretty" isn't great.

Bad form, Peter! [Hook reference for you younguns Guess its back to curl again.. and not the windows one, which apparently doesn't support --compressed

wsl curl --compressed -so /dev/null http://www.whatsmyip.org/http-compression-test/ -w '%{size_download}'

joebone avatar Feb 06 '23 05:02 joebone

+1

wilbit avatar Mar 22 '23 08:03 wilbit