PHP 트레잇 Zend\Diactoros\RequestTrait

Server and client-side requests differ slightly in how the Host header is handled; on client-side, it should be calculated on-the-fly from the composed URI (if present), while on server-side, it will be calculated from the environment. As such, this trait exists to provide the common code between both client-side and server-side requests, and each can then use the headers functionality required by their implementations.
파일 보기 프로젝트 열기: zendframework/zend-diactoros

공개 메소드들

메소드 설명
getMethod ( ) : string Retrieves the HTTP method of the request.
getRequestTarget ( ) : string Retrieves the message's request target.
getUri ( ) : Psr\Http\Message\UriInterface Retrieves the URI instance.
withMethod ( string $method ) : static Return an instance with the provided HTTP method.
withRequestTarget ( mixed $requestTarget ) : static Create a new instance with a specific request-target.
withUri ( Psr\Http\Message\UriInterface $uri, boolean $preserveHost = false ) : static Returns an instance with the provided URI.

비공개 메소드들

메소드 설명
assertHeaders ( array $headers ) Ensure header names and values are valid.
createUri ( null | string | Psr\Http\Message\UriInterface $uri ) : Psr\Http\Message\UriInterface Create and return a URI instance.
getHostFromUri ( ) : string Retrieve the host from the URI instance
initialize ( null | string | Psr\Http\Message\UriInterface $uri = null, null | string $method = null, string | resource | Psr\Http\Message\StreamInterface $body = 'php://memory', array $headers = [] ) Initialize request state.
validateMethod ( null | string $method ) Validate the HTTP method

메소드 상세

getMethod() 공개 메소드

Retrieves the HTTP method of the request.
public getMethod ( ) : string
리턴 string Returns the request method.

getRequestTarget() 공개 메소드

Retrieves the message's request-target either as it will appear (for clients), as it appeared at request (for servers), or as it was specified for the instance (see withRequestTarget()). In most cases, this will be the origin-form of the composed URI, unless a value was provided to the concrete implementation (see withRequestTarget() below). If no URI is available, and no request-target has been specifically provided, this method MUST return the string "/".
public getRequestTarget ( ) : string
리턴 string

getUri() 공개 메소드

This method MUST return a UriInterface instance.
public getUri ( ) : Psr\Http\Message\UriInterface
리턴 Psr\Http\Message\UriInterface Returns a UriInterface instance representing the URI of the request, if any.

withMethod() 공개 메소드

While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method.
public withMethod ( string $method ) : static
$method string Case-insensitive method.
리턴 static

withRequestTarget() 공개 메소드

If the request needs a non-origin-form request-target — e.g., for specifying an absolute-form, authority-form, or asterisk-form — this method may be used to create an instance with the specified request-target, verbatim. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the changed request target.
public withRequestTarget ( mixed $requestTarget ) : static
$requestTarget mixed
리턴 static

withUri() 공개 메소드

This method will update the Host header of the returned request by default if the URI contains a host component. If the URI does not contain a host component, any pre-existing Host header will be carried over to the returned request. You can opt-in to preserving the original state of the Host header by setting $preserveHost to true. When $preserveHost is set to true, the returned request will not update the Host header of the returned message -- even if the message contains no Host header. This means that a call to getHeader('Host') on the original request MUST equal the return value of a call to getHeader('Host') on the returned request. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new UriInterface instance.
public withUri ( Psr\Http\Message\UriInterface $uri, boolean $preserveHost = false ) : static
$uri Psr\Http\Message\UriInterface New request URI to use.
$preserveHost boolean Preserve the original state of the Host header.
리턴 static