[Bug] Content Delivery API returns an invalid Vary header

I was trying to hook up my content with GraphCDN so I can cache the query result, and while doing that I noticed it gives me an error saying Error 503 illegal Vary header from backend.

In fact, this isn’t a bug from GraphCDN; it’s an error message shown from the Fastly (the underlying CDN provider of GraphCDN) which disallows malformed Vary headers as they stated in their documentation.

So I curled up the Content Delivery API and I noticed there’s no spaces on the Vary header.

< vary: Accept,Accept-Encoding

It should have a space after the comma, as stated by RFC 7231.

Hello @basix ,

I’ve contacted the dev team about this, and i’ll get back to you as soon as possible

Thank you for letting us know!

Hi @basix, where did you exactly read that a space is required after the comma? I can’t find it in RFC, and I’ve seen myself many times this compact form. Are you sure that that’s the reason why Fastly’s saying that the header is malformed, or maybe it could be something else? :confused:

I’m pretty sure Fastly is putting 502 because of Vary header since the error says this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>503 Illegal Vary header from backend</title>
  </head>
  <body>
    <h1>Error 503 Illegal Vary header from backend</h1>
    <p>Illegal Vary header from backend</p>
    <h3>Guru Mediation:</h3>
    <p>Details: cache-icn1450034-ICN 1644386787 3055346844</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>

However I couldn’t find any statement that the comma-separated list should have spaces except the example section of the RFC itself which is quite confusing…

I’ll deploy a simple endpoint with the Vary header like above and check if the error persists.

Update - RFC says both are valid: RFC 2616 - Hypertext Transfer Protocol -- HTTP/1.1.

I think this issue can be closed as this issue should be solved by Fastly folks. Thank you so much for taking your time to look into this issue!

No problem, let us know how it goes!