title: Azure functions & HTTP OPTIONS request
body: <p>I want an existing application (which I do not control) to send information to an Azure function. </p>
  
  <p>The application first sends a HTTP OPTIONS request, and will then regularly send HTTP POST messages.</p>
  
  <p>The problem I have is that the application expects a header "Allow : POST,OPTIONS" in the response from the Azure function on the OPTIONS request. If the header is not present, it will not continue (instead, it throws an error : 'POST is not allowed')</p>
  
  <p>When trying to set the header in Azure functions, I get the following error message </p>
  
  <p><code>System.Net.Http: Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.</code></p>
  
  <p>I did enable CORS for all locations, and allowed all methods in the configuration.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>module.exports = function (context, req) 
  {
      //context.log('JavaScript HTTP trigger function processed a request.');
  
      if (req.method == "OPTIONS") 
      {
              context.res = 
              {
                  body: "",
                  headers: 
                  { 
                      //"Access-Control-Allow-Methods" : "POST,OPTIONS",
                      "allow" : "POST,OPTIONS"
                  },
                  status: 200,
              };
      }
      context.done();
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The specification say that the Allow header should be set for a 405 response. If the header is empty, nothing is allowed. However, there is no logic defined for when the header is not present at all.</p>
  
  <p>Is there a method through which I can send this header in response to the HTTP OPTIONS ?</p>