On Fri, Jan 10, 2020 at 1:17 PM Anton Fedonjuk <antonfedon...@gmail.com> wrote:
> $request->withRequestTarget('http://www.example.org/pub/page.html'); > method must change "Host" header and/or URI? > > I ask because *all* the PSR-7-compatible packages that I saw don't do > this. I think it's happened because note added only for withUri. > I think you're not understanding the purpose of the request-target within a request. Section 1.4 of the PSR-7 spec details the purpose, and how different values are interpreted. The point to understand, however, is that these serve a different purpose than the composed UriInterface. The UriInterface is used by a client in order to determine the protocol, port, and hostname so that the client can connect to the server in question. The request-target is the value used as the second segment of the request line when transmitting the request. In PSR-7, if no request-target is provided, then the string form of the URI fills in as an absolute-form request-target. Because the request-target can take a variety of forms that are not compliant with a UriInterface implementation (e.g., asterix-form, for OPTIONS requests; authority-form, for CONNECT requests; origin-form, which is typically only the pat; etc.), we allow setting it _separately_ from the URI. This means that setting it MUST NOT change the URI, as the point is that this is to customize the request line, and otherwise not affect how a client connects to the server. You ask "how URI can be not available?" When using PSR-17, it MUST be present. However, if you are using a specific implementation, it's entirely possible to construct a fully empty request. This is why we indicate the default behavior when that happens. -- Matthew Weier O'Phinney mweierophin...@gmail.com https://mwop.net/ he/him -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myWSgfFVhDN4_U7iJOwyRY3D30kd70zUirWcQrsTeGHZFg%40mail.gmail.com.