title: ColdFusion not handles HTTP OPTIONS requests for CFC
body: <p>Scenario:</p>
  
  <ul>
  <li>A webserver which hosts a frontend application based on ExtJS.</li>
  <li>A ColdFusion 10 server (with Apache) that hosts backend services.</li>
  <li>Frontend application make AJAX requests to ColdFusion components (CFC) with form <code>http://&lt;CF_server&gt;/&lt;app_path&gt;/&lt;CFC&gt;?method=someMethod&amp;...</code></li>
  <li>CFC responds with JSON.</li>
  </ul>
  
  <p>Since frontend and backend are on different servers we are in a CORS (Cross-Origin Resource Sharing) environment and AJAX requests making two http requests to backend: first is an OPTIONS method for handshake and second is a POST request. I have need enabling headers in Apache on CF server and using "Header set Access-Control-Allow-Origin: *" directive for enabling CORS, but I would like handling headers programmatically from CF not Apache. I have run some test and I noticed that OPTIONS method in http request works only with CFM and not with CFC, so the first AJAX request (with OPTIONS method) fails. I can bypass OPTIONS request in AJAX call setting useDefaultXhrHeader properties, but I would understand CF behavior.</p>
  
  <p>After running tests with cfhttp tag I have found that:</p>
  
  <ul>
  <li>HTTP request with OPTIONS method to CFM are similar to GET method: triggers events method on Application.cfc (orRequestStart, ...), returns filecontent and headers.</li>
  <li>HTTP request with OPTIONS method to CFC don't triggers events, don't return filecontent nor headers.</li>
  <li>A call (with OPTSIONS method) to unexistants CFC return same result.</li>
  </ul>
  
  <p>Why CF not handle OPTIONS method when calling CFC?</p>
  
  <p>In my tests i have bypassed Apache using integrated CF webserver on port 8500. I have also tried on CF9 with same results. Railo, instead, has a different behavior: handles OPTIONS method also for CFC.</p>
  
  <p>This is similar as this thread without response: <a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:59715" rel="nofollow">http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:59715</a></p>
  
  <p>Thanks.</p>