Content-Length in HEAD requests through workers


#1

Hi!

I think I’m seeing an issue with workers when handling HEAD requests. According to RFC the Content-Length header should be the the same as when doing a GET request. My backend server sends the correct Content-Length but when the request goes through a worker then Content-Length is always 0.
This seems to happen with even a minimal handler like this:

addEventListener('fetch', event => {
  event.respondWith(handle(event))
})
async function handle(event) {
  return await fetch(event.request)
}

Worth noting that when the request bypasses workers but still goes via CloudFlare then Content-Length is correct.

Is this expected behaviour in workers?

Thanks!


#2

Hi @dev8,

This is a bug! Here’s the fix:

If nothing goes wrong, it should roll out by the end of this week. Thanks for reporting this!


#3

Great news! Thank you for the fast response!


#4

This should now be fixed globally!