Skip to content

Commit

Permalink
[PSR-7] Errata: scheme delimiters
Browse files Browse the repository at this point in the history
A [discussion on the mailing list](https://groups.google.com/d/msgid/php-fig/db3d5421-30a5-4135-9f9e-fe432f03d719%40googlegroups.com?utm_medium=email&utm_source=footer) raised the point that
`:` is the actual scheme delimiter. In reviewing [RFC 3986 section 3](https://tools.ietf.org/html/rfc3986#section-3),
I noted that `:` is the end delimiter for a scheme, and `//` is the opening
delimiter for the authority. Since the `UriInterface` does not allow setting the
authority in a single go, the only time the `//` delimiter will likely be used
is as part of the scheme, making the current wording valid. However, the wording
should also note that a trailing `:` delimiter MUST be removed as well.

Created an "Errata" section that adds this; we can vote on it post-acceptance.
  • Loading branch information
weierophinney committed Mar 31, 2015
1 parent 7941563 commit f1f4ba5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions proposed/http-message-meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,26 @@ used to populate the headers of an HTTP message.
* Phil Sturgeon
* Chris Wilkinson
* Evert Pot

## 7. Votes

## 8. Errata

### 8.1 Scheme Delimiters

Per [RFC 3986 section 3](https://tools.ietf.org/html/rfc3986#section-3), `:` is
considered a closing delimiter for a scheme, and `//` is considered an
opening delimeter for the URI authority.

In the specification as accepted, `Psr\Http\Message\UriInterface` indicates that
the methods `withScheme()` and `getScheme()` should ignore a trailing `://`
delimiter for purposes of consistency. (No similar stipulation is placed on the
authority, as authority is not treated as a single segment, but rather as its
own individual segments (`user-info`, `host`, and `port`)).

The `://` delimiter was called out specifically, as schemes are widely either
presented as the bare-word (e.g., `http`, `https`) or with that delimiter (e.g.,
`http://`, `https://`), which is the combination of the scheme closing delimiter
and the authority opening delimiter. However, implementations of the methods
MUST also strip a closing `:` delimiter when presented without the opening `//`
delimiter.
4 changes: 4 additions & 0 deletions proposed/http-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,8 @@ interface UriInterface
*
* The string returned MUST omit the trailing "://" delimiter if present.
*
* @see https://github.com/php-fig/fig-standards/blob/proposed/http-message-meta.md#81-scheme-delimiters
* which indicates ":" delimiters must also be omitted.
* @return string The scheme of the URI.
*/
public function getScheme();
Expand Down Expand Up @@ -1276,6 +1278,8 @@ interface UriInterface
*
* An empty scheme is equivalent to removing the scheme.
*
* @see https://github.com/php-fig/fig-standards/blob/proposed/http-message-meta.md#81-scheme-delimiters
* which indicates ":" delimiters must also be omitted.
* @param string $scheme The scheme to use with the new instance.
* @return self A new instance with the specified scheme.
* @throws \InvalidArgumentException for invalid or unsupported schemes.
Expand Down

0 comments on commit f1f4ba5

Please sign in to comment.