DMarby / picsum-photos

Lorem Ipsum... but for photos.
https://picsum.photos
MIT License
2.2k stars 152 forks source link

`Picsum-ID` header is missing #109

Closed crstauf closed 7 months ago

crstauf commented 7 months ago

The https://picsum.photos/#image-details section indicates that "you can find out the ID of an image by looking at the Picsum-ID header", but there is no header with said key.

$ curl -I https://picsum.photos/seed/picsum/
HTTP/2 404 
date: Tue, 30 Jan 2024 17:20:54 GMT
content-type: text/plain; charset=utf-8
content-length: 15
cache-control: private, no-cache, no-store, must-revalidate
vary: Origin
x-content-type-options: nosniff
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=8jetgTCWtWb6ELM9jk09rEGz2QQC7FlOIpzsm8EY9%2Fu86AMkApYz2TjA5RL%2BOBm9pFfhy21GjYUXZu%2BHUMX6pf5AIv192jHA9HC%2FR2nWdy1yACRUrzwN0zB6U4q4zKI%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
strict-transport-security: max-age=15552000
server: cloudflare
cf-ray: 84db6360cbb6b3d1-MIA
alt-svc: h3=":443"; ma=86400
DMarby commented 7 months ago

Hi,

The url you posted in your example is invalid (as per the 404), it's missing /info or picture dimensions at the end.

If you use the endpoint with /info, it will return the information as JSON:

curl -L -X GET https://picsum.photos/seed/picsum/info
{"id":"866","author":"Samuel Zeller","width":4704,"height":3136,"url":"https://unsplash.com/photos/9RqA6tnT0gA","download_url":"https://picsum.photos/id/866/4704/3136"}

If you use the endpoint with dimensions correctly, it will return a redirect with the image. If you follow this redirect, you will find that it indeed contains the Picsum-ID header:

▶ curl -L -I -X GET https://picsum.photos/seed/picsum/200/200
HTTP/2 302
date: Tue, 30 Jan 2024 20:39:11 GMT
content-length: 0
location: https://fastly.picsum.photos/id/866/200/200.jpg?hmac=i0ngmQOk9dRZEzhEosP31m_vQnKBQ9C19TBP1CGoIUA
cache-control: private, no-cache, no-store, must-revalidate
vary: Origin
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=xtrVWvfZJuKnqBMMx%2F3o97bytzoLduvaFIG%2FJiJf61tBDbzvi6MVUXhXcPm47bDaFS%2BpB7nrX3f%2FBbQ%2F6TQHTIThEj1%2FrTXhdNh%2FT96MsXfQBrITFYTxywI%2BYI8t5G0%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
strict-transport-security: max-age=15552000
x-content-type-options: nosniff
server: cloudflare
cf-ray: 84dc85d70f872d69-ARN
alt-svc: h3=":443"; ma=86400

HTTP/2 200
content-type: image/jpeg
cache-control: public, max-age=2592000, stale-while-revalidate=60, stale-if-error=43200, immutable
content-disposition: inline; filename="866-200x200.jpg"
picsum-id: 866
timing-allow-origin: *
accept-ranges: bytes
date: Tue, 30 Jan 2024 20:39:11 GMT
via: 1.1 varnish
age: 562462
x-served-by: cache-bma1667-BMA
x-cache: HIT
x-cache-hits: 1
x-timer: S1706647151.354844,VS0,VE1
vary: Origin
content-length: 5115
crstauf commented 7 months ago

Ahhh, my (silly) mistake with the 404. Thanks for your help.