Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uri.Authority.toString renders leading double slash #784

Closed
jrudolph opened this issue Jan 17, 2017 · 1 comment
Closed

Uri.Authority.toString renders leading double slash #784

jrudolph opened this issue Jan 17, 2017 · 1 comment
Labels
bug help wanted Identifies issues that the core team will likely not have time to work on t:core Issues related to the akka-http-core module t:model Issues around the model classes and its functionality
Milestone

Comments

@jrudolph
Copy link
Member

While the overall rendering of URIs is fine, Uri.Authority.toString will render leading double slashes (which will also fail the round-trip Uri.Authority.parse(authority.toString)):

scala> Uri("http://localhost/test").authority
res1: akka.http.scaladsl.model.Uri.Authority = //localhost

scala> Uri.Authority.parse(res1.toString)
akka.http.scaladsl.model.IllegalUriException: Illegal authority: Invalid input '/', expected authority or 'EOI' (line 1, column 1): //localhost
^
  at akka.http.scaladsl.model.IllegalUriException$.apply(ErrorInfo.scala:40)
  at akka.http.scaladsl.model.Uri$.fail(Uri.scala:750)
  at akka.http.impl.model.parser.UriParser.fail(UriParser.scala:77)
  at akka.http.impl.model.parser.UriParser.parseAuthority(UriParser.scala:72)
  at akka.http.scaladsl.model.Uri$Authority$.parse(Uri.scala:331)
  ... 42 elided

This doesn't seem to be covered by the spec.

https://tools.ietf.org/html/rfc3986#section-3:

   The generic URI syntax consists of a hierarchical sequence of
   components referred to as the scheme, authority, path, query, and
   fragment.

      URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

      hier-part   = "//" authority path-abempty / [...]

  [...]

   The following are two example URIs and their component parts:

         foo://example.com:8042/over/there?name=ferret#nose
         \_/   \______________/\_________/ \_________/ \__/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         / \ /                        \
         urn:example:animal:ferret:nose

So, the double slashes belong to the hier-part and not to the authority.

In URI we could move the rendering of the double slashes from renderAuthority (which is used in Authority.toString) to renderUriWithoutFragment. Hopefully making this change won't lead to much breakage.

@jrudolph jrudolph added bug help wanted Identifies issues that the core team will likely not have time to work on t:core Issues related to the akka-http-core module t:model Issues around the model classes and its functionality labels Jan 17, 2017
ulasakdeniz added a commit to ulasakdeniz/akka-http that referenced this issue Jan 19, 2017
@ktoso ktoso closed this as completed in 8a5833b Jan 19, 2017
@ktoso ktoso added this to the 10.0.2 milestone Jan 19, 2017
@ktoso
Copy link
Member

ktoso commented Jan 19, 2017

Be sure to note this issue in the release notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Identifies issues that the core team will likely not have time to work on t:core Issues related to the akka-http-core module t:model Issues around the model classes and its functionality
Projects
None yet
Development

No branches or pull requests

2 participants