surf icon indicating copy to clipboard operation
surf copied to clipboard

Incorrect Content-Type value returned

Open hipstermojo opened this issue 4 years ago • 4 comments

Surf seems to return a Content-Type: application/json header when fetching images from webpages built with Notion. I tried making the same requests over curl and it logged the correct headers e.g Content-Type: image/gif for this gif which is an image from this article.

hipstermojo avatar Feb 09 '21 05:02 hipstermojo

Can you share one of these files? That would indicate it has incorrect magic bytes somehow.

Fishrock123 avatar Mar 01 '21 19:03 Fishrock123

That is the gif linked to in the first comment. aaf09519-3f8a-42f9-b794-43dc0d322cad

That would indicate it has incorrect magic bytes somehow.

Does it mean that surf relies on magic bytes first, then the content-type header, to determine a file type?

hipstermojo avatar Mar 02 '21 04:03 hipstermojo

Oh sorry, on remote read it should be content-type first.

It seems that when doing client decode it is not actually set properly.

Though, I would expect it to be application/octet-stream, since that's what Body::from_reader would set it to.

From deepest outwards to Surf:

  1. http_types::Body::from_reader()
  2. async_h1::client::decode()
  3. http_client::h1::H1Client::send()
  4. surf::Client::send()

Fishrock123 avatar Mar 02 '21 17:03 Fishrock123

I suspect this code should probably live in async-h1.

Fishrock123 avatar Mar 02 '21 17:03 Fishrock123