Skip to content

//okhttp/okhttp3/HttpUrl/toUri

toUri

[jvm]\

@JvmName(name = "uri")

fun toUri(): URI

Returns this URL as a java.net.URI. Because URI is more strict than this class, the returned URI may be semantically different from this URL:

  • Characters forbidden by URI like [ and | will be escaped.
  • Invalid percent-encoded sequences like %xx will be encoded like %25xx.
  • Whitespace and control characters in the fragment will be stripped.

These differences may have a significant consequence when the URI is interpreted by a web server. For this reason the URI class and this method should be avoided.