Neos\Flow\Http\Request::getMethod PHP Method

getMethod() public method

Returns the request method
public getMethod ( ) : string
return string The request method
    public function getMethod()
    {
        return $this->method;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Analyzes this response, considering the given request and makes additions
  * or removes certain headers in order to make the response compliant to
  * RFC 2616 and related standards.
  *
  * It is recommended to call this method before the response is sent and Flow
  * does so by default in its built-in HTTP request handler.
  *
  * @param Request $request The corresponding request
  * @return void
  * @api
  */
 public function makeStandardsCompliant(Request $request)
 {
     if ($request->hasHeader('If-Modified-Since') && $this->headers->has('Last-Modified') && $this->statusCode === 200) {
         $ifModifiedSinceDate = $request->getHeader('If-Modified-Since');
         $lastModifiedDate = $this->headers->get('Last-Modified');
         if ($lastModifiedDate <= $ifModifiedSinceDate) {
             $this->setStatus(304);
             $this->content = '';
         }
     } elseif ($request->hasHeader('If-Unmodified-Since') && $this->headers->has('Last-Modified') && ($this->statusCode >= 200 && $this->statusCode <= 299 || $this->statusCode === 412)) {
         $unmodifiedSinceDate = $request->getHeader('If-Unmodified-Since');
         $lastModifiedDate = $this->headers->get('Last-Modified');
         if ($lastModifiedDate > $unmodifiedSinceDate) {
             $this->setStatus(412);
         }
     }
     if (in_array($this->statusCode, [100, 101, 204, 304])) {
         $this->content = '';
     }
     if ($this->headers->getCacheControlDirective('no-cache') !== null || $this->headers->has('Expires')) {
         $this->headers->removeCacheControlDirective('max-age');
     }
     if ($request->getMethod() === 'HEAD') {
         if (!$this->headers->has('Content-Length')) {
             $this->headers->set('Content-Length', strlen($this->content));
         }
         $this->content = '';
     }
     if (!$this->headers->has('Content-Length')) {
         $this->headers->set('Content-Length', strlen($this->content));
     }
     if ($this->headers->has('Transfer-Encoding')) {
         $this->headers->remove('Content-Length');
     }
 }
All Usage Examples Of Neos\Flow\Http\Request::getMethod