How to get content-type in Pages middleware?

I’d like to add a middleware function that processes static HTML files, but not other static assets. This is what I’m trying to do:

export const onRequest: PagesFunction = async (context) => {
  const response = await;
  if (response.headers.get("Content-Type") !== "text/html") {
    return response;
  } else {
    // ...
    return updated_response;

However, response.headers is empty when my middleware is called.

Is there a way for the middleware to determine what content-type Pages is going to use for a given response? I’d prefer to use the default Pages logic rather than trying to figure it out for myself (e.g. by inspecting the URL or the response body).