meg icon indicating copy to clipboard operation
meg copied to clipboard

Display Human-readable size of the http response

Open TvMpt opened this issue 7 years ago • 4 comments

Could you show the length of the response in output? Some sites don't care about best practices and responds with 200 status code to show their custom 404 pages ("sorry not found"), making it hard to detect positive findings. With size in output we can easily filter out those findings...

TvMpt avatar Jan 08 '18 16:01 TvMpt

Hello!

That's a thought. I think that would be useful, but I don't want to go too far in to adding features all in one tool. It is a bit of a pain to find real 200 OK responses though for the reason you mention.

I'll give it some thought and get back to you :)

tomnomnom avatar Jan 09 '18 11:01 tomnomnom

Most of the analysis I do on the output files is done with standard linux tools, so I haven't really thought so much about this kind of thing yet.

To tide you over, here's a bit of bash that will list the files, the address, and the size of the file in bytes:

▶ find . -type f ! -name index -exec echo -n "{} " \; -exec head -n1 {} \; -exec stat --format=%s {} \; | paste - - | column -t
./httpbin.org/b03ba4483f82e897333812b5339b3cea56869d7e  https://httpbin.org/anything/foo/bar/         465
./httpbin.org/2f67264250a88219c3133343f12e6ef2f54eda6c  https://httpbin.org/.well-known/security.txt  712
./httpbin.org/3354bfb9b63c13f529617f9d4ff9df1fe5b9afab  https://httpbin.org/anything/                 449
./httpbin.org/5beaf92c22ec766fee51b0cdc59fb5c0811bb844  https://httpbin.org/anything/foo/bar/         466
...

And here's what I might do if I was looking for only '200 OK' responses:

▶ grep -ril '200 ok' * | grep -v index | xargs -n1 -I{} sh -c "echo -n '{} '; head -n1 {}; stat --format=%s {}" | paste - - | column -t
example.com/51f3333634a04aef57f8917da0e3a1cfca60816b  https://example.com/                   1728
example.com/f591aca5a4b976f816baff849189ef1b8451117f  https://example.com/                   1705
example.com/38c1195f861f6045d07f3e655c616ab7f7d8825c  https://example.com/                   458
example.com/2f723cf900d13593b1e38fec77ee929a992de9d8  https://example.com/                   482
example.com/74e13576952b21af9584698c02261a24af4b915a  https://example.com/                   477
...

tomnomnom avatar Jan 09 '18 11:01 tomnomnom

Hi @tomnomnom,

Any development on this for inbuild support? displaying content length along with status code at runtime?

ehsandeep avatar May 02 '18 22:05 ehsandeep

Hi @madaratech ,

We can get the length/size of the response by using len(res.body)

Just change this line in your code and then compile it.

screen

Hope it helps :)

bugbaba avatar Nov 21 '18 15:11 bugbaba