Example #1
0
    /**
     * Returns the HTTP Prefer header information.
     *
     * The prefer header is defined in:
     * http://tools.ietf.org/html/draft-snell-http-prefer-14
     *
     * This method will return an array with options.
     *
     * Currently, the following options may be returned:
     *  [
     *      'return-asynch'         => true,
     *      'return-minimal'        => true,
     *      'return-representation' => true,
     *      'wait'                  => 30,
     *      'strict'                => true,
     *      'lenient'               => true,
     *  ]
     *
     * This method also supports the Brief header, and will also return
     * 'return-minimal' if the brief header was set to 't'.
     *
     * For the boolean options, false will be returned if the headers are not
     * specified. For the integer options it will be 'null'.
     *
     * @return array
     */
    function getHTTPPrefer() {

        $result = [
            // can be true or false
            'respond-async' => false,
            // Could be set to 'representation' or 'minimal'.
            'return'        => null,
            // Used as a timeout, is usually a number.
            'wait'          => null,
            // can be 'strict' or 'lenient'.
            'handling'      => false,
        ];

        if ($prefer = $this->httpRequest->getHeader('Prefer')) {

            $result = array_merge(
                $result,
                \Sabre\HTTP\parsePrefer($prefer)
            );

        } elseif ($this->httpRequest->getHeader('Brief') == 't') {
            $result['return'] = 'minimal';
        }

        return $result;

    }
Example #2
0
 /**
  * Returns the HTTP Prefer header information.
  *
  * The prefer header is defined in:
  * http://tools.ietf.org/html/draft-snell-http-prefer-14
  *
  * This method will return an array with options.
  *
  * Currently, the following options may be returned:
  *  [
  *      'return-asynch'         => true,
  *      'return-minimal'        => true,
  *      'return-representation' => true,
  *      'wait'                  => 30,
  *      'strict'                => true,
  *      'lenient'               => true,
  *  ]
  *
  * This method also supports the Brief header, and will also return
  * 'return-minimal' if the brief header was set to 't'.
  *
  * For the boolean options, false will be returned if the headers are not
  * specified. For the integer options it will be 'null'.
  *
  * @return array
  */
 function getHTTPPrefer()
 {
     $result = ['respond-async' => false, 'return' => null, 'wait' => null, 'handling' => false];
     if ($prefer = $this->httpRequest->getHeader('Prefer')) {
         $result = array_merge($result, \Sabre\HTTP\parsePrefer($prefer));
     } elseif ($this->httpRequest->getHeader('Brief') == 't') {
         $result['return'] = 'minimal';
     }
     return $result;
 }