postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.79k stars 839 forks source link

Show compressed body size #7596

Open Eomm opened 4 years ago

Eomm commented 4 years ago

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

MilosRandelovic commented 4 years ago

+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.

thoughtworks200 commented 4 years ago

+1

tafia commented 3 years ago

+1

jonasfrid commented 3 years ago

+1

vaibhavpacharya commented 3 years ago

+1

Samreay commented 3 years ago

@shamasis - any movement on this?

tamirs9876 commented 3 years ago

+1

ElliotNB commented 3 years ago

@shamasis +1

goriunov commented 3 years ago

+1

pedrotambo commented 3 years ago

+1

augustoicaro commented 2 years ago

+1

danielramireze commented 2 years ago

+1

lada commented 2 years ago

+1

wilsonssss commented 2 years ago

+1

goforgold commented 2 years ago

+1

s00pa commented 2 years ago

+1

dranitski commented 2 years ago

+1

alexkev commented 2 years ago

+1

raymondKelly commented 2 years ago

+1

MonsterMetroid commented 2 years ago

+1

juber-nunes commented 2 years ago

2 1/2 years, any updates on this?

okcthulhu commented 1 year ago

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.

kevinswiber commented 1 year ago

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
Albob commented 1 year ago

@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 commented 1 year ago

And yeah +1 on this request 👍

zhao1532072926 commented 1 year ago

+1

kevinswiber commented 1 year ago

@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.

yevhenii-username commented 1 year ago

+1

joebone commented 1 year ago

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}'

wilbit commented 1 year ago

+1

Buyukcaglar commented 1 year ago

Any updates on this feature?

icedice commented 1 year ago

I need this as well, annoying that we cannot see this out of the box.

xiekeyi98 commented 1 year ago

+1, I need this to investigate server-side performance issues and compare different compression methods( gzip , br , deflate,etc)

nastassia-citian commented 1 year ago

Anyone have any alternatives for calculating compressed response size?

icedice commented 1 year ago

Anyone have any alternatives for calculating compressed response size?

I solved it by running the traffic through mitmproxy and checking the size there, it works but it's a bit convoluted for a basic task.

Buyukcaglar commented 1 year ago

Anyone have any alternatives for calculating compressed response size?

Insomnia

bcmcq commented 1 year ago

+1 🙏

bjaraszk commented 1 year ago

+1

nastassia-citian commented 1 year ago

I ended up adding middleware to my routes to log the compressed / decompressed size. Cross checking with dev tools network tab, it seems pretty accurate.

const logDataSize = (data) => {
    console.warn(`res object size ${typeof data === 'object' ? '(compressed)' : '(decompressed)'}: `, Buffer.byteLength(JSON.stringify(data), 'utf8') / 1024 / 1024 + ' MB');
};

// Middleware function to log response size
app.use((req, res, next) => {
    const originalSend = res.send;

    if (req.app.get('env') === 'development') {
        res.send = function(data) {
            logDataSize(data);
            originalSend.call(this, data);
        };
    }

    next();
});
Greg-Hyliion commented 9 months ago

+1

TheAustinG commented 9 months ago

Do +1s even matter at this point? This issue is going on 4 years with no updates. I doubt this is even close to being on their roadmap. Super disappointing.

Anyway, +1 in case it actually does carry any weight lol

Quezler commented 8 months ago

+1

yuenhy commented 6 months ago

+1

tapionx commented 5 months ago

+1

itsdax commented 5 months ago

✨ +1 ✨

gfrancomsft commented 5 months ago

+1

cocorossello commented 4 months ago

+1

alexanderb444 commented 4 months ago

+1

Nabeelaron commented 3 months ago

Any updates on the feature request ? @shamasis

PDonoso-DMF commented 1 month ago

+1