The problem with that command is that you have to download the image in its entirety to get its size.
Also poal uses python and JS only.
The code poal uses downloads the header only.
No no no no no!
HEAD
The HEAD method asks for a response identical to that of a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.
Nothing's downloaded. The entire response (Wireshark, "Length" field) is 903 bytes and only contains the headers. You can test the same URL with http://
to see the unencrypted data in Wireshark (and as I suspected the capitalization of letters changed.)
I don't know what library you are using, but on the inside, all that's needed is to replace "GET /di-CF3ZOA.png" in the HTTP request with "HEAD /di-CF3ZOA.png" to get the headers.
https://docs.python.org/3/library/http.client.html#http.client.HTTPConnection.request
or https://stackoverflow.com/questions/107405/how-do-you-send-a-head-http-request-in-python-2
PS/Edit: Maybe I should have specified, curl -I
is curl --head
aka -I, --head Show document info only
, the HTTP HEAD request
Maybe I should have specified, curl -I
Ok didn't know about -I
I use requests library to get headers.
Everything works perfectly fine except for some corrupt jpeg files.
I uploaded one, you can try it with your code if you want and see if you get the same results.
Oh and also if you are not convinced yet ;) that it really doesn't transfer the whole file:
# a download, normal GET request
curl -L https://pic8.co/sh/m2v8Y4.jpg -o "/dev/null"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 33382 100 33382 0 0 13315 0 0:00:02 0:00:02 --:--:-- 25193
# HEAD request, received=0
curl -LI https://pic8.co/sh/m2v8Y4.jpg -o "/dev/null"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 33382 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
Some very stupid servers may not show content-length, and that's the ONLY time you'd want to download either the file header or the whole file.
(post is archived)