Subject Re: Options header
From Steven <AndromedaXS@yahoo.com>
Date Mon, 16 Dec 2019 06:39:41 -0500
Newsgroups xb2net

FUNCTION httpFilterRequest( oClient )
  LOCAL aAllowMethods := { "GET", "HEAD", "POST", "OPTIONS" }, cAllowMethods := ""

// stuff
            CASE oClient:HTTPRequest:command == "OPTIONS"
              // The Method token indicates the method to be performed on the resource identified by the Request-URI.
              // The method is case-sensitive. OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE en CONNECT
              cAllowMethods := ""
              oClient:HTTPResponse:Allow := ""
              AEVAL( aAllowMethods, { |c,i| cAllowMethods += c+IIF( i == LEN( aAllowMethods), "", "," ) } )

              // HTTP access control (CORS)
              IF !EMPTY( oClient:HTTPRequest:Origin )  // RFC-6454
                  oClient:HTTPResponse:SetHeader( "Access-Control-Allow-Origin", oClient:HTTPRequest:Origin )
                  oClient:HTTPResponse:SetHeader( "Access-Control-Allow-Methods", cAllowMethods )
                  oClient:HTTPResponse:SetHeader( "Access-Control-Allow-Headers", "Content-Type, Content-Encoding, Accept-Language, Accept-Encoding, Accept-Charset, SOAPAction" )
                ELSE
                  oClient:HTTPResponse:Allow := cAllowMethods
              ENDIF
              oClient:HTTPResponse:Content := ""
              oClient:HTTPResponse:ContentLength := 0
              oClient:HTTPResponse:ContentType( "text/html; charset=utf-8" )
              oClient:HTTPResponse:StatusCode := 200   // Success
              lRetVal := FALSE
// stuff

  RETURN ( lRetVal )



Recent messages in this thread
 
-# Options header Sjors Janse Kok 15-Dec-2019 08:01 am
.-# Re: Options header Boris Borzic <bb> 15-Dec-2019 01:15 pm
..\# Re: Options header (Current message) Steven 16-Dec-2019 06:39 am