akka/akka-http

akka.http.scaladsl.model.Uri apply() methods should not take charset and mode as arguments?

Offen

#395 geöffnet am 15.10.2016

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Scala (598 Forks)batch import
1 - triagedhelp wanted

Repository-Metriken

Stars
 (1.311 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 10h) (2 gemergte PRs in 30 T)

Beschreibung

This was discussed in Akka User Group, and the review discussion which was in akka/akka#18715.

sirthias on Oct 13, 2015 IMHO neither the charset nor the mode is a property of the URI.

Now that the Uri.query() method takes charset and mode as arguments after the above PR 18175 was merged.

Then, I think we should deprecate Uri's apply() methods which take charset and mode arguments? Otherwise there could be confusing use like below.

val uri = Uri("http://localhost?a^=b", mode=Uri.ParsingMode.Relaxed)

println(uri.query(mode=Uri.ParsingMode.Relaxed).get("a^"))
//prints Some(b)

println(uri.query(mode=Uri.ParsingMode.Strict).get("a^"))
//!!! You pass a different mode after Uri's apply() was called, and get a different result !!!
//IllegalUriException: Illegal query: Invalid input '^', expected '+', '=', query-char, 'EOI', '&' or pct-ncoded (line 1, column 2): a^=b

Contributor Guide