0

I ran into an issue which is little strange. The files were migrated on the server long back and were never changed since a month and everything was working fine.

Basically I had this in PHP(I was using laravel framework 5.2) since a month :

header("Access-Control-Allow-Methods : GET, POST, PUT, DELETE");

The website was working fine and suddenly today it stopped working. I had this error in apache error.log : Header Access-Control-Allow-Methods contains invalid characters.

When I removed the space after colon and made like below it worked immediately :

 header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");

My concern is :

  1. Can this space cause such issue?
  2. What could be the reason it was working fine before and same code started throwing error today.
  3. I am using AWS EC2 instance and I checked, there were no server/service updates performed, nor any other files were changed.
  4. My zend opcache module is disabled, so I am curious if it was cached, what was it for?

Any help would be much appreciated.

legoscia
  • 39,593
  • 22
  • 116
  • 167
Mihir Bhende
  • 8,677
  • 1
  • 30
  • 37
  • What is the exact error message? The sole google result for what you typed is your post here suggesting that is not the error message. My understanding, and what I see on RFC 2616, is that space is NOT the issue. Red Herring? – ficuscr May 09 '17 at 21:11
  • 3
    A space *before* `:` is very much invalid. In RFC-2616 *"Each header field consists of a name followed by a colon (":") and the field value. ... The field value MAY be preceded by any amount of LWS, though a single SP is preferred."* The space *after* `:` is not an issue but the one before is simply wrong. – Michael - sqlbot May 10 '17 at 00:09

0 Answers0